From 9726042964cf112b3180be7e0c63806b46cf0945 Mon Sep 17 00:00:00 2001 From: Tarik Moussa Date: Mon, 15 Jun 2026 08:43:53 +0200 Subject: [PATCH] style: ruff format normalization to line-length=100 Committed code predated the line-length=100 ruff config; this brings the five drifted files into compliance. No logic change. Co-Authored-By: Claude Fable 5 --- codex/sources/semanticscholar.py | 5 +--- codex/synthesis.py | 6 +---- codex/wiki.py | 41 +++++++++++++++++++++++++------- tests/synthesis/test_cli.py | 4 +--- tests/wiki/test_compile.py | 12 +++------- 5 files changed, 38 insertions(+), 30 deletions(-) diff --git a/codex/sources/semanticscholar.py b/codex/sources/semanticscholar.py index 90c383b..e82d75a 100644 --- a/codex/sources/semanticscholar.py +++ b/codex/sources/semanticscholar.py @@ -96,10 +96,7 @@ def fetch_references(paper_id: str) -> list[Citation]: context: str | None = contexts[0] if contexts else None cited_id: str = ( - external_ids.get("DOI") - or external_ids.get("ArXiv") - or cited_paper.get("paperId") - or "" + external_ids.get("DOI") or external_ids.get("ArXiv") or cited_paper.get("paperId") or "" ) if cited_id: citations.append(Citation(citing_id=paper_id, cited_id=cited_id, context=context)) diff --git a/codex/synthesis.py b/codex/synthesis.py index 2baba3f..dcc1586 100644 --- a/codex/synthesis.py +++ b/codex/synthesis.py @@ -365,11 +365,7 @@ def find_connections( continue seen_pairs.add(pair) # type: ignore[arg-type] - pair_chunks = [ - c - for c in chunks - if c.get("bibkey") in {bibkey, other} - ] + pair_chunks = [c for c in chunks if c.get("bibkey") in {bibkey, other}] prompt = _CONNECTION_PROMPT.format(chunks_block=_format_chunks(pair_chunks)) raw = _safe_llm_generate(llm, prompt, settings.synthesis_llm_model) if not raw.strip(): diff --git a/codex/wiki.py b/codex/wiki.py index 2efe15e..b47a98a 100644 --- a/codex/wiki.py +++ b/codex/wiki.py @@ -240,9 +240,36 @@ def _parse_claims(markdown: str) -> list[Claim]: _STOPWORDS: frozenset[str] = frozenset( { - "the", "a", "an", "in", "on", "of", "to", "is", "are", "was", "were", - "and", "or", "but", "for", "with", "this", "that", "it", "we", "they", - "be", "as", "at", "by", "from", "has", "have", "not", "which", + "the", + "a", + "an", + "in", + "on", + "of", + "to", + "is", + "are", + "was", + "were", + "and", + "or", + "but", + "for", + "with", + "this", + "that", + "it", + "we", + "they", + "be", + "as", + "at", + "by", + "from", + "has", + "have", + "not", + "which", } ) @@ -360,12 +387,8 @@ def _detect_conflicts( for bk2 in bibkeys[i + 1 :]: # Check if any chunk from bk1 contains a conflict keyword # and any chunk from bk2 also does — heuristic signal only - bk1_has_conflict = any( - _CONFLICT_KEYWORDS.search(c) for c in by_bib[bk1] - ) - bk2_has_conflict = any( - _CONFLICT_KEYWORDS.search(c) for c in by_bib[bk2] - ) + bk1_has_conflict = any(_CONFLICT_KEYWORDS.search(c) for c in by_bib[bk1]) + bk2_has_conflict = any(_CONFLICT_KEYWORDS.search(c) for c in by_bib[bk2]) if bk1_has_conflict and bk2_has_conflict: conflicts.append((slug, bk1, bk2)) diff --git a/tests/synthesis/test_cli.py b/tests/synthesis/test_cli.py index 7791d16..0d86145 100644 --- a/tests/synthesis/test_cli.py +++ b/tests/synthesis/test_cli.py @@ -55,9 +55,7 @@ def isolated_leads_dir(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> Path: monkeypatch.setattr("codex.cli.get_settings", lambda: settings, raising=False) monkeypatch.setattr("codex.synthesis.get_settings", lambda: settings) - monkeypatch.setattr( - "codex.config.get_settings", lambda: settings, raising=False - ) + monkeypatch.setattr("codex.config.get_settings", lambda: settings, raising=False) return leads_path diff --git a/tests/wiki/test_compile.py b/tests/wiki/test_compile.py index 02da74f..53ff8fc 100644 --- a/tests/wiki/test_compile.py +++ b/tests/wiki/test_compile.py @@ -201,9 +201,7 @@ def test_grounding_guard_last_sentence_grounded_earlier_hallucination_ignored() This test verifies that a claim whose text = the last sentence grounds correctly. """ # The last sentence of the claim text is directly grounded in the fixture chunk. - grounded_sentence = ( - "the hyperbolic volume is V = L(gamma1) + L(gamma2) + L(gamma3)" - ) + grounded_sentence = "the hyperbolic volume is V = L(gamma1) + L(gamma2) + L(gamma3)" claim = Claim( text=grounded_sentence, bibkey="Springborn2008", @@ -523,9 +521,7 @@ def test_idempotent_no_rewrite_when_unchanged( call_count = 0 original_compile = compile_concept - def counting_compile( - concept: Concept, chunks: list[Any], **kwargs: Any - ) -> ConceptPage: + def counting_compile(concept: Concept, chunks: list[Any], **kwargs: Any) -> ConceptPage: nonlocal call_count call_count += 1 return original_compile(concept, chunks, **kwargs) @@ -569,9 +565,7 @@ def test_force_all_recompiles_even_when_unchanged( call_count = 0 original_compile = compile_concept - def counting_compile( - concept: Concept, chunks: list[Any], **kwargs: Any - ) -> ConceptPage: + def counting_compile(concept: Concept, chunks: list[Any], **kwargs: Any) -> ConceptPage: nonlocal call_count call_count += 1 return original_compile(concept, chunks, **kwargs)