Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
hauntsaninja merged 3 commits intopython:masterfromMestreLion:patch-1
Feb 2, 2023
Merged

Improve misleading message in Enum() (#5317)#14590

hauntsaninja merged 3 commits intopython:masterfromMestreLion:patch-1
Feb 2, 2023

Conversation

@MestreLion
Copy link
Contributor

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

Clarifying this is a mypy limitation, not an Enum() requirement.
@JelleZijlstra
Copy link
Member

Looks good, you'll likely have to update some test cases.

@JelleZijlstraJelleZijlstra self-assigned thisFeb 2, 2023
@MestreLion
Copy link
ContributorAuthor

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

@MestreLion
Copy link
ContributorAuthor

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 ontoyourmaster

@JelleZijlstra
Copy link
Member

We'll squash merge. I couldn't even create a merge commit if I wanted to :)

Screen Shot 2023-02-02 at 11 59 10 AM

I'm planning to merge once CI passes. Thanks for your contribution!

@MestreLion
Copy link
ContributorAuthor

We'll squash merge. I couldn't even create a merge commit if I wanted to :)

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.

I'm planning to merge once CI passes. Thanks for your contribution!

🥇 👍 :-)

@github-actions
Copy link
Contributor

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
Copy link
Collaborator

Thank you! I do like having "literal" be after, since it avoids confusion with typing.LiteralString.

@hauntsaninja
Copy link
Collaborator

hauntsaninja commentedFeb 2, 2023
edited
Loading

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
Copy link
ContributorAuthor

What about "Second argument of Enum() must be string, tuple, list or dict literal for mypy to determine Enum members"

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)

(I think this also helps clarify that it isn't a thing that mypy could support)

Well... theoretically itcould. It might be unfeasible or too complex to implement, but conceptually it is not impossible. Or is it?

@AlexWaygood
Copy link
Member

Well... theoretically itcould. 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 :)

@hauntsaninja
Copy link
Collaborator

hauntsaninja commentedFeb 2, 2023
edited
Loading

Enum("name", open("https://adsf").split()),Enum("name", x if solve_halting_problem(program) else y), nope!

AlexWaygood and MestreLion reacted with laugh emoji

@hauntsaninjahauntsaninja merged commit50717cf intopython:masterFeb 2, 2023
@hauntsaninja
Copy link
Collaborator

hauntsaninja commentedFeb 2, 2023
edited
Loading

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!

@MestreLionMestreLion deleted the patch-1 branchFebruary 3, 2023 01:58
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@JelleZijlstraJelleZijlstraJelleZijlstra approved these changes

@hauntsaninjahauntsaninjahauntsaninja approved these changes

Assignees

@JelleZijlstraJelleZijlstra

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@MestreLion@JelleZijlstra@hauntsaninja@AlexWaygood

[8]ページ先頭

©2009-2025 Movatter.jp