-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Improve misleading message in Enum() (#5317) #14590
Conversation
Clarifying this is a mypy limitation, not an Enum() requirement.
Looks good, you'll likely have to update some test cases. |
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 |
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 onto your |
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 from mypy_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]
|
Thank you! I do like having "literal" be after, since it avoids confusion with typing.LiteralString. |
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) |
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 it could. It might be unfeasible or too complex to implement, but conceptually it is not impossible. Or is it? |
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 :) |
|
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