Skip to content

Update enum for Python 3.6 #854

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

Closed
brettcannon opened this issue Jan 20, 2017 · 5 comments
Closed

Update enum for Python 3.6 #854

brettcannon opened this issue Jan 20, 2017 · 5 comments

Comments

@brettcannon
Copy link
Member

Bunch of changes to the enum module in Python 3.6. The type hints are also missing things that pre-date 3.6 like __members__. (The ability to iterate is covered by python/mypy/issues/2305.)

@JelleZijlstra
Copy link
Member

A bunch of new things were already added in bbc7594 and Guido seems to be working on the metaclass in bebb49a. I added some missing methods in 43c48cc and I can add any missing functionality on the metaclass once Guido's commit lands.

JelleZijlstra added a commit to JelleZijlstra/typeshed that referenced this issue Apr 22, 2017
Fixes python#854 (unless there's more I'm missing).
ambv pushed a commit that referenced this issue Apr 24, 2017
Fixes #854 (unless there's more I'm missing).
@FichteFoll
Copy link
Contributor

FichteFoll commented Sep 4, 2017

I still get this with mypy 0.521 and Python 3.6.2:

import enum


class NetworkEventName(str, enum.Enum):
    CONNECTED = "connected"
    DISCONNECTED = "disconnected"
    CLOSE_REQUEST = "close_request"
    MESSAGE = "message"
    RAW_LINE = "raw_line"


print(NetworkEventName.__members__)
> mypy /tmp/enum_test.py
/tmp/enum_test.py:12: error: Type[NetworkEventName] has no attribute "__members__"

> python /tmp/enum_test.py
OrderedDict([('CONNECTED', <NetworkEventName.CONNECTED: 'connected'>), ('DISCONNECTED', <NetworkEventName.DISCONNECTED: 'disconnected'>), ('CLOSE_REQUEST', <NetworkEventName.CLOSE_REQUEST: 'close_request'>), ('MESSAGE', <NetworkEventName.MESSAGE: 'message'>), ('RAW_LINE', <NetworkEventName.RAW_LINE: 'raw_line'>)])

@gvanrossum
Copy link
Member

gvanrossum commented Sep 4, 2017 via email

@gvanrossum
Copy link
Member

gvanrossum commented Sep 4, 2017 via email

@FichteFoll
Copy link
Contributor

FichteFoll commented Sep 6, 2017

Created as #1590. The __members__ property is defined, so I have no idea why it wouldn't work tbh.

@property
def __members__(self: Type[_T]) -> Mapping[str, _T]: ...

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

No branches or pull requests

5 participants