Skip to content

Conversation

@2bndy5
Copy link
Contributor

@2bndy5 2bndy5 commented Feb 6, 2026

See PEP604 which was adopted/preferred as of Python 3.10.

Summary by CodeRabbit

  • Refactor
    • Modernized type annotations across the codebase to use newer Python union and generic syntax (PEP 604/585). No runtime behavior changes; improves maintainability and type-checking.
  • Tests
    • Updated test type annotations to match the new typing style. No test logic changes.

@codecov
Copy link

codecov bot commented Feb 6, 2026

Codecov Report

❌ Patch coverage is 98.88889% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 98.30%. Comparing base (2f02972) to head (1edb6cf).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
cpp_linter/common_fs/__init__.py 92.85% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #187      +/-   ##
==========================================
- Coverage   98.30%   98.30%   -0.01%     
==========================================
  Files          24       24              
  Lines        1947     1942       -5     
==========================================
- Hits         1914     1909       -5     
  Misses         33       33              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

See [PEP604] which was adopted/preferred as of Python 3.10.

[PEP604]: https://peps.python.org/pep-0604/
@2bndy5 2bndy5 marked this pull request as ready for review February 6, 2026 08:37
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 6, 2026

Walkthrough

This PR modernizes type annotations project-wide, replacing typing module aliases (List, Dict, Optional, Union, Tuple) with Python 3.9+ built-in generics (list, dict, tuple) and PEP 604 union syntax (X | None), updating signatures, attributes, and test annotations accordingly.

Changes

Cohort / File(s) Summary
Clang Tools Core
cpp_linter/clang_tools/__init__.py, cpp_linter/clang_tools/clang_format.py, cpp_linter/clang_tools/clang_tidy.py, cpp_linter/clang_tools/patcher.py
Replaced typing aliases with built-in generics and PEP 604 unions across public APIs, class attributes and function signatures (e.g., Optional[T] → `T
File System & Filtering
cpp_linter/common_fs/__init__.py, cpp_linter/common_fs/file_filter.py
Modernized FileObj and FileFilter type hints (lists of ints, ranges, diff chunks, optional advice types) to built-in generics and union syntax; updated method signatures/returns accordingly.
Git Integration
cpp_linter/git/__init__.py, cpp_linter/git/git_str.py
Converted get_sha/get_diff/parse_diff/parse_patch signatures and internal annotations to built-in generics and PEP 604 unions; adjusted some commit/peel usages and parse error casting formatting.
REST API Layer
cpp_linter/rest_api/__init__.py, cpp_linter/rest_api/github_api.py
Updated RestApiClient and GitHub API method signatures, payload typings, and internal list/dict annotations to list[...], dict[...], and union syntax for optional params/returns.
CLI Configuration
cpp_linter/cli.py
Replaced typing aliases in Args dataclass and parser helpers with built-in generics and union syntax (e.g., diff_base, extensions, jobs, _parser_args, _parse_jobs).
Tests
tests/capture_tools_output/*, tests/ignored_paths/*, tests/test_cli_args.py, tests/test_misc.py, tests/test_rate_limits.py
Harmonized test parameter and local type hints to built-in generics and union syntax; no behavioral changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • shenxianpeng
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 69.77% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main objective: updating the codebase to use PEP 604 typing syntax (union operator |) instead of older Optional/Union imports from the typing module.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch pep604-typing

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot]

This comment was marked as duplicate.

coderabbitai[bot]

This comment was marked as resolved.

does not bump any deps though;
just removes old locks related to python 3.9
@cpp-linter cpp-linter deleted a comment from coderabbitai bot Feb 6, 2026
@2bndy5 2bndy5 merged commit 9a5897a into main Feb 6, 2026
43 checks passed
@2bndy5 2bndy5 deleted the pep604-typing branch February 6, 2026 09:14
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.

1 participant