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

Enums, bools, and tuples are not expanded during overload evaluation #9706

Open
InSyncWithFoo opened this issue Jan 14, 2025 · 2 comments
Open
Labels
bug Something isn't working spec compliance

Comments

@InSyncWithFoo
Copy link
Contributor

Minimal reproducible example (playground):

class E(Enum):
    A = 'A'
    B = 'B'


@overload
def f(v: Literal[E.A]) -> int: ...
@overload
def f(v: Literal[E.B]) -> str: ...

def f(v: E) -> int | str: ...
a1: E = ...
a2: Literal[E.A, E.B] = ...

reveal_type(f(a1))  # error: No matching overload
reveal_type(f(a2))  # int | str

The proposed overload chapter says that a non-Flag enum should be expanded into the union of its members during overload evaluation.

@InSyncWithFoo InSyncWithFoo added the bug Something isn't working label Jan 14, 2025
@erictraut
Copy link
Collaborator

No need to file bugs against individual parts of the draft proposal. There are many changes that will need to be made to conform to the proposal — both in pyright and mypy — once it has been accepted. I'll get to it in time. Closing this for now.

@erictraut
Copy link
Collaborator

Reopening this issue now that conformance tests have been written for the new chapter.

@erictraut erictraut changed the title Enums are not expanded during overload evaluation Enums, bools, and tuples are not expanded during overload evaluation Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working spec compliance
Projects
None yet
Development

No branches or pull requests

2 participants