Skip to content

Conversation

@devjerry0
Copy link
Owner

@devjerry0 devjerry0 commented Dec 15, 2025

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

Copilot AI review requested due to automatic review settings December 15, 2025 14:02
devjerry0 and others added 2 commits December 15, 2025 09:02
- 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
Copy link

Copilot AI left a 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: matchersmatcher, transformerstransformer, extensionsextension
  • 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 (flankcontext_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 items parameter should be typed as list[list[str]] (not just list) since it receives token_options from line 34 which is a list of lists. Similarly, the return type should be list[list[str]] since the function creates a list where each element is either a list from items or the separator list. 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
Copilot AI review requested due to automatic review settings December 15, 2025 14:28
- 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
Copy link

codecov bot commented Dec 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link

Copilot AI left a 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 items parameter should be more specific. It should be list[list[str]] instead of list to match the actual usage in _get_combinations where it receives token_options = [[token] for token in tokens]. Similarly, the return type should be list[list[str] | list[str]] or more accurately list[list[str]] since it returns a list of lists/separators.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings December 15, 2025 14:38
@devjerry0 devjerry0 merged commit 594affd into main Dec 15, 2025
18 checks passed
@devjerry0 devjerry0 deleted the refactor/singular-module-names branch December 15, 2025 14:45
Copy link

Copilot AI left a 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.

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.

2 participants