invalid-print-syntax
What it does
Section titled “What it does”Reports print >> file, ..., the Python 2 form that writes to a file.
Why it matters
Section titled “Why it matters”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).
Example
Section titled “Example”... pass except ValueError: pass print >> sys.stderr, "x"
...Configuration
Section titled “Configuration”python: lint: rules: invalid-print-syntax: warn # off, warn (default), errorEnabled by the presets: python/ruff.
Suppress one line with sudsy-disable-next-line invalid-print-syntax in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| ruff | F633 |
full |