-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Update ast for 3.12 #10201
Update ast for 3.12 #10201
Conversation
This comment has been minimized.
This comment has been minimized.
@@ -168,7 +168,7 @@ class NodeTransformer(NodeVisitor): | |||
# The usual return type is AST | None, but Iterable[AST] | |||
# is also allowed in some cases -- this needs to be mapped. | |||
|
|||
_T = TypeVar("_T", bound=AST) | |||
_T = _TypeVar("_T", bound=AST) |
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.
Does pytype like it any more if we do _T = typing.TypeVar("_T")
? (FWIW that would also be friendlier to flake8-pyi, which will recognise typing.TypeVar("_T")
as a TypeVar declaration, but won't recognise _TypeVar("_T")
as a TypeVar declaration.)
As @JelleZijlstra suggested, the issue is probably that pytype doesn't recognize |
Alex suggested that, not me :) Thanks! I can try switching to |
I have a fix for the pytype issue out for review. With any luck, I'll get it into this week's release. |
Adds support for aliasing names like TypeVar and simplifies name matching by requiring the caller to pass in only one variant of a name (e.g., "typing.Callable") and having the matcher automatically try all variants ("Callable", "typing.Callable", "collections.abc.Callable"). See python/typeshed#10201 for motivation. Fixes #1430. PiperOrigin-RevId: 534721075
I think pytype should be happy with |
Oh drat, it still seems broken =/ I'll look into it tomorrow. |
Thanks! No hurry, we'll want to wait anyway until python/cpython#104799 gets resolved and I can always try the |
This comment has been minimized.
This comment has been minimized.
Ok, should actually be fixed now XD And I made sure to run pytype_test locally this time to check that the fix works. Will be in next week's pytype release. |
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.
Needs to be updated now that python/cpython#104974 is merged ;)
I previously fixed the pyi parser's handling of `from typing import TypeVar as _TypeVar`, but I neglected to check that the parsed ast could then be successfully resolved by load_pytd. Context: python/typeshed#10201. PiperOrigin-RevId: 535500076
This comment has been minimized.
This comment has been minimized.
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.
Looks good!
The pytype failure should actually be fixed now, in version 2023.6.2. |
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Thanks @rchen152! |
Split out from #10200 since this part appears to cause some pytype failures.