subprocess.run is called without check, so a failing command goes unnoticed

tx0/python:subprocess-run-uncheckedstrictnotebug

What it finds

subprocess.run returns the exit status of the command and raises nothing when it fails, unless check=True is given. Without it a failed command is easy to miss; writing check=False says that the status is handled by hand. Reported are calls of subprocess.run without check and without **kwargs.

From the rule's source, subprocess_run_unchecked.rs.

Example from the rule's tests
import subprocessfrom subprocess import run subprocess.run(["ls"])tx0 reports: without check=True a failing command raises nothingrun(["ls"], capture_output=True)tx0 reports: without check=Truesubprocess.run(["ls"], check=True)subprocess.run(["ls"], check=False)runner.run(["ls"])
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 from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/python:subprocess-run-unchecked" = "note"

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:subprocess-run-unchecked] reason="..."

tx0 explain tx0/python:subprocess-run-unchecked shows the same in the terminal. Found a false positive? Report it.