Skip to content

Commit

Permalink
Update update_markdown_code_blocks.py (#109)
Browse files Browse the repository at this point in the history
Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
  • Loading branch information
glenn-jocher and UltralyticsAssistant authored Jun 18, 2024
1 parent adee335 commit a4a82cc
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion utils/update_markdown_code_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,29 @@ def add_indentation(code_block, num_spaces):
def format_code_with_ruff(temp_dir):
"""Formats all Python code files in the `temp_dir` directory using the 'ruff' linter tool."""
try:
# Run ruff commands to format the code
# Run ruff check
subprocess.run(["ruff", "check", "--fix", "--extend-select", "I", "-q", str(temp_dir)], check=True)

# Run ruff format
subprocess.run(["ruff", "format", "--line-length", "120", "-q", str(temp_dir)], check=True)

# Run docformatter
subprocess.run(
[
"docformatter",
"--wrap-summaries",
"120",
"--wrap-descriptions",
"120",
"--in-place",
"--pre-summary-newline",
"--close-quotes-on-newline",
"--recursive",
str(temp_dir),
],
check=True,
)

except Exception as e:
print(f"ERROR running ruff: {e}")

Expand Down

0 comments on commit a4a82cc

Please sign in to comment.