ci: H-1 batch 4 — Ruff SIM + RUF#111
Merged
Merged
Conversation
Adds SIM (flake8-simplify) and RUF (ruff-specific) to the ruff `select`
list. Surfaced 37 findings; 17 auto/unsafe-fixed, 16 manual fixes, plus
RUF002/RUF003 (ambiguous unicode in docstrings/comments) ignored
globally — the en-dash and × characters are intentional.
## Manual fixes
- **RUF012** (mutable default class attribute, 4 cases) — annotated as
`ClassVar[...]`: `EntityExtractor.REGEX_PATTERNS / ENTITY_TYPES /
_NAME_STOPWORDS`, `NoteConstructor.CAUSAL_RELATIONS`.
- **SIM102** (nested if → and-combined) — flattened in `ontology.py`
(3 cases) and `governance_validator.py`. The latter also removed a
no-op `pass`-only branch left over from a placeholder.
- **SIM105** (try-except-pass → contextlib.suppress) — applied to
`llm_providers/__init__.py` and `memory_store.py` Lance delete-row.
- **SIM108** (if-else → ternary) — `compact_lance.py` mode dispatch.
- **SIM103** (return negated) — `vector_retriever._is_valid_embedding`.
- **F401** (unused `import dateparser`) — replaced probe-import with
`importlib.util.find_spec("dateparser")` in temporal-boost path.
## Why ignore RUF002/RUF003
The codebase uses `–` (EN DASH) in comments and docstrings as a
typographic separator (e.g., "0.0–10.0", "—") and `×` in performance
docs (e.g., "32× improvement"). These are intentional stylistic
choices. A top-level ignore matches the actual authoring conventions.
Stacked on fix/audit-h1-ruff-batch-3-up (PR #109).
Contributor
There was a problem hiding this comment.
Pull request overview
Expands the project’s Ruff lint coverage by enabling SIM (flake8-simplify) and RUF (Ruff-specific) rules, then applies mechanical refactors and small typing fixes across the codebase to make the new rules pass.
Changes:
- Update Ruff configuration to select
SIMandRUF, and globally ignoreRUF002/RUF003for intentional Unicode punctuation in comments/docstrings. - Refactor multiple sites to satisfy
SIM*rules (flatten nestedifs, replacetry/except/passwithcontextlib.suppress, simplify list concatenation patterns). - Fix typing issues surfaced by Ruff (e.g., optional parameter annotations,
ClassVarfor mutable class attributes).
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/zettelforge/vector_retriever.py | Simplifies variance check return logic for embeddings (SIM103). |
| src/zettelforge/vector_memory.py | Collapses chunking if/else into a conditional expression (SIM108). |
| src/zettelforge/synthesis_generator.py | Corrects tier_filter typing to list[str] | None. |
| src/zettelforge/sqlite_backend.py | Uses contextlib.suppress during WAL checkpoint and simplifies list building. |
| src/zettelforge/scripts/compact_lance.py | Simplifies mode dispatch to a conditional expression (SIM108). |
| src/zettelforge/ontology.py | Flattens nested conditionals in validators and query helpers (SIM102). |
| src/zettelforge/note_constructor.py | Annotates mutable class attribute with ClassVar (RUF012). |
| src/zettelforge/memory_store.py | Replaces try/except/pass with contextlib.suppress for best-effort deletes (SIM105). |
| src/zettelforge/memory_manager.py | Removes unused local (_intent_meta), replaces probe-import with find_spec, updates optional typing. |
| src/zettelforge/llm_providers/init.py | Replaces try/except ValueError with contextlib.suppress during provider registration (SIM105). |
| src/zettelforge/knowledge_graph.py | Simplifies list extension pattern for DFS paths. |
| src/zettelforge/graph_retriever.py | Simplifies list extension pattern for BFS paths. |
| src/zettelforge/governance_validator.py | Flattens nested if structure (SIM102) and removes no-op branch. |
| src/zettelforge/entity_indexer.py | Adds ClassVar for mutable class attrs, uses contextlib.suppress for cleanup, minor iteration simplification. |
| src/zettelforge/demo.py | Removes unused return value binding. |
| src/zettelforge/config.py | Replaces nested try/except/pass with contextlib.suppress for float parsing (SIM105). |
| src/zettelforge/init.py | Reorders __all__ entries (no functional change). |
| pyproject.toml | Enables Ruff SIM + RUF and ignores RUF002/RUF003 globally. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
4 tasks
rolandpg
added a commit
that referenced
this pull request
Apr 25, 2026
… work The [Unreleased] section was empty since v2.4.3 cut. Captures everything merged since: RFC-011 local LLM backend (#104), RFC-012 LiteLLM (#108), the H-1 Ruff ratchet (#106 #107 #109 #111 #113), the L-4 CI shell-precedence fix (#112), the spec-drift validator broadening + GOV-009 Snyk declarations (#114), and a CONTRIBUTING.md accuracy pass (#115). Adds a compliance-audit closure table mirroring the running scoreboard in TODO.md, scoped to what shipped — outstanding items (H-3 mypy, H-4 GOV-006, M-2 RFC template, M-4 lock file) listed below the table as remaining work for v2.5.x. Targets v2.5.0 release.
2 tasks
rolandpg
added a commit
that referenced
this pull request
Apr 25, 2026
… work (#116) The [Unreleased] section was empty since v2.4.3 cut. Captures everything merged since: RFC-011 local LLM backend (#104), RFC-012 LiteLLM (#108), the H-1 Ruff ratchet (#106 #107 #109 #111 #113), the L-4 CI shell-precedence fix (#112), the spec-drift validator broadening + GOV-009 Snyk declarations (#114), and a CONTRIBUTING.md accuracy pass (#115). Adds a compliance-audit closure table mirroring the running scoreboard in TODO.md, scoped to what shipped — outstanding items (H-3 mypy, H-4 GOV-006, M-2 RFC template, M-4 lock file) listed below the table as remaining work for v2.5.x. Targets v2.5.0 release.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
SIM(flake8-simplify) andRUF(ruff-specific) to the ruffselectlist. Surfaced 37 findings; 17 auto/unsafe-fixed, 16 manual fixes, plus RUF002/RUF003 ignored globally for stylistic unicode (en-dash–and×).Manual fixes
ClassVar[...]onEntityExtractor.REGEX_PATTERNS / ENTITY_TYPES / _NAME_STOPWORDS,NoteConstructor.CAUSAL_RELATIONSand-combined in ontology + governance_validatorcontextlib.suppressin llm_providers + lance row deletedateparser→importlib.util.find_specWhy ignore RUF002/RUF003
Codebase consistently uses
–(EN DASH) as typographic separator in comments and docstrings, and×in performance docs ("32× improvement"). Stylistic, not bugs.Test plan
ruff check src/cleanruff format --check src/cleantest_ingest_relationship,test_intent_classification)🤖 Generated with Claude Code