-
Notifications
You must be signed in to change notification settings - Fork 804
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic type-checking with mypy and pyright (#2102)
- Loading branch information
Showing
6 changed files
with
148 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
[mypy] | ||
show_column_numbers = true | ||
warn_unused_ignores = true | ||
; Target the oldest supported version in editors | ||
python_version = 3.7 | ||
|
||
strict = false | ||
implicit_reexport = true | ||
|
||
; Implicit return types ! | ||
; TODO: turn back check_untyped_defs to true. For now this allows us to | ||
; at least put mypy in place by massively reducing checked code | ||
check_untyped_defs = false | ||
disallow_untyped_calls = false | ||
disallow_untyped_defs = false | ||
disallow_incomplete_defs = false | ||
|
||
; attr-defined: Module has no attribute (modules are dynamic) | ||
; method-assign: Cannot assign to a method (lots of monkey patching) | ||
; name-defined: Name "..." is not defined (dynamic modules will be hard to type without stubs, ie: pythoncom.*, leave undefined/unbound to Flake8/Ruff/pyright) | ||
disable_error_code = attr-defined, method-assign, name-defined | ||
; TODO: adodbapi should be updated and fixed separatly | ||
; Pythonwin/Scintilla is vendored | ||
; Pythonwin/pywin/idle is vendored IDLE extensions predating Python 2.3. They now live in idlelib in https://github.com/python/cpython/tree/main/Lib/idlelib | ||
; Ignoring non-public apis for now | ||
; Duplicate module named "rasutil" and "setup", short-term fix is to ignore | ||
exclude = .*((build|adodbapi|Pythonwin/Scintilla|Pythonwin/pywin/idle|[Tt]est|[Dd]emos?)/.*|rasutil.py|setup.py) | ||
|
||
; C-modules that will need type-stubs | ||
[mypy-adsi.*,dde,exchange,exchdapi,perfmon,servicemanager,win32api,win32clipboard,win32event,win32evtlog,win32file,win32gui,win32help,win32pdh,win32process,win32ras,win32security,win32service,win32trace,win32ui,win32uiole,win32wnet,wincerapi,winxpgui,_win32sysloader,_winxptheme] | ||
ignore_missing_imports = True | ||
|
||
; verstamp is installed from win32verstamp.py called in setup.py | ||
; Most of win32com re-exports win32comext | ||
; Test is a local untyped module in win32comext.axdebug | ||
; pywin32_system32 is an empty module created in setup.py to store dlls | ||
[mypy-verstamp,win32com.*,Test,pywin32_system32] | ||
ignore_missing_imports = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{ | ||
"typeCheckingMode": "basic", | ||
// Target the oldest supported version in editors | ||
"pythonVersion": "3.7", | ||
// Keep it simple for now by allowing both mypy and pyright to use `type: ignore` | ||
"enableTypeIgnoreComments": true, | ||
// Exclude from scanning when running pyright | ||
"exclude": [ | ||
"build/", | ||
// TODO: adodbapi should be updated and fixed separatly | ||
"adodbapi/", | ||
// Vendored | ||
"Pythonwin/Scintilla/", | ||
// Vendored IDLE extensions predating Python 2.3. They now live in idlelib in https://github.com/python/cpython/tree/main/Lib/idlelib | ||
"Pythonwin/pywin/idle/", | ||
// Ignoring non-public apis for now | ||
"**/Test/", | ||
"**/test/", | ||
"**/Demos/", | ||
"**/demo/", | ||
], | ||
// Packages that will be accessible globally. | ||
// Setting this makes pyright use the repo's code for those modules instead of typeshed or pywin32 in site-packages | ||
"extraPaths": [ | ||
"com", | ||
"win32/Lib", | ||
"Pythonwin", | ||
], | ||
// TODO: For now this allows us to at least put pyright in place by massively reducing checked code | ||
// it also reduces issues with the shipped types-pywin32 from typeshed | ||
"reportGeneralTypeIssues": "none", | ||
"reportArgumentType": "none", | ||
"reportAttributeAccessIssue": "none", | ||
// FIXE: These all need to be fixed first and turned back to error | ||
// some of the fixes need to be done in types-pywin32 from typeshed | ||
"reportAssignmentType": "warning", | ||
"reportCallIssue": "warning", | ||
"reportIndexIssue": "warning", | ||
"reportOperatorIssue": "warning", | ||
"reportOptionalCall": "warning", | ||
"reportOptionalIterable": "warning", | ||
"reportOptionalMemberAccess": "warning", | ||
"reportOptionalSubscript": "warning", | ||
// TODO: Leave Unbound/Undefined to its own PR(s) | ||
"reportUnboundVariable": "warning", | ||
"reportUndefinedVariable": "warning", | ||
// Too many dynamically generated modules. This will require type stubs to properly fix. | ||
"reportMissingImports": "warning", | ||
// IDEM, but happens when pywin32 is not in site-packages but module is found from typeshed. | ||
// TODO: Is intended to be fixed with an editable install | ||
// Since we're a library, and not user code, we care less about forgetting to install a dependency, | ||
// as long as we have its stubs. So just disabling for now is fine. | ||
"reportMissingModuleSource": "none", | ||
// External type stubs may not be completable, and this will require type stubs for dynamic modules. | ||
"reportMissingTypeStubs": "information", | ||
// Sometimes used for extra runtime safety | ||
"reportUnnecessaryComparison": "warning", | ||
// Use Flake8/Pycln/Ruff instead | ||
"reportUnusedImport": "none", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters