Skip to content

Commit

Permalink
Improve error reporting in GitHub and always fetch latest stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam committed Feb 29, 2024
1 parent ca94290 commit d318fe1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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

2 changes: 1 addition & 1 deletion Pythonwin/pywin/framework/stdin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion pyrightconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
23 changes: 9 additions & 14 deletions pywin32_postinstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit d318fe1

Please sign in to comment.