Enable ruff TC rules (type-checking imports)#1999
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Enables Ruff’s flake8-type-checking (“TC”) rules and updates the codebase to comply by moving type-only imports behind TYPE_CHECKING guards and avoiding runtime-evaluated type references (notably in cast() calls), reducing import-time overhead.
Changes:
- Enable Ruff
TCrules inpyproject.toml. - Move type-only imports into
if TYPE_CHECKING:blocks across the codebase. - Quote type expressions in
cast()calls to avoid runtime type dependencies.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| utils/generate_enums.py | Move model imports to TYPE_CHECKING and quote cast() type expressions. |
| pyproject.toml | Enable Ruff TC rules. |
| pyoverkiz/types.py | Guard Callable import behind TYPE_CHECKING. |
| pyoverkiz/response_handler.py | Guard aiohttp.ClientResponse import behind TYPE_CHECKING. |
| pyoverkiz/obfuscate.py | Guard JSON type import behind TYPE_CHECKING. |
| pyoverkiz/models.py | Guard typing-only imports and quote cast() type expressions. |
| pyoverkiz/enums/base.py | Quote cast() type argument for Self. |
| pyoverkiz/client.py | Guard typing-only imports and quote cast() type expressions. |
| pyoverkiz/auth/strategies.py | Guard typing-only imports and quote cast() type expressions. |
| pyoverkiz/auth/factory.py | Guard typing-only imports (ssl, ClientSession, ServerConfig). |
| pyoverkiz/auth/base.py | Guard Mapping import behind TYPE_CHECKING. |
| pyoverkiz/action_queue.py | Guard typing-only imports behind TYPE_CHECKING. |
| pyoverkiz/_case.py | Guard Callable import behind TYPE_CHECKING. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
8d940a6 to
c63e733
Compare
- Move type-only imports behind TYPE_CHECKING guards across 13 files - Ignore TC006 (quoting cast types hurts IDE autocomplete) - Reduces import-time overhead by deferring annotation-only imports
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.
Summary
TYPE_CHECKINGblocks across 13 filescast()callsTest plan
ruff check .passespytest— 280 tests passmypypasses