-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
KarelKenens
wants to merge
7
commits into
python:master
Choose a base branch
from
KarelKenens:fix-annotated-with-function-as-type-keyword-list-parameter
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c7f95a4
fix: add lookup_qualified
KarelKenens b47d21e
test: type keyword would fail before fix
KarelKenens e3a9a3d
Merge branch 'master' into fix-annotated-with-function-as-type-keywor…
KarelKenens 777e4c3
test: restructure to run with correct python version
KarelKenens 8136e70
Merge branch 'master' into fix-annotated-with-function-as-type-keywor…
KarelKenens 0bd6bb5
fix: pass through argument to all recursive calls
KarelKenens 9ad2101
test: deeper nested annotated
KarelKenens File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1318,3 +1318,25 @@ from typing_extensions import TypeAlias | |
|
||
Foo: TypeAlias = ClassVar[int] # E: ClassVar[...] can't be used inside a type alias | ||
[builtins fixtures/tuple.pyi] | ||
|
||
[case testAnnotatedWithCallableAsParameterTypeKeyword] | ||
# flags: --python-version 3.12 | ||
from typing_extensions import Annotated | ||
|
||
def something() -> None: ... | ||
|
||
type A = list[Annotated[str, something()]] | ||
|
||
a: A | ||
reveal_type(a) # N: Revealed type is "builtins.list[builtins.str]" | ||
[builtins fixtures/tuple.pyi] | ||
|
||
[case testAnnotatedWithCallableAsParameterTypeAlias] | ||
# flags: --python-version 3.12 | ||
from typing_extensions import Annotated, TypeAlias | ||
|
||
def something() -> None: ... | ||
|
||
B: TypeAlias = list[Annotated[str, something()]] | ||
b: B | ||
reveal_type(b) # N: Revealed type is "builtins.list[builtins.str]" | ||
[builtins fixtures/tuple.pyi] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 through
lookup_qualified
?There was a problem hiding this comment.
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 that
lookup_qualified
is not being passed on in the recursions.This test passes.
This one does not (even after changes currently in this PR).
Can make the second one pass by pushing
lookup_qualified
through to another recursive call.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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 pass
lookup_qualified
through.I suspect:
lookup_qualified
lookup_qualified
PR was part of a larger PR so this got missedUnfortunately I'm on mobile so blame UI kinda sucks :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR that added
lookup_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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, please do. @JukkaL