You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@rchen152@mrkmndz Do pytype/pyre support PEP 585? If not, would you mind me creating a ticket in the respective projects that we can reference from here?
src/pep585.py:8:0 Revealed type [-1]: Revealed type for `list1` is `List[str]`.
src/pep585.py:9:0 Revealed type [-1]: Revealed type for `list2` is `List[str]`.
🎉 This means all type checkers now support this feature and we can start using it in typeshed. 🎉
We should require future PRs to use built-in generics. I am personally in favor of a "big bang" PR after the reshuffling is done. Currently is a good time, since we have nearly no open PRs that could cause conflicts. But I am curious what the other maintainers think.
I believe mypy actually does not yet support this in type aliases, only lists (x = list[int] doesn't work yet in mypy).
@Hultner this syntax should work in stubs even when it doesn't work at runtime yet. We should confirm that the type checkers actually allow this syntax in stubs when targeting older versions though.
@srittau do you have some opened issue to link me to? I can probably help with this one 🙂
Btw, this works for me on mypy@master:
deffunc(a: type[int]):
reveal_type(a) # N: Revealed type is "Type[builtins.int]"func(int) # okfunc(str) # E: Argument 1 to "func" has incompatible type "Type[str]"; expected "Type[int]"
Can you create mypy issues about any remaining issues and cc me? We can make a mypy point release with the fixes once everything works correctly (there should be no need to wait for a full release).
Activity
srittau commentedon Jan 6, 2021
@rchen152 @mrkmndz Do pytype/pyre support PEP 585? If not, would you mind me creating a ticket in the respective projects that we can reference from here?
sproshev commentedon Jan 6, 2021
Supported by PyCharm since 2020.2 https://youtrack.jetbrains.com/issue/PY-42418
rchen152 commentedon Jan 7, 2021
Internally, pytype has actually never distinguished between builtins.list and typing.List, etc. So we should already support this one.
srittau commentedon Jan 25, 2021
Test case:
pyre returns:
🎉 This means all type checkers now support this feature and we can start using it in typeshed. 🎉
Akuli commentedon Jan 25, 2021
Are we going to have a huge pull request to change
Listtolist? Or is this not important enough for a huge pull request?srittau commentedon Jan 25, 2021
We should require future PRs to use built-in generics. I am personally in favor of a "big bang" PR after the reshuffling is done. Currently is a good time, since we have nearly no open PRs that could cause conflicts. But I am curious what the other maintainers think.
Hultner commentedon Jan 25, 2021
How would that turn out for people still using python 3.7 or 3.8? Or should they just pin an older typeshed version?
JelleZijlstra commentedon Jan 25, 2021
I believe mypy actually does not yet support this in type aliases, only lists (
x = list[int]doesn't work yet in mypy).@Hultner this syntax should work in stubs even when it doesn't work at runtime yet. We should confirm that the type checkers actually allow this syntax in stubs when targeting older versions though.
srittau commentedon Feb 1, 2021
@JelleZijlstra A quick test seems to work:
Correctly reveals
strfor bothalias2andalias4. Bothalias1andalias2don't work, though.srittau commentedon Feb 23, 2021
Reopening because of python/mypy#9980.
Recommend to use PEP 585
Recommend using PEP 585 (#5055)
srittau commentedon Apr 9, 2021
The following does not work with mypy:
...(Unexpected '...' for homogeneous tuples using builtin tuple (PEP 585) mypy#9980)type(type not generic when running with Python < 3.9 mypy#10303)srittau commentedon Jun 28, 2021
Base classes don't work either. python/mypy#10731
JukkaL commentedon Jul 15, 2021
Mypy should be fixed on GitHub master. The fixes haven't been released yet, though.
JelleZijlstra commentedon Dec 22, 2021
With the latest mypy release this should be mostly fixed, but as I recall there's still a few issues.
AlexWaygood commentedon Dec 22, 2021
I am working on a PR for this.
srittau commentedon Dec 22, 2021
Generic
typedidn't work yet when I tried to use it. Tuples and base classes are fixed.sobolevn commentedon Dec 22, 2021
@srittau do you have some opened issue to link me to? I can probably help with this one 🙂
Btw, this works for me on
mypy@master:srittau commentedon Dec 22, 2021
At least the following still fails with mypy 0.920. I didn't test mypy master:
srittau commentedon Dec 22, 2021
And here are a bunch of further errors: https://github.com/python/typeshed/runs/4604434037?check_suite_focus=true
#4820 for experiments.
JukkaL commentedon Dec 22, 2021
Can you create mypy issues about any remaining issues and cc me? We can make a mypy point release with the fixes once everything works correctly (there should be no need to wait for a full release).
srittau commentedon Dec 22, 2021
python/mypy#10303 seems to be still problematic, but the errors from #4820 are gone with mypy 0.930. 🥳
AlexWaygood commentedon Dec 28, 2021
Many pytype errors were output by the CI when I tried to use imports from
collections.abceverywhere 😕https://github.com/python/typeshed/runs/4629393978?check_suite_focus=trueAlexWaygood commentedon Dec 29, 2021
I have opened google/pytype#1096 for the pytype errors.
srittau commentedon Feb 2, 2022
As of mypy 0.931 this is now fully supported.