Skip to content

Enum.__members__ not recognized #1590

Closed
@FichteFoll

Description

@FichteFoll

Despite the update in #1195, I still get an error when accessing an Enum's __members__ attribute 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'>)])

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions