Skip to content

function call that returns Never incorrectly marked as unreachable when function that's defined later with multiple argument decorator is called #13043

Closed
@DetachHead

Description

@DetachHead

sorry for the wacky title

from typing import TypeVar, Literal
from typing_extensions import assert_never

Fn = TypeVar("Fn")


def foo(fn: Fn, value: bool = False) -> Fn:
    ...


def bar(value: Literal[True]) -> None:
    if value:
        baz()
    else:
        assert_never(value) # error: Statement is unreachable  [unreachable]


@foo
def baz() -> None:
    ...

playground

functions that return Never are not supposed to be marked as unreachable - see #10916 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-reachabilityDetecting unreachable code

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions