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

Allow passing a callable with type vars in self types #18401

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

A5rocks
Copy link
Collaborator

@A5rocks A5rocks commented Jan 1, 2025

Fixes #18400

@ilevkivskyi I'd appreciate if you checked the logic in this PR because I enabled polymorphic inference for binding self and had to handle [T] () -> (T) -> T into () -> [T] (T) -> T... I remember seeing this kind of push down logic before, but I can't remember if there's a common function or if there is an issue with doing that.

This comment has been minimized.

@ilevkivskyi
Copy link
Member

@A5rocks I will check this one later, sorry (with all the reviews I don't have time/energy to finish my PR adding support for properties with different setter types).

@A5rocks
Copy link
Collaborator Author

A5rocks commented Jan 21, 2025

This also makes the output on #14322 better, though I think the issue has already been solved:

#------ difference on issues/14322/blocks.json
+ /tmp/tmpcftql_gf:49: note: Revealed type is "def [P] (b_param_1: builtins.str, *P.args, **P.kwargs) -> __main__.B[P`<id>, __main__.ADerived]"
+ Success: no issues found in 1 source file
- /tmp/tmpcftql_gf:47: error: Need type annotation for "BADerived"  [var-annotated]
- /tmp/tmpcftql_gf:49: note: Revealed type is "def (*Any, **Any) -> __main__.B[[a_param_1: builtins.float], __main__.ADerived]"
- Found 1 error in 1 file (checked 1 source file)
#------

Copy link
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

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.

mypy doesn't escape typevars from generics in self-type
2 participants