-
Notifications
You must be signed in to change notification settings - Fork 811
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Basic type-checking with mypy and pyright #2102
Conversation
com/win32com/client/build.py
Outdated
NoTranslateMap = {} | ||
for v in NoTranslateTypes: | ||
NoTranslateMap[v] = None | ||
NoTranslateMap = set(NoTranslateTypes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this intended to be public API? If not I'd rename it to NoTranslateSet
com/win32com/client/gencache.py
Outdated
@@ -52,7 +56,8 @@ | |||
|
|||
# A dictionary of ITypeLibrary objects for demand generation explicitly handed to us | |||
# 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any idea where CallTipWindow
, dde
and pywin32_system32
come from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
def _make_tk_calltip_window(self): | |
import CallTipWindow | |
return CallTipWindow.CallTip(self.text) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
…-type-checking
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
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: