Skip to content

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

Merged
merged 6 commits into from
May 27, 2017

Conversation

mistermocha
Copy link
Contributor

@mistermocha mistermocha commented May 24, 2017

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.

@@ -32,8 +32,9 @@ def unique(enumeration: _S) -> _S: ...
if sys.version_info >= (3, 6):
_auto_null = ... # type: Any

class auto:
class auto(IntFlag):
Copy link
Member

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.

Copy link
Contributor Author

@mistermocha mistermocha May 24, 2017

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()

Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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?)

Copy link

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

Copy link
Collaborator

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.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

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.

Copy link
Contributor Author

@mistermocha mistermocha left a 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants