Skip to content

chore: drop empty if TYPE_CHECKING: blocks and orphaned imports (ruff TC005)#153

Open
alexzhu0 wants to merge 1 commit intoFlowElement-ai:mainfrom
alexzhu0:chore/ruff-tc005-drop-empty-type-checking
Open

chore: drop empty if TYPE_CHECKING: blocks and orphaned imports (ruff TC005)#153
alexzhu0 wants to merge 1 commit intoFlowElement-ai:mainfrom
alexzhu0:chore/ruff-tc005-drop-empty-type-checking

Conversation

@alexzhu0
Copy link
Copy Markdown
Contributor

@alexzhu0 alexzhu0 commented May 2, 2026

Summary

Ruff rule TC005 flags empty if TYPE_CHECKING: blocks — dead code left behind by previous refactors when every forward-reference import under the block was eventually removed. 28 occurrences outside generated code.

After deleting the empty block, the TYPE_CHECKING import becomes unused (F401) in the same file. This PR cleans both in one commit so each file is self-consistent; F401 is invoked only on files already touched by TC005, nothing else is rewritten.

-from typing import TYPE_CHECKING
-
 from sqlalchemy import Column, ForeignKey, String, UniqueConstraint
 from sqlalchemy.dialects.postgresql import UUID as PgUUID
 from sqlalchemy.orm import relationship

-if TYPE_CHECKING:
-    pass
-
-
 class Role(Principal):

Some files still have other unused imports the broader F401 sweep would clean up — those are deliberately out of scope here (I tried the global ruff --select F401 --fix and it cascaded into 90 files touching unrelated code). This PR is strictly the TC005 blast radius.

Scope

28 files, +19 / −84. Touched areas:

Layer Files
Graph adapters kuzu, remote_kuzu, neo4j_driver, neptune_driver
Vector adapters ChromaDBAdapter
API / maintenance episode_quality.py
Auth models Role, Tenant
Core domain Entity, Facet
Data models Data, Dataset
LLM backends baml acreate_structured_output, litellm_instructor openai adapter
Episodic memory edge_text_generators, episode_builder/phase0c, episode_size_check, facet_entity_matcher, llm_tasks
Sync SyncOperation
Tests 8 test files covering CLI, crawler e2e, descriptive metrics, permissions, s3, rate-limit retry, parallel DBs, neptune analytics

Verification

$ ruff check . --exclude 'm_flow/baml_client' --exclude 'm_flow-frontend' --select TC005
All checks passed!

$ for f in <every touched file>; do uv run python -c "import ast; ast.parse(open('$f').read())"; done
# clean across all 28 files

$ for mod in m_flow.auth.models.Role m_flow.core.domain.models.Entity \
             m_flow.data.models.Data m_flow.memory.episodic.episode_size_check; do
    uv run python -c "import $mod"
  done
# import ok: all sample modules

No behavior change. Generated code under m_flow/baml_client/ is untouched.

I affirm that all code in every commit of this pull request conforms to the terms of the M-flow Developer Certificate of Origin

…ff TC005)

Ruff rule TC005 flags `if TYPE_CHECKING: pass` / empty `if TYPE_CHECKING`
blocks — dead code left behind by previous refactors when every forward-
reference import under the block was eventually removed.

Scope: 28 files, all hits of TC005 outside generated code. After deleting
each empty block, the `TYPE_CHECKING` symbol becomes an unused import
(F401) in those same 28 files — this PR cleans that up in the same
commit so the files are self-consistent. F401 is invoked only on files
already touched by TC005; nothing else is rewritten.

Verification:
- `ruff check . --exclude 'm_flow/baml_client' --select TC005` is now clean
- `ast.parse` on every touched file: clean
- Import check via project `uv run python` on sample modules: clean

No behavior change.
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.

1 participant