-
-
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
Mypy doesn't recognize metaclass implementing __getitem__ #1771
Comments
Oh, it looks like this already exists in the tracker: #741. I'll have to close this as a duplicate. |
Sorry to dig this up after years, but it seems the issue was never really resolved besides printing the correct type in I spent quite some time struggling to get custom generics to work in mypy, because this issue and the associated PR made me believe the feature is implemented. |
Suppose we have an
Enum
calledMyEnum
, and we try something likeMyEnum["foo"]
, mypy will give us an errorValue of type "MyEnum" is not indexable
. We believe this is because mypy has trouble recognizing when a metaclass implements__getitem__
.A workaround is to do
getattr(MyEnum, "foo")
, but it'd be nice to have an actual fix.The text was updated successfully, but these errors were encountered: