-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Completing functionality for enum.auto #1331
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
Conversation
Full context: python/mypy#3441
stdlib/3.4/enum.pyi
Outdated
@@ -32,8 +32,9 @@ def unique(enumeration: _S) -> _S: ... | |||
if sys.version_info >= (3, 6): | |||
_auto_null = ... # type: Any | |||
|
|||
class auto: | |||
class auto(IntFlag): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment explaining why we're lying here? Maybe link to the mypy issue or PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enum.IntFlag
has all the right methods & properties to most closely match the behavior of anything returned by enum.auto()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add that in the code itself?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I hope a docstring is apporopriate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A comment is preferred. (Also, why is an __init__
needed?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As written in my comment, I don't think the comment is telling the truth but the inadvertent result of some misunderstanding. https://youtrack.jetbrains.com/issue/PY-53388/PyCharm-thinks-enumauto-needs-an-argument#focus=Comments-27-6301482.0-0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you think there are problems with how things are implemented, please open a new issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please open a typeshed issue if you want typeshed people to do something about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding comment explaining why auto
is subclassing IntFlag
in typeshed
Full context: python/mypy#3434
This diff is needed to properly exercise enum.auto when type-checking. Otherwise, enum.auto just renders out to Any().
The attached issue, along with the proposed changes here python/mypy#3441 would suggest a proper method for testing this precise feature.