Basic type-checking with mypy and pyright#2102
Conversation
| NoTranslateMap = {} | ||
| for v in NoTranslateTypes: | ||
| NoTranslateMap[v] = None | ||
| NoTranslateMap = set(NoTranslateTypes) |
There was a problem hiding this comment.
Is this intended to be public API? If not I'd rename it to NoTranslateSet
| # Keyed by usual clsid, lcid, major, minor | ||
| demandGeneratedTypeLibraries = {} | ||
| # Typing as Any because PyITypeLib is not exposed | ||
| demandGeneratedTypeLibraries: dict[tuple[str, int, int, int], Any] = {} |
There was a problem hiding this comment.
Any should be used sparingly, it's an escape hatch. For instance: When it's impossible to represent a type accurately using the current type system.
In this case, we have no way to represent this type though python code (for now). And I need to pass something to the generic type parameter.
|
|
mypy.ini
Outdated
| ; Most of win32com re-exports win32comext | ||
| ; Test is a local untyped module in win32comext.axdebug | ||
| ; Not sure where the rest of modules/packages come from | ||
| [mypy-verstamp,win32com.*,Test,CallTipWindow,dde,pywin32_system32,] |
There was a problem hiding this comment.
Any idea where CallTipWindow, dde and pywin32_system32 come from?
There was a problem hiding this comment.
dde is a module - https://github.com/mhammond/pywin32/blob/main/setup.py#L2025
pywin32_system32 is a hack setup.py does to put the DLLs in a place where they aren't technically a package, eg, https://github.com/mhammond/pywin32/blob/main/setup.py#L337-L339
IIRC, CallTipWindow was a part of idle which we hackily reused -
pywin32/Pythonwin/pywin/idle/CallTips.py
Lines 38 to 41 in 4025d76
There was a problem hiding this comment.
I went on a deep dive about CallTipWindow yesterday. It comes from pre-Python 3.6 idlelib code. A lot of other modules have been renamed in Python 3.5. Some even have been merged into other modules way before that. Relevant PRs I found:
- CallTips / CallTipWindow renamed in 3.6: https://github.com/python/cpython/pull/7807/files
- Most modules renamed in 3.5: python/cpython@0d9220e
- AutoIndent (and others) removed in 2.3: python/cpython@3ae4eaa
So yeah, I too doubt this works anymore. Not anything for this PR to do. Not sure what you wanna do with that either. But for now I can at least document why CallTipWindow is not a found module.
a2bdd50 to
d54d3e7
Compare
d54d3e7 to
7a3c26f
Compare
3dab48d to
c892575
Compare
8b007f2 to
49c1bbb
Compare
|
Re "Solve some pyright warnings in changed files" - does this imply that in the future, when other changed files are touched, these same warnings might appear in those files? |
49c1bbb to
0a5a6ad
Compare
If a warning is present in a file that has been modified, yes. As for the fact that they show up as "GitHub annotations", I think I can disable that entirely from what I'm reading. https://github.com/actions/toolkit/blob/master/docs/commands.md#problem-matchers Edit: Didn't seem to work. If these annoy you, I can turn them to "info" in pyright configs. |
541fce0 to
ed2d377
Compare
ed2d377 to
c1374da
Compare
47353ca to
d318fe1
Compare
|
As a sidenote before this comes up: Test dependencies should probably be pinned. And even better: written to a |
|
@mhammond I think all of your latest concerns have been addressed here. Btw all of my currently opened PRs are ready for review / hoping for a merge. You can use this query to ignore |

This is the PR that finally makes basic type-checking validation of public methods possible, easing the addition of 3.7+ type annotations.
In its current state, a lot of checks are disabled, and some areas of code are completely ignored. But a handful of critical issues are now checked by GitHub actions and will help prevent some regressions.
A few typing fixes have already been provided where I considered they would be worth over disabling globally.
Once this PR is merged, I can in parallel start: