Skip to content

forward-annotation-syntax-error

Pythoncorrectnessno fixdefault: warn

Reports a quoted annotation whose text is not an expression.

Type checkers and typing.get_type_hints parse the string as an expression. A string that is not one fails there, though Python itself never looks at it when the code runs, so the mistake hides until a tool evaluates the annotation.

To fix, correct the text of the annotation.

Reported
...
def annotations(a: "Missing", b: "bad syntax here"):
x: int
...
...
python:
lint:
rules:
forward-annotation-syntax-error: warn # off, warn (default), error

Suppress one line with sudsy-disable-next-line forward-annotation-syntax-error in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
ruff F722 full