Substitute type variables in return type of static methods#16670
Merged
hauntsaninja merged 1 commit intopython:masterfrom Dec 17, 2023
Merged
Substitute type variables in return type of static methods#16670hauntsaninja merged 1 commit intopython:masterfrom
hauntsaninja merged 1 commit intopython:masterfrom
Conversation
`add_class_tvars` correctly instantiates type variables for class methods but not for static methods. Check if the analyzed member is a static method in `analyze_class_attribute_access` and substitute the type variable in the return type in `add_class_tvars` accordingly. Fixes python#16668.
Contributor
|
Diff from mypy_primer, showing the effect of this PR on open source code: Expression (https://github.com/cognitedata/Expression)
- tests/test_parser.py:243: error: Cannot infer type argument 1 of "pipe" [misc]
- tests/test_parser.py:245: error: Argument 2 to "pipe" has incompatible type "Callable[[Iterable[_TSource]], Block[_TSource]]"; expected "Callable[[list[Parser[Expression]]], Any]" [arg-type]
trio (https://github.com/python-trio/trio)
+ src/trio/_core/_multierror.py:247: error: Unused "type: ignore" comment [unused-ignore]
mongo-python-driver (https://github.com/mongodb/mongo-python-driver)
+ bson/json_util.py:324: error: Unused "type: ignore" comment [unused-ignore]
|
Contributor
Author
|
A little weird that this hit a recursion limit for daemons on Windows in the CI. Just tried |
Member
It's a stdlib bug in shutil.py that occasionally causes flakes in our test suite on Windows on older Python versions. Not caused by your PR; nothing to worry about |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
add_class_tvarscorrectly instantiates type variables in the return type for class methods but not for static methods. Check if the analyzed member is a static method inanalyze_class_attribute_accessand substitute the type variable in the return type inadd_class_tvarsaccordingly.Fixes #16668.