Skip to content

invalid-syntax

Pythoncorrectnessno fixdefault: error

Reports code that Python rejects when it compiles the file although the grammar allows it, such as a duplicate parameter, nonlocal at module level or await in a function that is not async.

Python raises a SyntaxError for the file, so none of the code in it runs, and the error shows up only when the module is imported or compiled.

To fix, follow the message and correct the statement.

Reported
...
await x
def f():
...
python:
lint:
rules:
invalid-syntax: error # off, warn, error (default)

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