Skip to content

Commit c28166b

Browse files
committed
fix: resolve mypy errors, missing redaction imports, and Supply Chain action version
- db_doctor.py: narrow type-ignore to import-untyped, annotate failures list properly - preflight.py: guard against None before int() in _parse_compose_port - routes.py: import _is_secret_field and _contains_private_pem from redaction module (fallback code referenced them but they were never imported, causing NameError) - ci.yaml: pin trivy-action to @0.29.0 (0.30.0 does not exist) - Reformat emitter.py, db_doctor.py, preflight.py with black Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AhwicpfSvKesuRxBHs9sQ2
1 parent 3deebfe commit c28166b

5 files changed

Lines changed: 20 additions & 18 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ jobs:
223223
path: sbom.spdx.json
224224

225225
- name: Vulnerability scan
226-
uses: aquasecurity/trivy-action@0.30.0
226+
uses: aquasecurity/trivy-action@0.29.0
227227
with:
228228
scan-type: fs
229229
scan-ref: .

netengine/api/routes.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@
2323
from netengine.events.queues import PRIMARY_QUEUES, Queue, dlq_for
2424
from netengine.logging import get_logger
2525
from netengine.phase_labels import PHASE_LABELS
26-
from netengine.security.redaction import redact_for_api, redact_for_support_bundle
26+
from netengine.security.redaction import (
27+
_contains_private_pem,
28+
_is_secret_field,
29+
redact_for_api,
30+
redact_for_support_bundle,
31+
)
2732
from netengine.spec.loader import SpecLoadError, load_spec
2833
from netengine.spec.models import SPEC_SCHEMA_VERSION, NetEngineSpec
2934

netengine/diagnostic/db_doctor.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def _queue_name(row: object) -> str | None:
6969

7070
async def _inspect_database(db_url: str, *, timeout: float) -> list[DoctorCheckResult]:
7171
try:
72-
import asyncpg # type: ignore[import]
72+
import asyncpg # type: ignore[import-untyped]
7373
except ImportError:
7474
return [
7575
DoctorCheckResult(
@@ -164,9 +164,7 @@ async def _inspect_database(db_url: str, *, timeout: float) -> list[DoctorCheckR
164164
await conn.close()
165165

166166

167-
def check_database(
168-
db_url: str | None, *, timeout: float = 3.0
169-
) -> list[DoctorCheckResult]:
167+
def check_database(db_url: str | None, *, timeout: float = 3.0) -> list[DoctorCheckResult]:
170168
"""Return actionable doctor checks for Postgres, pgmq, and event queues."""
171169
checks = [parsed := _parse_db_url(db_url)]
172170
if not db_url or parsed.status != DoctorStatus.OK:
@@ -201,7 +199,7 @@ def check_pgmq_runtime_state(state_file: Path) -> DoctorCheckResult:
201199
required=False,
202200
)
203201

204-
failures: list[dict] = data.get("event_send_failures") or []
202+
failures: list[dict[str, object]] = data.get("event_send_failures") or []
205203
disabled_drops = [f for f in failures if f.get("queue") == _PGMQ_DISABLED_QUEUE]
206204
if disabled_drops:
207205
return DoctorCheckResult(

netengine/diagnostic/preflight.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ def _parse_compose_port(raw_port: object) -> tuple[int, str] | None:
119119
if isinstance(raw_port, dict):
120120
published = raw_port.get("published") or raw_port.get("target")
121121
proto = str(raw_port.get("protocol") or "tcp").lower()
122+
if published is None:
123+
return None
122124
try:
123125
return int(published), proto
124126
except (TypeError, ValueError):
@@ -330,9 +332,7 @@ def _can_bind(port: int, proto: str) -> bool:
330332

331333
def _check_port(port: int, proto: str) -> DoctorCheckResult:
332334
name = f"port:{port}/{proto}"
333-
label = next(
334-
(p.label for p in KNOWN_LOCAL_PORTS if p.port == port and p.proto == proto), None
335-
)
335+
label = next((p.label for p in KNOWN_LOCAL_PORTS if p.port == port and p.proto == proto), None)
336336
detail_suffix = f" ({label})" if label else ""
337337
try:
338338
_can_bind(port, proto)
@@ -479,20 +479,20 @@ def _check_docker_conflicts(ctx: DoctorContext) -> list[DoctorCheckResult]:
479479
(
480480
DoctorStatus.FAIL
481481
if kind == "container" and conflicts
482-
else DoctorStatus.WARN
483-
if conflicts
484-
else DoctorStatus.OK
482+
else DoctorStatus.WARN if conflicts else DoctorStatus.OK
485483
),
486484
", ".join(conflicts) if conflicts else "no known name conflicts",
487485
(
488486
"Stop/remove conflicting containers before startup."
489487
if kind == "container" and conflicts
490488
else (
491-
"Run `netengine down` or remove stale Docker resources if these "
492-
"belong to an old run."
489+
(
490+
"Run `netengine down` or remove stale Docker resources if these "
491+
"belong to an old run."
492+
)
493+
if conflicts
494+
else None
493495
)
494-
if conflicts
495-
else None
496496
),
497497
"docker",
498498
required=kind == "container",

netengine/events/emitter.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from netengine.events.schema import EventEnvelope
1010
from netengine.handlers.context import PhaseContext
1111

12-
1312
_PGMQ_DISABLED_QUEUE = "<pgmq_disabled>"
1413

1514

0 commit comments

Comments
 (0)