8000 `type` stub is missing `__class_getitem__` · Issue #6218 · python/typeshed · GitHub
[go: up one dir, main page]

Skip to content

type stub is missing __class_getitem__ #6218

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

Closed
ghost opened this issue Nov 1, 2021 · 3 comments
Closed

type stub is missing __class_getitem__ #6218

ghost opened this issue Nov 1, 2021 · 3 comments

Comments

@ghost
Copy link
ghost commented Nov 1, 2021

At least as of python 3.9, type[int] returns a GenericAlias, but this does not seem to be implemented on builtins.pyi or at least with mypy specifically:

$ mypy -c 'type[int]'
<string>:1: error: Value of type "Type[type]" is not indexable

(p.s. I am not entirely sure if this is with mypy or typeshed, correct me if I'm wrong!)

@ghost
Copy link
Author
ghost commented Nov 1, 2021

if I understood correctly, this should be a simple fix, right? on class type(object): add:

    if sys.version_info >= (3, 9):
        def __class_getitem__(cls, item: Any) -> GenericAlias: ...

@JelleZijlstra
Copy link
Member

We recently discussed this in #6205. type does not in fact implement __class_getitem__.

@ghost
Copy link
Author
ghost commented Nov 1, 2021

oh, I totally missed that! should this be moved to mypy's repo then?

This issue was closed.
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

No branches or pull requests

1 participant
0