Skip to content

Commit d318fe1

Browse files
committed
Improve error reporting in GitHub and always fetch latest stubs
1 parent ca94290 commit d318fe1

4 files changed

Lines changed: 19 additions & 18 deletions

File tree

.github/workflows/main.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ jobs:
123123
- uses: actions/setup-python@v4
124124
with:
125125
python-version: ${{ matrix.python-version }}
126-
- run: pip install mypy types-regex types-setuptools
126+
- run: pip install types-regex types-setuptools mypy>=1.5
127127
- run: mypy . --python-version=${{ matrix.python-version }}
128128

129129
pyright:
@@ -134,7 +134,13 @@ jobs:
134134
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
135135
steps:
136136
- uses: actions/checkout@v3
137-
- uses: jakebailey/pyright-action@v1
137+
- uses: actions/setup-python@v4
138+
with:
139+
python-version: ${{ matrix.python-version }}
140+
# pyright vendors typeshed, but let's make sure we have the most up to date stubs
141+
- run: pip install types-regex types-setuptools
142+
- uses: jakebailey/pyright-action@v2
138143
with:
139144
python-version: ${{ matrix.python-version }}
145+
annotate: errors
140146

Pythonwin/pywin/framework/stdin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,4 @@ def fake_input(prompt=None):
168168
finally:
169169
get_input_line = input
170170
else:
171-
sys.stdin = Stdin() # type: ignore[assignment]
171+
sys.stdin = Stdin() # type: ignore[assignment] # Not an actual TextIO

pyrightconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"reportArgumentType": "none",
3333
"reportAttributeAccessIssue": "none",
3434
// FIXE: These all need to be fixed first and turned back to error
35-
// spme of the fixes need to be done in types-pywin32 from typeshed
35+
// some of the fixes need to be done in types-pywin32 from typeshed
3636
"reportAssignmentType": "warning",
3737
"reportCallIssue": "warning",
3838
"reportIndexIssue": "warning",

pywin32_postinstall.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,14 @@
22
#
33
# copies pywintypesXX.dll and pythoncomXX.dll into the system directory,
44
# and creates a pth file
5+
import argparse
56
import glob
67
import os
78
import shutil
89
import sys
910
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
1813

1914
tee_f = open(os.path.join(tempfile.gettempdir(), "pywin32_postinstall.log"), "w")
2015

@@ -44,11 +39,11 @@ def flush(self):
4439
# with sys.stdout as None but stderr is hooked up. This work-around allows
4540
# bdist_wininst to see the output we write and display it at the end of
4641
# the install.
47-
if sys.stdout is None:
42+
if sys.stdout is None: # pyright: ignore[reportUnnecessaryComparison]
4843
sys.stdout = sys.stderr
4944

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
5247

5348
com_modules = [
5449
# module_name, class_names
@@ -193,7 +188,9 @@ def LoadSystemModule(lib_dir, modname):
193188
loader = importlib.machinery.ExtensionFileLoader(modname, filename)
194189
spec = importlib.machinery.ModuleSpec(name=modname, loader=loader, origin=filename)
195190
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+
)
197194

198195

199196
def SetPyKeyVal(key_name, value_name, value):
@@ -697,8 +694,6 @@ def verify_destination(location):
697694

698695

699696
def main():
700-
import argparse
701-
702697
parser = argparse.ArgumentParser(
703698
formatter_class=argparse.RawDescriptionHelpFormatter,
704699
description="""A post-install script for the pywin32 extensions.

0 commit comments

Comments
 (0)