Skip to content

Regression with default match pattern for Never type on 1.1.296 #4706

Closed
@bellini666

Description

@bellini666

Take this simple example with reportUnnecessaryComparison set to warning

from typing import assert_never

def get_foo() -> int | str:
    ...

foo = get_foo()

match foo:
    case int():
        ...
    case str():
        ...
    case _:  # Pattern will never be matched for subject type "Never" (reportUnnecessaryComparison)
        assert_never(foo)

This was working fine on previous versions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    as designedNot a bug, working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions