8000 [1.16 regression] failure to exhaustively narrow type var bounded by union (across files) · Issue #19159 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content
[1.16 regression] failure to exhaustively narrow type var bounded by union (across files) #19159
Open
@hauntsaninja

Description

@hauntsaninja

Courtesy of @delfick

So if we have two files

# a.py
from typing import assert_never

import b


def switch[T_Choice: b.One | b.Two](choice: type[T_Choice]) -> None:
    match choice:
        case b.One:
            print(1)
        case b.Two:
            print(2)
        case _:
            assert_never(choice)


switch(b.One)

and

# b.py
class One: ...
class Two: ...

Then I get no errors with mypy 1.15 and this error with 1.16

a.py:13: error: Argument 1 to "assert_never" has incompatible type "type[Two] | Never"; expected "Never"  [arg-type]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0