print >> file is written as in Python 2

tx0/python:print-redirectdefaultwarningbug

What it finds

print >> sys.stderr, "failed": Python 2's way to print to a file. In Python 3, print is a function, and this shifts the function right by the file, which raises TypeError. print("failed", file=sys.stderr) is the Python 3 form.

From the rule's source, print_redirect.rs.

Example from the rule's tests
import sys  def report(message):    print >> sys.stderr, messagetx0 reports: print >> file is Python 2; in Python 3 it raises TypeError    print >>sys.stderrtx0 reports: print >> file is Python 2    print(message, file=sys.stderr)
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:

tx0.toml
[rules]
"tx0/python:print-redirect" = "off"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

# tx0: ignore[tx0/python:print-redirect] reason="..."

tx0 explain tx0/python:print-redirect shows the same in the terminal. Found a false positive? Report it.