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

Description

@DetachHead

sorry for the wacky title

fromtypingimportTypeVar, Literalfromtyping_extensionsimportassert_neverFn=TypeVar("Fn")
deffoo(fn: Fn, value: bool=False) ->Fn:
...
defbar(value: Literal[True]) ->None:
ifvalue:
baz()
else:
assert_never(value) # error: Statement is unreachable [unreachable]@foodefbaz() ->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