-
-
Notifications
You must be signed in to change notification settings - Fork 2.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
type
class cannot be used as a generic
#11424
Comments
type
object cannot be used as a generictype
class cannot be used as a generic
Oh, interesting. The following do work on master:
Clearly a bug, curious if you have a more complex example that fails on master as well? |
Hmm, this is weird: $ python -m mypy --version
mypy 0.920+dev.0ec868fe778c57b52f6df54f54eb19616e1d6ba2
$ python -m mypy -c 'type[int]' --python-version 3.9
<string>:1: error: Value of type "Type[type]" is not indexable
Found 1 error in 1 file (checked 1 source file)
$ python -m mypy -c 'foo: type[int]' --python-version 3.9
Success: no issues found in 1 source file
$ python -m mypy -c 'reveal_type(type[int]); foo: type[int]; reveal_type(foo)' --python-version 3.9
<string>:1: error: Value of type "Type[type]" is not indexable
<string>:1: note: Revealed type is "Any"
<string>:1: note: Revealed type is "Type[builtins.int]"
Found 1 error in 1 file (checked 1 source file) I also can't seem to reproduce the issue I was having, which was using something like |
No longer reproducible on 0.942 |
I can still reproduce this:
And it also reproduces for me on 0.942. It might be a duplicate of #12392 though. |
Thanks, you're right -- not sure why I closed this. As you say, though, there's heavy overlap with #12392, which has more practical use cases in it. So I don't think there's a need to reopen, personally. |
I can still reproduce the issue even after the #12392 fix: it seems that def f() -> type:
a: type[int] # fine
A = type[int] # fine
return type[int] # error: Value of type "type[type]" is not indexable [index] I'm using mypy 1.4.0 on Python 3.10.6. Could this issue be re-opened? |
This is basically covered by #13026 I think |
Agreed, no need to re-open then. |
(moved from python/typeshed#6218)
It seems as of python 3.9,
type[...]
has a special case for returningGenericAlias
while not having a__class_getitem__
, this causes issues when using it in favour oftyping.Type
:I stumbled upon this issue with
python 3.9.7
/mypy 0.910
but it is still there as ofmypy 0.920+dev.8b9ade2
The text was updated successfully, but these errors were encountered: