Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

support Callable / callable Protocols in suggest decorator unwarpping#19072

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
asottile wants to merge2 commits intopython:master
base:master
Choose a base branch
Loading
fromasottile:decorator-identity

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-actionsGitHub Actions

This comment has been minimized.

@@ -659,7 +671,7 @@ def extract_from_decorator(self, node: Decorator) -> FuncDef | None:
for ct in typ.items:
if not (
len(ct.arg_types) == 1
andisinstance(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 becomeis_same_type to allow aliases?

Copy link
ContributorAuthor

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

sterliakov reacted with thumbs up emoji
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.

@@ -659,7 +671,7 @@ def extract_from_decorator(self, node: Decorator) -> FuncDef | None:
for ct in typ.items:
if not (
len(ct.arg_types) == 1
andisinstance(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

@sterliakovsterliakov 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 batchingis_same_type here would be appropriate, but don't mind deferring that to a separate PR if you'd prefer. LG, thanks!

@github-actionsGitHub Actions
Copy link
Contributor

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

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@sterliakovsterliakovsterliakov approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

dmypy gives up on trivial decorator
2 participants
@asottile@sterliakov

[8]ページ先頭

©2009-2025 Movatter.jp