From b8900b5fef02cf004bb25304ee96ebc371c597d2 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Fri, 24 Jul 2026 01:27:35 +0200 Subject: [PATCH] Ruff 0.16.0 compatibility changes (#833) --- actions/__init__.py | 2 +- actions/update_markdown_code_blocks.py | 9 +++++---- tests/test_update_markdown_codeblocks.py | 1 + 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/actions/__init__.py b/actions/__init__.py index a4278a3..494fc9d 100644 --- a/actions/__init__.py +++ b/actions/__init__.py @@ -28,4 +28,4 @@ # ├── test_summarize_pr.py # └── ... -__version__ = "0.2.34" +__version__ = "0.2.35" diff --git a/actions/update_markdown_code_blocks.py b/actions/update_markdown_code_blocks.py index a40277a..622abad 100644 --- a/actions/update_markdown_code_blocks.py +++ b/actions/update_markdown_code_blocks.py @@ -73,7 +73,7 @@ def format_code_with_ruff(temp_dir): "--unsafe-fixes", "--extend-select=F,I,D,UP,RUF", "--target-version=py38", - "--ignore=BLE001,D100,D101,D103,D104,D203,D205,D212,D213,D401,D406,D407,D413,F821,F841,RUF001,RUF002,RUF012,S110", + "--ignore=B018,BLE001,D100,D101,D103,D104,D203,D205,D212,D213,D401,D406,D407,D413,F821,F841,RUF001,RUF002,RUF012,S110", str(temp_dir), ], check=True, @@ -108,6 +108,7 @@ def format_bash_with_prettier(temp_dir): shell=True, # must use shell=True to expand internal $(cmd) capture_output=True, text=True, + check=False, ) if result.returncode != 0: print(f"ERROR running prettier-plugin-sh ❌ {result.stderr}") @@ -183,7 +184,7 @@ def process_markdown_file(file_path, temp_dir, process_python=True, process_bash temp_file_path = temp_dir / generate_temp_filename(file_path, i + offset, code_type) with open(temp_file_path, "w", encoding="utf-8") as temp_file: - temp_file.write(code_without_indentation) + temp_file.write(f"{code_without_indentation}\n") temp_files.append((num_spaces, code_block, temp_file_path, code_type)) @@ -221,9 +222,9 @@ def update_markdown_file(file_path, markdown_content, temp_files): print(f"Error writing file {file_path}: {e}") -def main(root_dir=Path.cwd(), process_python=True, process_bash=True, verbose=False): +def main(root_dir=None, process_python=True, process_bash=True, verbose=False): """Processes Markdown files, extracts and formats code blocks, and updates the original files.""" - root_path = Path(root_dir) + root_path = Path.cwd() if root_dir is None else Path(root_dir) markdown_files = [markdown_file for markdown_file in root_path.rglob("*.md") if not markdown_file.is_symlink()] temp_dir = Path("temp_code_blocks") temp_dir.mkdir(exist_ok=True) diff --git a/tests/test_update_markdown_codeblocks.py b/tests/test_update_markdown_codeblocks.py index 956a2c3..6319462 100644 --- a/tests/test_update_markdown_codeblocks.py +++ b/tests/test_update_markdown_codeblocks.py @@ -106,6 +106,7 @@ def test(): assert len(temp_files) == 1 assert temp_files[0][1] == "def test():\n return True" mock_file.assert_called_once() + mock_file().write.assert_called_once_with("def test():\n return True\n") def test_format_bash_skips_when_no_shell_files(tmp_path):