Conversation
added 2 commits
December 15, 2025 10:30
Add `from __future__ import annotations` to all Python modules for: - Zero runtime overhead for type hints (PEP 563) - No need to quote type expressions in cast() - Modern Python 3.7+ best practice - Cleaner, more readable type annotations Removed quotes from cast() calls in file_loader.py as they're no longer needed with postponed evaluation of annotations.
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.
Pull request overview
This PR modernizes the codebase by adding from __future__ import annotations to all Python modules in the contractions package, enabling PEP 563 postponed evaluation of type annotations. This change allows for cleaner type hints without forward references, reduces runtime overhead, and follows modern Python best practices.
- Added
from __future__ import annotationsto all 11 contractions package modules - Updated
cast()calls to use direct type references instead of string literals - Optimized imports in state.py using TYPE_CHECKING guard for runtime performance
- Added TC006 to ruff ignore list to support the TYPE_CHECKING pattern
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| pyproject.toml | Added TC006 to ruff ignore list to allow TYPE_CHECKING import guards |
| contractions/validation.py | Added future annotations import |
| contractions/transformer.py | Added future annotations import |
| contractions/state.py | Added future annotations import and moved textsearch import to TYPE_CHECKING guard |
| contractions/processor.py | Added future annotations import |
| contractions/matcher.py | Added future annotations import |
| contractions/file_loader.py | Added future annotations import and updated cast() calls to use direct type references |
| contractions/extension.py | Added future annotations import and refactored helper functions to inline calls |
| contractions/bootstrap.py | Added future annotations import |
| contractions/api.py | Added future annotations import |
| contractions/init.py | Added future annotations import |
| contractions/_version.py | Bumped version from 0.3.1 to 0.3.2 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.