Fix CI lint failures so build-push can run and push an image
ruff: drop stale SLF001 noqa, wrap json.load in a context manager (SIM115), remove unused imports + placeholder-less f-strings; ignore PLR0912/PLR0915 for one-off scripts. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
1fc83dcac9
commit
cf747d3efe
3 changed files with 10 additions and 6 deletions
|
|
@ -82,7 +82,7 @@ def _truncate_sample(payload: Any) -> dict[str, Any] | None:
|
||||||
|
|
||||||
async def _check_token(client: TracksolidClient, *, parser_version: str) -> None:
|
async def _check_token(client: TracksolidClient, *, parser_version: str) -> None:
|
||||||
try:
|
try:
|
||||||
await client._ensure_token() # noqa: SLF001 — intentional probe
|
await client._ensure_token() # intentional probe of the token endpoint
|
||||||
except (TracksolidError, httpx.HTTPError) as exc:
|
except (TracksolidError, httpx.HTTPError) as exc:
|
||||||
await _record(
|
await _record(
|
||||||
endpoint=TOKEN_METHOD,
|
endpoint=TOKEN_METHOD,
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,9 @@ ignore = ["PLR0913", "PLR2004"]
|
||||||
|
|
||||||
[tool.ruff.lint.per-file-ignores]
|
[tool.ruff.lint.per-file-ignores]
|
||||||
"tests/*" = ["PLR0913", "PLR2004"]
|
"tests/*" = ["PLR0913", "PLR2004"]
|
||||||
|
# One-off operational/analysis scripts: allow the long, branchy simulation
|
||||||
|
# routines that mirror the SQL trip state machine.
|
||||||
|
"scripts/*" = ["PLR0912", "PLR0915"]
|
||||||
|
|
||||||
[tool.mypy]
|
[tool.mypy]
|
||||||
python_version = "3.12"
|
python_version = "3.12"
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@ from __future__ import annotations
|
||||||
import json
|
import json
|
||||||
import math
|
import math
|
||||||
import sys
|
import sys
|
||||||
from collections import Counter, defaultdict
|
from collections import defaultdict
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
|
@ -205,19 +205,20 @@ def legacy_summary(rows: list[dict[str, Any]]) -> dict[str, Any]:
|
||||||
|
|
||||||
|
|
||||||
def main(path: str) -> None:
|
def main(path: str) -> None:
|
||||||
rows = json.load(open(path))
|
with open(path) as f:
|
||||||
|
rows = json.load(f)
|
||||||
print(f"\n=== {path} ===")
|
print(f"\n=== {path} ===")
|
||||||
print(f"raw rows: {len(rows)}")
|
print(f"raw rows: {len(rows)}")
|
||||||
|
|
||||||
leg = legacy_summary(rows)
|
leg = legacy_summary(rows)
|
||||||
print(f"\n-- LEGACY --")
|
print("\n-- LEGACY --")
|
||||||
print(f"trips: {len(leg['trips'])} (plus {leg['n_stationary_rows']} stationary-bucket rows)")
|
print(f"trips: {len(leg['trips'])} (plus {leg['n_stationary_rows']} stationary-bucket rows)")
|
||||||
for tid, t0, t1, n in leg["trips"]:
|
for tid, t0, t1, n in leg["trips"]:
|
||||||
dur = (t1 - t0).total_seconds() / 60
|
dur = (t1 - t0).total_seconds() / 60
|
||||||
print(f" trip {tid}: {t0:%H:%M:%S} → {t1:%H:%M:%S} ({dur:.0f} min, {n} fixes)")
|
print(f" trip {tid}: {t0:%H:%M:%S} → {t1:%H:%M:%S} ({dur:.0f} min, {n} fixes)")
|
||||||
|
|
||||||
sim = simulate(rows)
|
sim = simulate(rows)
|
||||||
print(f"\n-- NEW ALGO (5min stop, 30min gap, 5 km/h stationary) --")
|
print("\n-- NEW ALGO (5min stop, 30min gap, 5 km/h stationary) --")
|
||||||
rep = sim["reporting_time"]
|
rep = sim["reporting_time"]
|
||||||
print(f"reporting_time: {rep.isoformat() if rep else 'none'}")
|
print(f"reporting_time: {rep.isoformat() if rep else 'none'}")
|
||||||
print(f"day totals: distance={sim['total_distance_km']} km, "
|
print(f"day totals: distance={sim['total_distance_km']} km, "
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue