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

Fix annotated with function as type keyword list parameter#20094

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

Conversation

@KarelKenens
Copy link
Contributor

Fixes#20090

@github-actions

This comment has been minimized.


def something() -> None: ...

type A = list[Annotated[str, something()]]
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can move this test totest-data/unit/check-python312.test:--python-version does not override syntax errors (so won't help here), and that file only runs on 3.12+

KarelKenens reacted with thumbs up emoji
@github-actions

This comment has been minimized.

Copy link
Collaborator

@A5rocksA5rocks left a comment

Choose a reason for hiding this comment

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

This code change makes sense to me though it's a bit surprising that it fixes a bug!

returnexpr_to_unanalyzed_type(args[0],options,allow_new_syntax,expr)
base.args=tuple(
expr_to_unanalyzed_type(arg,options,allow_new_syntax,expr,allow_unpack=True)
expr_to_unanalyzed_type(
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's other recursion happening here, do you think it's a good idea to preemptively thread throughlookup_qualified?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Not going to pretend I have a good understanding of the consequences. But I can trigger what is basically the same behaviour by nesting annotations. And to me it seems that the cause is indeed thatlookup_qualified is not being passed on in the recursions.
This test passes.

[casetestAnnotatedWithCallableAsParameterTypeAliasDeeper]fromtyping_extensionsimportAnnotated,TypeAliasdefsomething()->None: ...A:TypeAlias=list[Annotated[Annotated[str,something()],something()]]a:Areveal_type(a)# N: Revealed type is "builtins.list[builtins.str]"[builtinsfixtures/tuple.pyi]

This one does not (even after changes currently in this PR).

[casetestAnnotatedWithCallableAsParameterTypeKeywordDeeper]fromtyping_extensionsimportAnnotateddefsomething()->None: ...typeA=list[Annotated[Annotated[str,something()],something()]]a:Areveal_type(a)# N: Revealed type is "builtins.list[builtins.str]"[builtinsfixtures/tuple.pyi]

Can make the second one pass by pushinglookup_qualified through to another recursive call.

Copy link
Collaborator

@A5rocksA5rocksOct 22, 2025
edited
Loading

Choose a reason for hiding this comment

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

Maybe check blame to quickly look at the PR that introduced things (maybe it addresses this), but it sounds like it would be good to passlookup_qualified through.

I suspect:

  1. the recursive calls were added before thelookup_qualified
  2. thelookup_qualified PR was part of a larger PR so this got missed

Unfortunately I'm on mobile so blame UI kinda sucks :(

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

PR that addedlookup_qualified doesn't address passing through the argument.
But as you said, the recursion was there already. An oversight sound plausible to me.
@A5rocks , should I add the passing through to this PR?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, please do.@JukkaL

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah this looks like an oversight.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

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.

Yes,lookup_qualified should almost certainly be passed everywhere, looks like a simple omission.

@github-actions
Copy link
Contributor

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

@JukkaLJukkaL merged commit8e2ce96 intopython:masterNov 13, 2025
21 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@JukkaLJukkaLJukkaL left review comments

+2 more reviewers

@A5rocksA5rocksA5rocks approved these changes

@sterliakovsterliakovsterliakov approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Error inconsistent betweentype keyword andTypeAlias

4 participants

@KarelKenens@JukkaL@A5rocks@sterliakov

[8]ページ先頭

©2009-2025 Movatter.jp