Skip to content

Conversation

cclauss
Copy link
Member

@cclauss cclauss commented Mar 17, 2025

% ruff rule PLW1510 # https://docs.astral.sh/ruff/rules/subprocess-run-without-check

By default, subprocess.run() does not check the return code of the process it runs. This can lead to silent failures.

We have 17 silent failures in our tests.

def run_shell_command(cmd: str, args: str, cwd="."):
-   proc = subprocess.run(cmd + args, cwd=cwd, capture_output=True, check=False)
+   proc = subprocess.run(cmd + args, cwd=cwd, capture_output=True, check=True)

Copy link
Member

@aaronliu0130 aaronliu0130 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cpplint is supposed to have a return code of 1 when it collects any error from the input files. There is no problem nor typo here.

In fact the return code is already checked against the expected return code in the .def file in check_def(), which would throw an uncaught OSError if the given .def file was not found.

@cclauss
Copy link
Member Author

cclauss commented Mar 18, 2025

Thanks for clarifying... Closing.

@cclauss cclauss closed this Mar 18, 2025
@cclauss cclauss deleted the run_shell_command-check=True branch March 18, 2025 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants