Skip to content

Enable ruff TC rules (type-checking imports)#1999

Open
iMicknl wants to merge 1 commit intov2/mainfrom
v2/ruff-tc
Open

Enable ruff TC rules (type-checking imports)#1999
iMicknl wants to merge 1 commit intov2/mainfrom
v2/ruff-tc

Conversation

@iMicknl
Copy link
Copy Markdown
Owner

@iMicknl iMicknl commented Apr 19, 2026

Summary

  • Move type-only imports into TYPE_CHECKING blocks across 13 files
  • Quote type expressions in cast() calls
  • Reduces runtime import overhead without changing behavior

Test plan

  • ruff check . passes
  • pytest — 280 tests pass
  • mypy passes

Copilot AI review requested due to automatic review settings April 19, 2026 17:21
@iMicknl iMicknl requested a review from tetienne as a code owner April 19, 2026 17:21
@iMicknl iMicknl added enhancement New feature or request v2 labels Apr 19, 2026
Copy link
Copy Markdown
Contributor

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

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 TC rules in pyproject.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.

@iMicknl iMicknl force-pushed the v2/ruff-tc branch 2 times, most recently from 8d940a6 to c63e733 Compare April 19, 2026 17:38
- 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request v2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants