Skip to content

quoted-annotation (UP037)#

Derived from the pyupgrade linter.

Fix is always available.

What it does#

Checks for the presence of unnecessary quotes in type annotations.

Why is this bad?#

In Python, type annotations can be quoted to avoid forward references. However, if from __future__ import annotations is present, Python will always evaluate type annotations in a deferred manner, making the quotes unnecessary.

Example#

from __future__ import annotations


def foo(bar: "Bar") -> "Bar":
    ...

Use instead:

from __future__ import annotations


def foo(bar: Bar) -> Bar:
    ...

References#