|
2 | 2 | # |
3 | 3 | # copies pywintypesXX.dll and pythoncomXX.dll into the system directory, |
4 | 4 | # and creates a pth file |
| 5 | +import argparse |
5 | 6 | import glob |
6 | 7 | import os |
7 | 8 | import shutil |
8 | 9 | import sys |
9 | 10 | import sysconfig |
10 | | - |
11 | | -try: |
12 | | - import winreg as winreg |
13 | | -except: |
14 | | - import winreg |
15 | | - |
16 | | -# Send output somewhere so it can be found if necessary... |
17 | | -import tempfile |
| 11 | +import tempfile # Send output somewhere so it can be found if necessary... |
| 12 | +import winreg |
18 | 13 |
|
19 | 14 | tee_f = open(os.path.join(tempfile.gettempdir(), "pywin32_postinstall.log"), "w") |
20 | 15 |
|
@@ -44,11 +39,11 @@ def flush(self): |
44 | 39 | # with sys.stdout as None but stderr is hooked up. This work-around allows |
45 | 40 | # bdist_wininst to see the output we write and display it at the end of |
46 | 41 | # the install. |
47 | | -if sys.stdout is None: |
| 42 | +if sys.stdout is None: # pyright: ignore[reportUnnecessaryComparison] |
48 | 43 | sys.stdout = sys.stderr |
49 | 44 |
|
50 | | -sys.stderr = Tee(sys.stderr) # type: ignore[assignment] |
51 | | -sys.stdout = Tee(sys.stdout) # type: ignore[assignment] |
| 45 | +sys.stderr = Tee(sys.stderr) # type: ignore[assignment] # Not an actual TextIO |
| 46 | +sys.stdout = Tee(sys.stdout) # type: ignore[assignment] # Not an actual TextIO |
52 | 47 |
|
53 | 48 | com_modules = [ |
54 | 49 | # module_name, class_names |
@@ -193,7 +188,9 @@ def LoadSystemModule(lib_dir, modname): |
193 | 188 | loader = importlib.machinery.ExtensionFileLoader(modname, filename) |
194 | 189 | spec = importlib.machinery.ModuleSpec(name=modname, loader=loader, origin=filename) |
195 | 190 | mod = importlib.util.module_from_spec(spec) |
196 | | - spec.loader.exec_module(mod) |
| 191 | + spec.loader.exec_module( # pyright: ignore[reportOptionalMemberAccess] # We provide the loader, we know it won't be None |
| 192 | + mod |
| 193 | + ) |
197 | 194 |
|
198 | 195 |
|
199 | 196 | def SetPyKeyVal(key_name, value_name, value): |
@@ -697,8 +694,6 @@ def verify_destination(location): |
697 | 694 |
|
698 | 695 |
|
699 | 696 | def main(): |
700 | | - import argparse |
701 | | - |
702 | 697 | parser = argparse.ArgumentParser( |
703 | 698 | formatter_class=argparse.RawDescriptionHelpFormatter, |
704 | 699 | description="""A post-install script for the pywin32 extensions. |
|
0 commit comments