FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

`run_shell_command()` with `check=True` to avoid silent failures by cclauss · Pull Request #343 · cpplint/cpplint · GitHub

run_shell_command() with check=True to avoid silent failures - #343

Closed
cclauss wants to merge 1 commit into
developfrom
run_shell_command-check=True
Closed

run_shell_command() with check=True to avoid silent failures#343
cclauss wants to merge 1 commit into
developfrom
run_shell_command-check=True

Conversation

cclauss commented Mar 17, 2025
edited
Loading

Copy link
Copy Markdown
Member

% 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)

aaronliu0130 left a comment
edited
Loading

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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 commented Mar 18, 2025

Copy link
Copy Markdown
Member Author

Thanks for clarifying... Closing.

cclauss closed this Mar 18, 2025
cclauss deleted the run_shell_command-check=True branch March 18, 2025 13:03
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL