Skip to content
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

Pyright doesn't recognize the __members__ attribute of enumeration class #759

Closed
MapleCCC opened this issue Jun 24, 2020 · 3 comments
Closed
Labels
addressed in next version Issue is fixed and will appear in next published version enhancement request New feature or request

Comments

@MapleCCC
Copy link

Describe the bug
According to Python official document (https://docs.python.org/3.8/library/enum.html#iteration), there is an attribute __members__ of every enumeration class that provides all names defined in the enumeration class. Since it appears in the official document, we should consider it a public API. But Pyright doesn't seem to recognize the __members__ attribute, as elaborated in the following screenshot.

To Reproduce

from enum import Enum

class Fruit(Enum):
    apple = 1
    orange = 2
    pear = 3

print(Fruit.__members__)

Expected behavior
Pyright should be able to recoginize __members__ as a mapping.

Screenshots or Code
image
image

VS Code extension or command-line
Pyright is run as VS Code extension.
Extension version 1.1.44

@jakebailey
Copy link
Member

Typeshed's definition of enum includes it in the metaclass: https://github.com/python/typeshed/blob/master/stdlib/3/enum.pyi

@erictraut erictraut added the enhancement request New feature or request label Jun 25, 2020
@erictraut
Copy link
Collaborator

Thanks for the bug report. This will be fixed in the next published version of Pyright.

@erictraut erictraut added the addressed in next version Issue is fixed and will appear in next published version label Jun 27, 2020
@erictraut
Copy link
Collaborator

This is now fixed in Pyright version 1.1.48, which I just published. It will also be included in the next public release of Pylance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addressed in next version Issue is fixed and will appear in next published version enhancement request New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants