Skip to content

fix: config validation, dead code removal, and performance improvements#9

Merged
mit-d merged 1 commit intomainfrom
feat/misc-bug-fixes
Mar 11, 2026
Merged

fix: config validation, dead code removal, and performance improvements#9
mit-d merged 1 commit intomainfrom
feat/misc-bug-fixes

Conversation

@mit-d
Copy link
Copy Markdown
Owner

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

Summary

  • Validate config values: severity, --allow-category, --allow-script — invalid values now exit 2 with helpful messages instead of silently misbehaving
  • Improve error handling: catch missing/malformed config files and warn on unrecognised config keys (e.g. typos like alow-codepoints)
  • Remove dead code & improve performance: remove unreachable U+FFFD from REPLACEMENT_TABLE, refactor fixer to use str.translate(), eliminate duplicate file reads when --check-confusables is enabled
  • Code cleanup: simplify _parse_codepoint, add slots=True to Override dataclass

Test plan

  • All 223 tests pass (10 new tests for validation/error handling)
  • ruff, mypy, and all pre-commit hooks pass
  • Existing behavior preserved — new text parameter defaults to None (backward compatible)

- Validate severity values from config/overrides (exit 2 on invalid)
- Catch config load errors with friendly messages (exit 2)
- Validate --allow-category and --allow-script values
- Warn on unrecognised config keys
- Remove unreachable U+FFFD entry from REPLACEMENT_TABLE
- Refactor fixer to use str.translate() for better performance
- Read files once when --check-confusables is enabled
- Simplify _parse_codepoint prefix handling
- Add slots=True to Override dataclass
@mit-d mit-d merged commit f34e78f into main Mar 11, 2026
4 checks passed
@mit-d mit-d deleted the feat/misc-bug-fixes branch March 11, 2026 01:17
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