Skip to content

Commit 21ada1d

Browse files
satraclaude
andcommitted
fix(041): lint fixes — ruff format backend, line length compliance
T051: All ruff check + format passes for library/ and backend/. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 2eac2a3 commit 21ada1d

5 files changed

Lines changed: 24 additions & 28 deletions

File tree

backend/src/auth/dependencies.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ def _check(user: dict | None) -> dict:
147147
raise HTTPException(
148148
status_code=403,
149149
detail=(
150-
f"Role '{role}' required. "
151-
f"Your roles: {user.get('realm_access', {}).get('roles', [])}"
152-
),
150+
f"Role '{role}' required. "
151+
f"Your roles: {user.get('realm_access', {}).get('roles', [])}"
152+
),
153153
)
154154
return user
155155

backend/src/graphql/resolvers.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -410,18 +410,19 @@ async def resolve_search(
410410
)
411411
sem_result = await session.execute(
412412
sem_stmt,
413-
{"qvec": str(query_vec if isinstance(query_vec, list) else query_vec.tolist()), "lim": first},
413+
{
414+
"qvec": str(
415+
query_vec if isinstance(query_vec, list) else query_vec.tolist()
416+
),
417+
"lim": first,
418+
},
414419
)
415420
for row in sem_result:
416421
sim = round(float(row.similarity), 4)
417422
sem_scores[row.sha256] = sim
418423
if row.sha256 in seen_sha:
419424
continue # Will update score below
420-
prov = (
421-
(row.provenance or [{}])[0]
422-
if row.provenance
423-
else {}
424-
)
425+
prov = (row.provenance or [{}])[0] if row.provenance else {}
425426
results.append(
426427
t.SearchResultType(
427428
entity_type=etype,
@@ -431,8 +432,7 @@ async def resolve_search(
431432
row.file_name or row.sha256[:12],
432433
),
433434
source=prov.get("source"),
434-
description=row.description
435-
or prov.get("description", ""),
435+
description=row.description or prov.get("description", ""),
436436
score=sim,
437437
)
438438
)
@@ -471,12 +471,14 @@ async def resolve_search(
471471
)
472472
)
473473
if existing.scalar_one_or_none() is None:
474-
session.add(AlignmentCandidate(
475-
entity_a=sha_a,
476-
entity_b=sha_b,
477-
similarity=min(a.score, b.score),
478-
source="search",
479-
))
474+
session.add(
475+
AlignmentCandidate(
476+
entity_a=sha_a,
477+
entity_b=sha_b,
478+
similarity=min(a.score, b.score),
479+
source="search",
480+
)
481+
)
480482
await session.flush()
481483
except Exception as exc:
482484
logger.debug("Failed to record alignment candidates: %s", exc)
@@ -1585,9 +1587,7 @@ async def resolve_ontology_store_info(session: AsyncSession) -> list[dict]:
15851587
from src.db.models import OntologySource
15861588

15871589
stmt = (
1588-
select(OntologySource)
1589-
.where(OntologySource.active.is_(True))
1590-
.order_by(OntologySource.name)
1590+
select(OntologySource).where(OntologySource.active.is_(True)).order_by(OntologySource.name)
15911591
)
15921592
rows = (await session.execute(stmt)).scalars().all()
15931593
return [

backend/src/services/chat_service.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ def _get_model() -> str:
4949
"function": {
5050
"name": "lookup_ontology_term",
5151
"description": (
52-
"Search the ontology store for a term."
53-
" Use this instead of guessing URIs."
52+
"Search the ontology store for a term. Use this instead of guessing URIs."
5453
),
5554
"parameters": {
5655
"type": "object",
@@ -162,9 +161,7 @@ async def chat_completion(
162161
system = SYSTEM_PROMPT
163162
if entity_context:
164163
ctx = json.dumps(entity_context, indent=2, default=str)
165-
system += (
166-
f"\n\nCurrent entity context:\n```json\n{ctx}\n```"
167-
)
164+
system += f"\n\nCurrent entity context:\n```json\n{ctx}\n```"
168165

169166
full_messages = [{"role": "system", "content": system}] + messages
170167

backend/src/tools/enrichment_tools.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@
114114
"adapter_type": {
115115
"type": "string",
116116
"description": (
117-
"Adapter to use (bids, dandi,"
118-
" reproschema, csv, json-schema)"
117+
"Adapter to use (bids, dandi, reproschema, csv, json-schema)"
119118
),
120119
},
121120
},

specs/041-cross-source-alignment/tasks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
- [ ] T048 Run full pipeline across all 8 sources with alignment enabled — record entity counts before/after alignment in eval-record.md per constitution
131131
- [ ] T049 Verify alignment report: confirm known cross-source pairs (age↔interview_age, sex↔gender) aligned; confirm no false merges for entities with different ranges
132132
- [ ] T050 Performance validation: time full alignment of registry and verify <30 minutes; document in eval-record.md
133-
- [ ] T051 Fix any ruff lint/format issues across all modified files — run `uv run ruff check --fix` and `uv run ruff format` in library/ and backend/
133+
- [X] T051 Fix any ruff lint/format issues across all modified files — run `uv run ruff check --fix` and `uv run ruff format` in library/ and backend/
134134
- [ ] T052 Verify frontend builds cleanly — run `pnpm lint && pnpm build` in frontend/
135135
- [X] T053 Update library/src/undata_library/cli.py pipeline command to include alignment as default post-commit step — `pipeline --source X` runs extract→enrich→commit→align→transform
136136

0 commit comments

Comments
 (0)