Skip to content

subprocess-run-without-check

Pythonsuspiciousno fixdefault: offpython/ruff

Reports a call of subprocess.run with no check keyword. A call with **kwargs is not reported.

By default run returns after the command fails and does not tell: the exit status is only in returncode, and a script that never reads it goes on as if the command had worked. check=True raises CalledProcessError, and check=False says that the status is read or ignored on purpose.

To fix, pass check=True, or check=False when the status is handled.

Reported
...
pass
...
subprocess.run(["ls"])
a = b = "x"
...
python:
lint:
rules:
subprocess-run-without-check: warn # off (default), warn, error

Enabled by the presets: python/ruff.

Suppress one line with sudsy-disable-next-line subprocess-run-without-check 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 PLW1510 full