Skip to content
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

Substitute type variables in return type of static methods #16670

Merged
merged 1 commit into from
Dec 17, 2023

Conversation

kourbou
Copy link
Contributor

@kourbou kourbou commented Dec 16, 2023

add_class_tvars correctly instantiates type variables in the return type 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 #16668.

`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.
Copy link
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]

@kourbou
Copy link
Contributor Author

kourbou commented Dec 16, 2023

A little weird that this hit a recursion limit for daemons on Windows in the CI. Just tried -k testDaemonRecheck and -k testDaemonRunRestartPluginVersion on a Windows machine on my end and couldn't reproduce.

@AlexWaygood
Copy link
Member

A little weird that this hit a recursion limit for daemons on Windows in the CI. Just tried -k testDaemonRecheck and -k testDaemonRunRestartPluginVersion on a Windows machine on my end and couldn't reproduce.

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

Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thank you!

@hauntsaninja hauntsaninja merged commit 1dd8e7f into python:master Dec 17, 2023
17 of 18 checks passed
@kourbou kourbou deleted the fix-issue-16668 branch December 17, 2023 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'got "C[T]", expected "C[T]"' with staticmethod
3 participants