Skip to content

invalid-print-syntax

Pythoncorrectnessno fixdefault: warnpython/ruff

Reports print >> file, ..., the Python 2 form that writes to a file.

In Python 3 print >> file, x is an expression that shifts the function print right by file, which fails with a TypeError when it runs, and the text is never written.

To fix, call print(..., file=file).

Reported
...
pass
except ValueError:
pass
print >> sys.stderr, "x"
...
python:
lint:
rules:
invalid-print-syntax: warn # off, warn (default), error

Enabled by the presets: python/ruff.

Suppress one line with sudsy-disable-next-line invalid-print-syntax 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 F633 full