Skip to content

Substitute type variables in return type of static methods#16670

Merged
hauntsaninja merged 1 commit into
python:masterfrom
kourbou:fix-issue-16668
Dec 17, 2023
Merged

Substitute type variables in return type of static methods#16670
hauntsaninja merged 1 commit into
python:masterfrom
kourbou:fix-issue-16668

Conversation

@kourbou

@kourbou kourbou commented Dec 16, 2023

Copy link
Copy Markdown
Contributor

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.
@github-actions

Copy link
Copy Markdown
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

kourbou commented Dec 16, 2023

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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

@hauntsaninja hauntsaninja left a comment

Copy link
Copy Markdown
Collaborator

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
@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