Skip to content

Conversation

@devjerry0
Copy link
Owner

No description provided.

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.
Copilot AI review requested due to automatic review settings December 15, 2025 15:31
@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!

@devjerry0 devjerry0 merged commit 269aa64 into main Dec 15, 2025
12 checks passed
@devjerry0 devjerry0 deleted the refactor/future-annotations branch December 15, 2025 15:38
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 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 annotations to 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.

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