-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
Run mypy on Lib/test/libregrtest
in CI
#109382
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
Closed
Closed
Changes from 8 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
24db8b9
Run mypy on `Lib/test/libregrtest` in CI
AlexWaygood c217d64
fixes
AlexWaygood 73ac976
improve workflow file
AlexWaygood ad42b09
nit
AlexWaygood a637bce
minimize diff
AlexWaygood e1b0e4a
Add instructions to the mypy.ini file on how to run mypy
AlexWaygood 267bc83
Improve workflow file
AlexWaygood d24bcf9
Revert some unnecessary changes
AlexWaygood 87c3e8e
PEP 585
AlexWaygood 800d080
Add comment to `type: ignore` comment on `case TestResults()`
AlexWaygood 98d3000
Remove `PrintWarningsType`
AlexWaygood 581ef0d
`results.py`: Don't import `xml.etree.ElementTree` in the global scope
AlexWaygood 89e4a77
minimize diff
AlexWaygood File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,43 @@ | ||
# Config file for running mypy on libregrtest. | ||
# | ||
# Note: mypy can't be run on libregrtest from the CPython repo root. | ||
# If you try to do so, mypy will complain | ||
# about the entire `Lib/` directory "shadowing the stdlib". | ||
# Instead, `cd` into `Lib/test`, then run `mypy --config-file libregrtest/mypy.ini`. | ||
|
||
[mypy] | ||
packages = libregrtest | ||
python_version = 3.11 | ||
platform = linux | ||
pretty = True | ||
|
||
# Enable most stricter settings | ||
enable_error_code = ignore-without-code | ||
strict = True | ||
|
||
# Various stricter settings that we can't yet enable | ||
# Try to enable these in the following order: | ||
disallow_incomplete_defs = False | ||
disallow_untyped_calls = False | ||
disallow_untyped_defs = False | ||
check_untyped_defs = False | ||
warn_return_any = False | ||
|
||
# Various internal modules that typeshed deliberately doesn't have stubs for: | ||
[mypy-_abc.*] | ||
ignore_missing_imports = True | ||
|
||
[mypy-_opcode.*] | ||
ignore_missing_imports = True | ||
|
||
[mypy-_overlapped.*] | ||
ignore_missing_imports = True | ||
|
||
[mypy-_testcapi.*] | ||
ignore_missing_imports = True | ||
|
||
[mypy-_testinternalcapi.*] | ||
ignore_missing_imports = True | ||
|
||
[mypy-test.*] | ||
ignore_missing_imports = True |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Please don't do that. I want to minimize imports at startup, to minimize how many modules are imported when a test is run. Maybe even add a comment to explain why the import is not done at top level, that it's a deliberate choice.
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.
Okay. The reason why I did this was to accurately add type hints for the
TestResults.testsuite_xml
attribute on line 35. The current type hints for that attribute are incorrect, and caused several mypy errors.A possible workaround is to do the top-level import inside an
if TYPE_CHECKING
block.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 made that change in 581ef0d; let me know what you think!