FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Update ast for 3.12 by JelleZijlstra · Pull Request #10201 · python/typeshed · GitHub

Update ast for 3.12 - #10201

Merged
JelleZijlstra merged 5 commits into
python:mainfrom
JelleZijlstra:ast312
Jun 3, 2023
Merged

Update ast for 3.12#10201
JelleZijlstra merged 5 commits into
python:mainfrom
JelleZijlstra:ast312

Conversation

Copy link
Copy Markdown
Member

Split out from #10200 since this part appears to cause some pytype failures.

This comment has been minimized.

Comment thread stdlib/ast.pyi
# is also allowed in some cases -- this needs to be mapped.

_T = TypeVar("_T", bound=AST)
_T = _TypeVar("_T", bound=AST)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.)

Comment thread stdlib/_ast.pyi Outdated

Copy link
Copy Markdown
Collaborator

As @JelleZijlstra suggested, the issue is probably that pytype doesn't recognize _TypeVar as TypeVar - there are some typing constructs that we match by name. Let me see if there's anything I can do about it.

Copy link
Copy Markdown
Member Author

Alex suggested that, not me :)

Thanks! I can try switching to typing.TypeVar for now.

Copy link
Copy Markdown
Collaborator

I have a fix for the pytype issue out for review. With any luck, I'll get it into this week's release.

rchen152 added a commit to google/pytype that referenced this pull request May 24, 2023
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

Copy link
Copy Markdown
Collaborator

I think pytype should be happy with from typing import TypeVar as _TypeVar with today's release (2023.5.24). Could you give it a try?

Copy link
Copy Markdown
Collaborator

Oh drat, it still seems broken =/ I'll look into it tomorrow.

JelleZijlstra commented May 25, 2023
edited
Loading

Copy link
Copy Markdown
Member Author

Thanks! No hurry, we'll want to wait anyway until python/cpython#104799 gets resolved and I can always try the typing.TypeVar workaround.

This comment has been minimized.

Copy link
Copy Markdown
Collaborator

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.

AlexWaygood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Needs to be updated now that python/cpython#104974 is merged ;)

rchen152 added a commit to google/pytype that referenced this pull request May 31, 2023
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.

AlexWaygood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Looks good!

rchen152 commented Jun 2, 2023

Copy link
Copy Markdown
Collaborator

The pytype failure should actually be fixed now, in version 2023.6.2.

github-actions Bot commented Jun 3, 2023

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

JelleZijlstra merged commit 628c88d into python:main Jun 3, 2023
JelleZijlstra deleted the ast312 branch June 3, 2023 00:11

Copy link
Copy Markdown
Member Author

Thanks @rchen152!

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
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.

3 participants


Back | FazBrowse Home | New Git URL