-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Enum of a NamedTuple-derived type leads to incompatible type error #1745
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
Comments
I know we have plenty of namedtuple-related issues. But does this code serve a real purpose? Enum has a lot of magic, so does namedtuple -- I'm not sure if we should really be required to make sense of this, and what you're trying to accomplishing with that class. |
This is a distilled example of a real-life enum I came across in our code. Not going to get into whether or not having such an enum is a good idea, but we have it and I'm getting mypy errors trying to use it as an argument to a function. The main weirdness is that the error is of the form |
Note that without the Foo base class you can still access the bar attribute in f() -- use x.value.bar rather than x.bar. |
This came up again today -- a user hit an error message just as confusing (and with the same structure) as the one in @alexsydell's report, and after some debugging someone else recognized it as this issue. In addition to the type-checker issue that we shouldn't be reporting an error here at all, the error message is awfully perplexing and is likely an example of #1582. |
I believe that this is a result of the special casing of both
I think that this special casing is justified, but I'm not sure. |
This code:
leads to:
The text was updated successfully, but these errors were encountered: