Skip to content

no-return-argument-annotation-in-stub (PYI050)#

Derived from the flake8-pyi linter.

What it does#

Checks for uses of typing.NoReturn (and typing_extensions.NoReturn) in stubs.

Why is this bad?#

Prefer typing.Never (or typing_extensions.Never) over typing.NoReturn, as the former is more explicit about the intent of the annotation. This is a purely stylistic choice, as the two are semantically equivalent.

Example#

from typing import NoReturn


def foo(x: NoReturn): ...

Use instead:

from typing import Never


def foo(x: Never): ...

References#