-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Cannot use Literal variable inside Literal type #8187
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
Well, I find #3494 maybe related to this |
Essentially yes, variables and type aliases should be never mixed. If you want an alias, use |
@ilevkivskyi indeed and I misunderstand this, too. However, I found a Lines 425 to 427 in fe8309a
which I think it would be useful to add a note here to point to the docs to help the anyone encounters this error message in the future
Furthermore, I check the docs in both |
Yes, but fixing this TODO depends on fixing #3494 first. |
Resolves #3494 (Since module types are tracked in #3500) Following #8187 (comment) and #3494, if I understand correctly and the semantics in #3494's example code has been fixed (report error on re-assign Alias = B, the remaining work of #3494 is to update the docs, which is the main focus of this PR. Newly added docs are in common issues and solutions section, with the content mostly adapted from Ivan's example in #3494. And a note point to the docs is also added.
Using mypy 0.761, Python 3.7.5 here. The
ANIMALS2
value is highlighted as incorrect by Mypy:But it seems Mypy should be able to deduce that ANIMALS1 and ANIMALS2 are the same thing?
I'm not sure if the more lax version should be allowed as well, but seems useful:
The text was updated successfully, but these errors were encountered: