From cec9106cdf4a29c80297cf2734ec387740fec11a Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Thu, 25 Dec 2025 13:49:59 +0100 Subject: [PATCH] Codespell ignore camelcase (#693) --- action.yml | 4 +++- actions/review_pr.py | 4 ++-- actions/update_markdown_code_blocks.py | 12 ++++++------ actions/utils/common_utils.py | 2 +- actions/utils/openai_utils.py | 2 +- tests/test_update_markdown_codeblocks.py | 8 ++++---- 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/action.yml b/action.yml index 6197bad..66a4c69 100644 --- a/action.yml +++ b/action.yml @@ -232,6 +232,7 @@ runs: continue-on-error: true # Important so that commit step can pick up changes # Spelling --------------------------------------------------------------------------------------------------------- + # --ignore-regex '\b[a-z]+[A-Z][a-zA-Z]*\b' ignores camelCase words (e.g. repoRes, dateA) to prevent false positives - name: Run Codespell if: (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') && inputs.spelling == 'true' && (github.event.action == 'opened' || github.event.action == 'synchronize') run: | @@ -239,7 +240,8 @@ runs: --builtin clear,rare,informal,en-GB_to_en-US \ --write-changes \ --uri-ignore-words-list * \ - --ignore-words-list "cancelled,MapPin,couldn,grey,writeable,finalY,RepResNet,Idenfy,WIT,Smoot,EHR,ROUGE,ALS,iTerm,Carmel,FPR,Hach,Calle,ore,COO,MOT,crate,nd,ned,strack,dota,ane,segway,fo,gool,winn,commend,bloc,nam,afterall,skelton,goin,cann,CANN" \ + --ignore-regex '\b[a-z]+[A-Z][a-zA-Z]*\b' \ + --ignore-words-list "cancelled,MapPin,couldn,grey,writeable,RepResNet,Idenfy,WIT,Smoot,EHR,ROUGE,ALS,Carmel,FPR,Hach,Calle,ore,COO,MOT,crate,nd,ned,strack,dota,ane,segway,fo,gool,winn,commend,bloc,nam,afterall,skelton,goin,cann,CANN" \ --skip "*.pt,*.pth,*.torchscript,*.onnx,*.tflite,*.pb,*.bin,*.param,*.mlmodel,*.engine,*.npy,*.data*,*.csv,*pnnx*,*venv*,*translat*,*lock*,__pycache__*,*.ico,*.jpg,*.png,*.webp,*.avif,*.mp4,*.mov,/runs,/.git,./docs/??/*.md,./docs/mkdocs_??.yml" shell: bash continue-on-error: true diff --git a/actions/review_pr.py b/actions/review_pr.py index ba7a87b..fa87a3e 100644 --- a/actions/review_pr.py +++ b/actions/review_pr.py @@ -115,7 +115,7 @@ def generate_pr_review( continue if len(snippet) == MAX_CONTEXT_FILE_CHARS: snippet = f"{snippet.rstrip()}\n... (truncated)" - # Only include if within budget, include buffer for markdown noise + # Only include if within budget, include buffer for Markdown noise estimated_cost = len(snippet) + 200 if total_chars + estimated_cost < MAX_PROMPT_CHARS: file_contents.append(f"### {file_path}\n```\n{snippet}\n```") @@ -155,7 +155,7 @@ def generate_pr_review( "- Suggestions must be complete, working code with NO comments, placeholders, or explanations\n" "- Single-line fixes only: provide 'suggestion' without 'start_line' to replace the line at 'line'\n" "- Match the exact indentation of the original code\n" - "- Avoid triple backticks (```) in suggestions as they break markdown formatting\n\n" + "- Avoid triple backticks (```) in suggestions as they break Markdown formatting\n\n" "SUMMARY:\n" "- Brief overall assessment: what's good, what needs attention\n" "- If no issues found, acknowledge the PR is clean\n\n" diff --git a/actions/update_markdown_code_blocks.py b/actions/update_markdown_code_blocks.py index 5d1bbe5..3f93306 100644 --- a/actions/update_markdown_code_blocks.py +++ b/actions/update_markdown_code_blocks.py @@ -11,7 +11,7 @@ from pathlib import Path def extract_code_blocks(markdown_content): - """Extracts Python and Bash code blocks from markdown content using regex pattern matching.""" + """Extracts Python and Bash code blocks from Markdown content using regex pattern matching.""" # Python code blocks py_pattern = r"^( *)```(?:python|py|\{[ ]*\.py[ ]*\.annotate[ ]*\})\n(.*?)\n\1```" py_code_blocks = re.compile(py_pattern, re.DOTALL | re.MULTILINE).findall(markdown_content) @@ -120,7 +120,7 @@ def process_markdown_string( process_bash: bool = True, verbose: bool = False, ) -> str: - """Formats Python/Bash code blocks inside a markdown string.""" + """Formats Python/Bash code blocks inside a Markdown string.""" formatted_markdown = markdown_content with tempfile.TemporaryDirectory() as temp_dir_name: temp_dir = Path(temp_dir_name) @@ -157,7 +157,7 @@ def generate_temp_filename(file_path, index, code_type): def process_markdown_file(file_path, temp_dir, process_python=True, process_bash=True, verbose=False): - """Processes a markdown file, extracting code blocks for formatting and updating the original file.""" + """Processes a Markdown file, extracting code blocks for formatting and updating the original file.""" try: markdown_content = Path(file_path).read_text() code_blocks_by_type = extract_code_blocks(markdown_content) @@ -192,7 +192,7 @@ def process_markdown_file(file_path, temp_dir, process_python=True, process_bash def update_markdown_file(file_path, markdown_content, temp_files): - """Updates a markdown file with formatted code blocks.""" + """Updates a Markdown file with formatted code blocks.""" for num_spaces, original_code_block, temp_file_path, code_type in temp_files: try: with open(temp_file_path) as temp_file: @@ -219,7 +219,7 @@ def update_markdown_file(file_path, markdown_content, temp_files): def main(root_dir=Path.cwd(), process_python=True, process_bash=True, verbose=False): - """Processes markdown files, extracts and formats code blocks, and updates the original files.""" + """Processes Markdown files, extracts and formats code blocks, and updates the original files.""" root_path = Path(root_dir) markdown_files = list(root_path.rglob("*.md")) temp_dir = Path("temp_code_blocks") @@ -242,7 +242,7 @@ def main(root_dir=Path.cwd(), process_python=True, process_bash=True, verbose=Fa if process_bash: format_bash_with_prettier(temp_dir) # Format Bash files - # Update markdown files with formatted code blocks + # Update Markdown files with formatted code blocks for markdown_file, markdown_content, temp_files in all_temp_files: update_markdown_file(markdown_file, markdown_content, temp_files) diff --git a/actions/utils/common_utils.py b/actions/utils/common_utils.py index c9c3742..c15f67e 100644 --- a/actions/utils/common_utils.py +++ b/actions/utils/common_utils.py @@ -209,7 +209,7 @@ def filter_diff_text(diff_text: str) -> tuple[str, list[str]]: def format_skipped_files_dropdown(skipped_files: list[str], max_files: int = 100) -> str: - """Format skipped files as a collapsible HTML details dropdown for GitHub markdown.""" + """Format skipped files as a collapsible HTML details dropdown for GitHub Markdown.""" if not skipped_files: return "" count = len(skipped_files) diff --git a/actions/utils/openai_utils.py b/actions/utils/openai_utils.py index bcab0e0..6fc0096 100644 --- a/actions/utils/openai_utils.py +++ b/actions/utils/openai_utils.py @@ -87,7 +87,7 @@ def filter_labels(available_labels: dict, current_labels: list | None = None, is def get_pr_summary_guidelines() -> str: """Returns PR summary formatting guidelines (used by both unified PR open and PR update/merge).""" - return """Summarize this PR, focusing on major changes, their purpose, and potential impact. Keep the summary clear and concise, suitable for a broad audience. Add emojis to enliven the summary. Your response must include all 3 sections below with their markdown headers: + return """Summarize this PR, focusing on major changes, their purpose, and potential impact. Keep the summary clear and concise, suitable for a broad audience. Add emojis to enliven the summary. Your response must include all 3 sections below with their Markdown headers: ### 🌟 Summary (single-line synopsis) diff --git a/tests/test_update_markdown_codeblocks.py b/tests/test_update_markdown_codeblocks.py index 8a11a5a..b7889bb 100644 --- a/tests/test_update_markdown_codeblocks.py +++ b/tests/test_update_markdown_codeblocks.py @@ -15,7 +15,7 @@ from actions.update_markdown_code_blocks import ( def test_extract_code_blocks(): - """Test extracting code blocks from markdown content.""" + """Test extracting code blocks from Markdown content.""" # Test with Python and Bash code blocks markdown_content = """ # Test Markdown @@ -87,7 +87,7 @@ def test_generate_temp_filename(): @patch("pathlib.Path.write_text") @patch("builtins.open", new_callable=mock_open) def test_process_markdown_file(mock_file, mock_write, mock_read_text): - """Test processing markdown files.""" + """Test processing Markdown files.""" mock_read_text.return_value = """ # Test @@ -109,7 +109,7 @@ def test(): def test_main_real_files(): - """Test main function on actual repository markdown files.""" - # Run main on current directory which contains README.md and other markdown files + """Test main function on actual repository Markdown files.""" + # Run main on current directory which contains README.md and other Markdown files # This provides real-world test coverage of the entire pipeline main(process_python=True, process_bash=True, verbose=False)