Skip to content

Commit eb9ea94

Browse files
nficanoclaude
andcommitted
refactor phase 6: TRY003 narrow ignore; per-line TRY301 exception
The ARCPError exception class already carries typed structure (a `code: ErrorCode` enum field plus a `details: dict`); the human-readable message is intentionally a free-form string, not a per-error subclass. TRY003 ("avoid long messages outside the exception class") doesn't fit this design, so add it as a narrow project-level ignore with the rationale captured inline. The same justification covers TransportClosed ("transport is closed", "websocket closed", etc.) and the two pydantic field-validator ValueErrors in envelope.py. For TRY301 in runtime.server cancel-handler: the raise-inside-try is deliberate so a single except clause normalizes both validation-thrown and explicit-raised ARCPError into one cancel.refused envelope. Add a per-line noqa with the reason. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 4bfa618 commit eb9ea94

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ select = [
7373
]
7474
ignore = [
7575
"E501", # line-too-long: handled by ruff format; surfaced cases are pydantic Field descriptions.
76+
# TRY003: raise-vanilla-args. The ARCPError exception class already carries
77+
# typed structure (`code: ErrorCode`, `details: dict`); the message string
78+
# is the human-readable explanation. Splitting one subclass per message
79+
# would add code without adding type structure. Same applies to
80+
# TransportClosed and the two pydantic field-validator ValueErrors.
81+
"TRY003",
7682
]
7783

7884
[tool.ruff.lint.per-file-ignores]

src/arcp/runtime/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ async def _handle_cancel(rt: ARCPRuntime, state: SessionState, env: Envelope) ->
217217
)
218218
await rt._send(state, accepted)
219219
else:
220-
raise ARCPError(
220+
raise ARCPError( # noqa: TRY301 — raise inside try is deliberate; the except below converts validation errors into a cancel.refused envelope alongside other ARCPError sources.
221221
ErrorCode.UNIMPLEMENTED,
222222
f"cancel target {payload.target!r} not supported in v0.1",
223223
)

0 commit comments

Comments
 (0)