Skip to content

NoReturn should be assignable to any type #2921

@erictraut

Description

@erictraut

Discussed in #2920

Originally posted by JelleZijlstra January 22, 2022
I was exploring pyright's treatment of NoReturn (in preparation for adding and documenting typing.Never) and noticed that pyright allows passing NoReturn to parameters of type object. For example, this typechecks:

def f(x: NoReturn):
    repr(x)  # repr() takes object

Is this an intentional behavior? It's not what I expected on first principles but it seems useful in practice.

Metadata

Metadata

Assignees

No one assigned

    Labels

    addressed in next versionIssue is fixed and will appear in next published versionbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions