Skip to content

refactor: consolidate codepoint parsing into reusable module#11

Merged
mit-d merged 1 commit intomainfrom
refactor/consolidate-codepoint-parsing
Mar 21, 2026
Merged

refactor: consolidate codepoint parsing into reusable module#11
mit-d merged 1 commit intomainfrom
refactor/consolidate-codepoint-parsing

Conversation

@mit-d
Copy link
Copy Markdown
Owner

@mit-d mit-d commented Mar 21, 2026

Summary

  • Extract _parse_codepoint() and _parse_range() from main.py into a new check_unicode.parsing module with public
    API
  • Add input validation: Unicode range bounds (0..U+10FFFF), empty/invalid input rejection, inverted range detection (lo

hi), whitespace tolerance around range dashes

  • Functions raise ValueError instead of argparse.ArgumentTypeError so they're reusable from both CLI and config
    layers
  • 25 new unit tests in test_parsing.py covering all formats (U+XXXX, 0xXXXX, bare hex), edge cases, and error paths
  • Prerequisite for upcoming configurable replacement table feature

Test plan

  • All 265 tests pass (pytest --cov=check_unicode --cov-fail-under=80)
  • 98% coverage, parsing.py at 100%
  • ruff check and mypy --strict clean
  • Smoke test: existing CLI behavior unchanged for --allow-codepoint and --allow-range
  • CI matrix (Python 3.11-3.14)

Extract _parse_codepoint() and _parse_range() from main.py into a new
check_unicode.parsing module with public API, input validation, and
comprehensive tests.

- parse_codepoint(): validates 0..U+10FFFF range, rejects empty/invalid input
- parse_range(): validates lo <= hi ordering, tolerates whitespace around dash
- Both raise ValueError (not argparse.ArgumentTypeError) for reuse from config layer
- 25 new unit tests in test_parsing.py
@mit-d mit-d merged commit 7b5ac03 into main Mar 21, 2026
4 checks passed
@mit-d mit-d deleted the refactor/consolidate-codepoint-parsing branch March 21, 2026 00:36
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