diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e5be54f54..a0583c3a9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -123,7 +123,7 @@ jobs: - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - - run: pip install mypy types-regex types-setuptools + - run: pip install types-regex types-setuptools mypy>=1.5 - run: mypy . --python-version=${{ matrix.python-version }} pyright: @@ -134,7 +134,13 @@ jobs: python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] steps: - uses: actions/checkout@v3 - - uses: jakebailey/pyright-action@v1 + - uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + # pyright vendors typeshed, but let's make sure we have the most up to date stubs + - run: pip install types-regex types-setuptools + - uses: jakebailey/pyright-action@v2 with: python-version: ${{ matrix.python-version }} + annotate: errors diff --git a/Pythonwin/pywin/framework/stdin.py b/Pythonwin/pywin/framework/stdin.py index 20e1b094b..91fe7ef3e 100644 --- a/Pythonwin/pywin/framework/stdin.py +++ b/Pythonwin/pywin/framework/stdin.py @@ -168,4 +168,4 @@ def fake_input(prompt=None): finally: get_input_line = input else: - sys.stdin = Stdin() # type: ignore[assignment] + sys.stdin = Stdin() # type: ignore[assignment] # Not an actual TextIO diff --git a/pyrightconfig.json b/pyrightconfig.json index 1b68253a1..1dd371af2 100644 --- a/pyrightconfig.json +++ b/pyrightconfig.json @@ -32,7 +32,7 @@ "reportArgumentType": "none", "reportAttributeAccessIssue": "none", // FIXE: These all need to be fixed first and turned back to error - // spme of the fixes need to be done in types-pywin32 from typeshed + // some of the fixes need to be done in types-pywin32 from typeshed "reportAssignmentType": "warning", "reportCallIssue": "warning", "reportIndexIssue": "warning", diff --git a/pywin32_postinstall.py b/pywin32_postinstall.py index f81c00e23..5a4981edc 100644 --- a/pywin32_postinstall.py +++ b/pywin32_postinstall.py @@ -2,19 +2,14 @@ # # copies pywintypesXX.dll and pythoncomXX.dll into the system directory, # and creates a pth file +import argparse import glob import os import shutil import sys import sysconfig - -try: - import winreg as winreg -except: - import winreg - -# Send output somewhere so it can be found if necessary... -import tempfile +import tempfile # Send output somewhere so it can be found if necessary... +import winreg tee_f = open(os.path.join(tempfile.gettempdir(), "pywin32_postinstall.log"), "w") @@ -44,11 +39,11 @@ def flush(self): # with sys.stdout as None but stderr is hooked up. This work-around allows # bdist_wininst to see the output we write and display it at the end of # the install. -if sys.stdout is None: +if sys.stdout is None: # pyright: ignore[reportUnnecessaryComparison] sys.stdout = sys.stderr -sys.stderr = Tee(sys.stderr) # type: ignore[assignment] -sys.stdout = Tee(sys.stdout) # type: ignore[assignment] +sys.stderr = Tee(sys.stderr) # type: ignore[assignment] # Not an actual TextIO +sys.stdout = Tee(sys.stdout) # type: ignore[assignment] # Not an actual TextIO com_modules = [ # module_name, class_names @@ -193,7 +188,9 @@ def LoadSystemModule(lib_dir, modname): loader = importlib.machinery.ExtensionFileLoader(modname, filename) spec = importlib.machinery.ModuleSpec(name=modname, loader=loader, origin=filename) mod = importlib.util.module_from_spec(spec) - spec.loader.exec_module(mod) + spec.loader.exec_module( # pyright: ignore[reportOptionalMemberAccess] # We provide the loader, we know it won't be None + mod + ) def SetPyKeyVal(key_name, value_name, value): @@ -697,8 +694,6 @@ def verify_destination(location): def main(): - import argparse - parser = argparse.ArgumentParser( formatter_class=argparse.RawDescriptionHelpFormatter, description="""A post-install script for the pywin32 extensions.