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

The value of enums shoulde be inferred if possible #1624

Closed
saryou opened this issue Mar 12, 2021 · 2 comments
Closed

The value of enums shoulde be inferred if possible #1624

saryou opened this issue Mar 12, 2021 · 2 comments
Labels
addressed in next version Issue is fixed and will appear in next published version enhancement request New feature or request

Comments

@saryou
Copy link

saryou commented Mar 12, 2021

Is your feature request related to a problem? Please describe.

I know that enum's value is defined as Any in enum.pyi but it is better if the value type inferred precisely. Also mypy already complains that following code has an error.

from enum import Enum


class MyEnum(Enum):
    a = 1


def take_str(s: str):
    print(s)


def take_int(s: int):
    print(s)


take_str(MyEnum.a.value)
take_int(MyEnum.a.value)

Describe the solution you'd like

I don't understand the details but I think this is the mypy's implementation:

python/mypy#6867

@erictraut erictraut added the enhancement request New feature or request label Mar 12, 2021
@erictraut
Copy link
Collaborator

Thanks for the suggestion. This support will be included in the next release of pyright.

@erictraut erictraut added the addressed in next version Issue is fixed and will appear in next published version label Mar 13, 2021
@erictraut
Copy link
Collaborator

This is addressed in pyright 1.1.121, which I just published. It will also be included in the next release of pylance.

heejaechang pushed a commit to heejaechang/pyright that referenced this issue Nov 3, 2021
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

2 participants