| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| # 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.
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.)
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
|
Alex suggested that, not me :) Thanks! I can try switching to typing.TypeVar for now. |
Sorry, something went wrong.
|
I have a fix for the pytype issue out for review. With any luck, I'll get it into this week's release. |
Sorry, something went wrong.
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 from typing import TypeVar as _TypeVar with today's release (2023.5.24). Could you give it a try? |
Sorry, something went wrong.
|
Oh drat, it still seems broken =/ I'll look into it tomorrow. |
Sorry, something went wrong.
|
Thanks! No hurry, we'll want to wait anyway until python/cpython#104799 gets resolved and I can always try the typing.TypeVar workaround. |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
There was a problem hiding this comment.
Needs to be updated now that python/cpython#104974 is merged ;)
Sorry, something went wrong.
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
There was a problem hiding this comment.
Looks good!
Sorry, something went wrong.
|
The pytype failure should actually be fixed now, in version 2023.6.2. |
Sorry, something went wrong.
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Split out from #10200 since this part appears to cause some pytype failures.