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

unreachable idiom doesn't work on match of function call expression #17075

Closed
tamird opened this issue Mar 29, 2024 · 1 comment
Closed

unreachable idiom doesn't work on match of function call expression #17075

tamird opened this issue Mar 29, 2024 · 1 comment
Labels
bug mypy got something wrong

Comments

@tamird
Copy link
Contributor

tamird commented Mar 29, 2024

playground

from typing import assert_never

def returns_union() -> int | float | None:
    return None
    
def broken() -> None:
    match returns_union():
        case None:
            pass
        case int():
            pass
        case float():
            pass
        case never:
            assert_never(never) # error: Argument 1 to "assert_never" has incompatible type "int | float | None"; expected "NoReturn"  [arg-type]
            
def not_broken() -> None:
    match _ := returns_union(): # assignment to unused variable fixes the problem
        case None:
            pass
        case int():
            pass
        case float():
            pass
        case never:
            assert_never(never)
@tamird tamird added the bug mypy got something wrong label Mar 29, 2024
@tamird
Copy link
Contributor Author

tamird commented Mar 29, 2024

Oops, duplicate of #12998, fixed on master.

@tamird tamird closed this as completed Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

1 participant