Skip to content

chore: sort __slots__ tuples alphabetically (ruff RUF023)#152

Open
alexzhu0 wants to merge 1 commit intoFlowElement-ai:mainfrom
alexzhu0:chore/ruff-ruf023-sort-slots
Open

chore: sort __slots__ tuples alphabetically (ruff RUF023)#152
alexzhu0 wants to merge 1 commit intoFlowElement-ai:mainfrom
alexzhu0:chore/ruff-ruf023-sort-slots

Conversation

@alexzhu0
Copy link
Copy Markdown
Contributor

@alexzhu0 alexzhu0 commented May 2, 2026

Summary

Ruff rule RUF023 flags __slots__ tuples that are not in natural-sort order. Python itself doesn't care about slot order — slots are addressed by name, not position — but keeping them sorted makes diffs trivially reviewable and removes a class of copy-paste-then-miss-one-field bugs.

10 occurrences across 9 files, all auto-fixable.

What changed

Pure reordering. No slot is added, removed, renamed, or rewired. No __init__, descriptor lookup, __reduce__/pickle protocol, or inheritance contract changes.

 class CacheDBInterface(ABC):
     ...
-    __slots__ = ("_host", "_port", "_key", "_lock")
+    __slots__ = ("_host", "_key", "_lock", "_port")
 class FastembedEmbeddingEngine(EmbeddingEngine):
     ...
     __slots__ = (
-        "model",
-        "dimensions",
-        "max_completion_tokens",
         "batch_size",
+        "dimensions",
         "embedding_model",
-        "tokenizer",
+        "max_completion_tokens",
         "mock",
+        "model",
+        "tokenizer",
     )

Files

Area Classes
Cache interface CacheDBInterface
Embedding engines FastembedEmbeddingEngine, OllamaEmbeddingEngine
Graph primitives MemoryGraph, MemoryGraphNode, MemoryGraphEdge (2 classes in MemoryGraphElements.py)
Tokenizer adapters GeminiTokenizer, MistralTokenizer
Pipeline / IO Stage (pipeline/tasks/task.py), FileBufferedReader

9 files, +16 / −16.

Verification

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

$ for mod in m_flow.adapters.cache.cache_db_interface \
             m_flow.knowledge.graph_ops.m_flow_graph.MemoryGraph \
             m_flow.pipeline.tasks.task \
             m_flow.shared.files.storage.FileBufferedReader; do
    PYTHONPATH=. uv run python -c "import $mod"
  done
# import ok: all 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

Ruff's RUF023 flags `__slots__` tuples that aren't in natural-sort order.
Python itself doesn't care about slot order — slots are addressed by name,
not position — but keeping them sorted makes diffs trivially reviewable
and removes a class of copy-paste-then-miss-one-field bugs.

Scope: 9 files, 10 classes touched. Each change reorders only the literal
slot strings; no slot is added, removed, renamed, or rewired. No `__init__`,
`__reduce__`, pickling logic, or inheritance contract is affected.

Verification:
- `ruff check . --exclude 'm_flow/baml_client' --select RUF023` is now clean
- import check via project `uv run python` on all touched modules: clean

No behavior change.
@alexzhu0
Copy link
Copy Markdown
Contributor Author

alexzhu0 commented May 5, 2026

Static analysis — weighted-edge sources failing here (and on every fork PR) is not from this change — it's a workflow config bug. The job's ruff-action args pass m_flow/knowledge/graph_ops/** as a string; ruff-action doesn't shell-expand it, so ruff hits E902 No such file or directory on the literal ** path before it lints anything.

I've opened #167 with a two-line fix (drop /**, ruff recurses into directories). Once that merges this check should go green on this PR without any rebase here.

(The other failing checks are already green after the latest push.)

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