-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor/singular module names #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Move ruff and mypy configs from standalone files to pyproject.toml - Add .idea/ and uv.lock to .gitignore - Document e() and p() shorthand aliases in API Reference
- Add return type annotations to all matcher factory functions - Add type annotations to validation function parameters (using object instead of Any) - Add type cast to file_loader after runtime validation - Fix deprecated fix() function type annotations with type: ignore - Sort __all__ exports alphabetically - Add assertion guards after _load_dicts() to satisfy mypy strict checks
- Replace os.path.exists() with Path.exists() - Replace open() context manager with Path.read_text() - Remove os import in favor of pathlib.Path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors the codebase to use singular module names (matcher, transformer, extension) instead of plural forms, consolidates configuration into pyproject.toml, and adds comprehensive type annotations to improve type safety with strict mypy settings.
Key Changes:
- Renamed modules:
matchers→matcher,transformers→transformer,extensions→extension - Consolidated all tool configurations (mypy, ruff) from separate files into pyproject.toml
- Added type hints throughout validation.py, matcher.py, file_loader.py, init.py, and transformer.py
- Enhanced mypy and ruff configurations with stricter type checking and linting rules
- Updated documentation to reflect API improvements and performance benchmarks
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| setup.cfg | Removed obsolete RPM build configuration (consolidated into pyproject.toml) |
| mypy.ini | Removed standalone mypy config (moved to pyproject.toml) |
| pyproject.toml | Consolidated and enhanced tool configurations with strict mypy settings, comprehensive ruff rules, and pytest options |
| contractions/validation.py | Added object type hints to validation function parameters for better type safety |
| contractions/transformer.py | Added type annotation to _intersperse separator parameter |
| contractions/processor.py | Updated import from matchers to matcher module |
| contractions/matcher.py | Added return type hints and assert statements to ensure non-None state after loading dictionaries |
| contractions/file_loader.py | Added cast() calls to provide type checker with specific generic types after runtime validation |
| contractions/extension.py | Updated import from matchers to matcher module |
| contractions/bootstrap.py | Updated import from transformers to transformer module |
| contractions/api.py | Updated import from extensions to extension module |
| contractions/init.py | Added type hints to fix() function and alphabetically sorted __all__ exports |
| README.md | Updated API parameter names (flank → context_chars), performance metrics, and improved documentation structure |
| .gitignore | Added .idea/ (JetBrains IDEs) and uv.lock (uv package manager) |
Comments suppressed due to low confidence (1)
contractions/transformer.py:38
- The type annotations are incomplete. The
itemsparameter should be typed aslist[list[str]](not justlist) since it receivestoken_optionsfrom line 34 which is a list of lists. Similarly, the return type should belist[list[str]]since the function creates a list where each element is either a list fromitemsor theseparatorlist. These incomplete annotations will prevent mypy from catching type errors with the strict settings enabled in pyproject.toml (lines 96-99).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Auto-fix 46 ruff errors (quotes, import sorting, etc.) - Add type annotations to test helper functions - Add TypedDict for BenchmarkResults in test_performance.py - Configure mypy to be less strict on tests (common practice) - All checks now pass: ruff, mypy, pytest
- Add return type annotations (-> None) to all test functions - Add type: ignore comments for intentional type violations in tests - Fix type narrowing issues in preview test assertions - Remove mypy test override - tests now pass strict type checking - Exclude build/ and dist/ directories from mypy - All checks pass: mypy (strict), ruff, pytest
- TC006: Quote type expressions in typing.cast() for type checkers - RUF043: Use raw strings for regex patterns with metacharacters - Escape dots in pytest.raises(match=...) patterns
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 18 out of 19 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
contractions/transformer.py:38
- The type annotation for
itemsparameter should be more specific. It should belist[list[str]]instead oflistto match the actual usage in_get_combinationswhere it receivestoken_options = [[token] for token in tokens]. Similarly, the return type should belist[list[str] | list[str]]or more accuratelylist[list[str]]since it returns a list of lists/separators.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 19 out of 20 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
contractions/transformer.py:38
- Incomplete type annotation on function. The items parameter is untyped (just list) and the return type is also untyped (just list). With strict mypy settings enabled (disallow_untyped_defs = true), this function should have complete type hints. The items parameter appears to be list[list[str]] based on usage in _get_combinations, and the return type should be list[list[str] | list[str]] or similar. Consider fully typing this function to comply with the strict type checking configuration.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This pr got a bit bigger than i planned lol since it's only me working on this 🤷
refactored the codebase to use singular module names (matcher, transformer, extension) instead of plural forms, consolidated configuration into pyproject.toml, and added comprehensive type annotations to improve type safety with strict mypy settings.
Key Changes:
Renamed modules: matchers → matcher, transformers → transformer, extensions → extension
Consolidated all tool configurations (mypy, ruff) from separate files into pyproject.toml
Added type hints throughout validation.py, matcher.py, file_loader.py, init.py, and transformer.py
Enhanced mypy and ruff configurations with stricter type checking and linting rules
Updated documentation to reflect API improvements and performance benchmarks