Enable ruff TC rules (type-checking imports)#1999
Conversation
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
|
@copilot resolve the merge conflicts in this pull request |
# Conflicts: # pyoverkiz/models.py Co-authored-by: iMicknl <1424596+iMicknl@users.noreply.github.com>
Agent-Logs-Url: https://github.com/iMicknl/python-overkiz-api/sessions/eeb5e0c6-f7f9-49a5-b716-d2f4a40badb0 Co-authored-by: iMicknl <1424596+iMicknl@users.noreply.github.com>
Resolved. I merged Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Summary
TYPE_CHECKINGblocks across 13 filescast()callsTest plan
ruff check .passespytest— 280 tests passmypypasses