KEMBAR78
support Callable / callable Protocols in suggest decorator unwarpping by asottile · Pull Request #19072 · python/mypy · GitHub
Skip to content

Conversation

asottile
Copy link
Contributor

Resolves #18940

while I feel like just accepting any identity function would be good enough I expanded the check to explicitly allow Callables and Protocol callables

@github-actions

This comment has been minimized.

len(ct.arg_types) == 1
and isinstance(ct.arg_types[0], TypeVarType)
and _arg_accepts_function(get_proper_type(ct.arg_types[0]))
and ct.arg_types[0] == ct.ret_type
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can this become is_same_type to allow aliases?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I assume you mean the == line?

probably! but that'd be a separate issue / patch I would imagine

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, sorry, misclicked - I meant the == line of course.

len(ct.arg_types) == 1
and isinstance(ct.arg_types[0], TypeVarType)
and _arg_accepts_function(get_proper_type(ct.arg_types[0]))
and ct.arg_types[0] == ct.ret_type
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, sorry, misclicked - I meant the == line of course.

Co-authored-by: Stanislav Terliakov <50529348+sterliakov@users.noreply.github.com>
Copy link
Collaborator

@sterliakov sterliakov left a comment

Choose a reason for hiding this comment

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

I think batching is_same_type here would be appropriate, but don't mind deferring that to a separate PR if you'd prefer. LG, thanks!

@github-actions
Copy link
Contributor

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

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.

Thank you!

@hauntsaninja hauntsaninja merged commit ce5f127 into python:master Jun 18, 2025
18 checks passed
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.

dmypy gives up on trivial decorator

3 participants