Skip to content

MAINT Enable ruff TCH (flake8-type-checking) rules and fix all violations#1395

Merged
romanlutz merged 12 commits intomicrosoft:mainfrom
romanlutz:romanlutz/ruff_tch
Feb 26, 2026
Merged

MAINT Enable ruff TCH (flake8-type-checking) rules and fix all violations#1395
romanlutz merged 12 commits intomicrosoft:mainfrom
romanlutz:romanlutz/ruff_tch

Conversation

@romanlutz
Copy link
Copy Markdown
Contributor

Move type-only imports into TYPE_CHECKING blocks to improve runtime performance:

  • Move first-party imports used only in annotations (TC001)
  • Move third-party imports used only in annotations (TC002)
  • Move stdlib imports used only in annotations (TC003)
  • Quote cast() type arguments for deferred evaluation (TC006)
  • Fix string union in runtime annotation with future annotations (TC010)
  • Clean up resulting isort and unused import issues

Move type-only imports into TYPE_CHECKING blocks to improve runtime performance:
- Move first-party imports used only in annotations (TC001)
- Move third-party imports used only in annotations (TC002)
- Move stdlib imports used only in annotations (TC003)
- Fix string union in runtime annotation with __future__ annotations (TC010)
- Ignore TC006 (quoting cast types is unnecessary for builtins)
- Clean up resulting isort and unused import issues

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Resolve conflicts from main branch updates including:
- ComponentIdentifier refactor (replacing individual identifier types)
- New lint rules (W) in pyproject.toml
- Various code changes in scorer, converter, and executor modules
@hannahwestra25 hannahwestra25 self-assigned this Feb 24, 2026
romanlutz and others added 8 commits February 25, 2026 04:47
Resolved pyproject.toml (keep both RET and TCH), accepted main for
remote_dataset_loader.py and hugging_face_chat_target.py then re-applied
TCH fixes. Added noqa for scorer.py runtime cast imports. Ignore TCH in
doc/ since notebooks run at runtime.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The chatml_tokenizer_normalizer fixture was calling
AutoTokenizer.from_pretrained() which requires network access to
HuggingFace. Replaced with a mock that simulates ChatML template
formatting, making the test fully offline.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
romanlutz and others added 2 commits February 26, 2026 11:00
…to TYPE_CHECKING

- scorer.py: Move PromptChatTarget/PromptTarget to TYPE_CHECKING block
  (only used in annotations, file has 'from __future__ import annotations')
- workflow_strategy.py + 4 other files: Move 'import logging' back to
  runtime with noqa:TC003 (stdlib module, no import cost concern)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@hannahwestra25 hannahwestra25 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@romanlutz romanlutz merged commit 7c65439 into microsoft:main Feb 26, 2026
28 checks passed
@romanlutz romanlutz deleted the romanlutz/ruff_tch branch February 26, 2026 20:56
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