Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork3.1k
Improve misleading message in Enum() (#5317)#14590
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Clarifying this is a mypy limitation, not an Enum() requirement.
JelleZijlstra commentedFeb 2, 2023
Looks good, you'll likely have to update some test cases. |
MestreLion commentedFeb 2, 2023
I was already doing so, took a bit longer than expected, was side-tracked when I realized I forked from a fork instead of the original repo. And it seems Github does not allow changing source repo. Oh my... will fix that after (and if) this gets merged |
MestreLion commentedFeb 2, 2023
If merged, will this be a rebase or a plain merge? Given my fork was based on an outdated fork by mistake, a plain merge will create an "arc" of ~3700 commits, which I admit looks awful in repository tree views. If this is undesirable, just say the word and I'll promptly re-create my fork and rebase my branch ontoyour |
JelleZijlstra commentedFeb 2, 2023
MestreLion commentedFeb 2, 2023
Phew, great! Glad my silly mistake will not taint my first contribution here :) Would be a shame if the parent commit was some random commit of years ago.
🥇 👍 :-) |
Diff frommypy_primer, showing the effect of this PR on open source code: prefect (https://github.com/PrefectHQ/prefect)- src/prefect/cli/deployment.py:667: error: Enum() expects a string, tuple, list or dict literal as the second argument [misc]+ src/prefect/cli/deployment.py:667: error: Non-literal string, tuple, list or dict as the second argument of Enum() is not supported [misc] |
hauntsaninja commentedFeb 2, 2023
Thank you! I do like having "literal" be after, since it avoids confusion with typing.LiteralString. |
hauntsaninja commentedFeb 2, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
What about "Second argument of Enum() must be string, tuple, list or dict literal for mypy to determine Enum members" (I think this also helps clarify that it isn't a thing that mypy could support) |
MestreLion commentedFeb 2, 2023
Looks nice too. I initially chose "is not supported" idiom just to follow suit with similar error messages (which I believe also mean that this is on mypy's side, not Enum's)
Well... theoretically itcould. It might be unfeasible or too complex to implement, but conceptually it is not impossible. Or is it? |
AlexWaygood commentedFeb 2, 2023
It could be supported in the sense of "if you rewrote mypy from the ground up and made it a runtime type checker as well as a static type checker, it could be supported". But that's not realistically going to happen, and it's stretching the meaning of the word "could" a bit far :) |
hauntsaninja commentedFeb 2, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
|
hauntsaninja commentedFeb 2, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Oh weird, I may have merged prematurely, seems like that didn't trigger Github Actions checks for some reason. But thank you for the improvement! |

Clarifying this is a mypy limitation, not an Enum() requirement.
Not a true fix, but a workaround for#5317 to avoid confusion (as seen by the many duplicates
Just clarifying a somewhat misleading error message