Skip to content

Narrow handshake_status with isinstance instead of int() coercion#158

Merged
alexkroman merged 2 commits into
mainfrom
claude/pydantic-code-quality-cpld8n
Jun 13, 2026
Merged

Narrow handshake_status with isinstance instead of int() coercion#158
alexkroman merged 2 commits into
mainfrom
claude/pydantic-code-quality-cpld8n

Conversation

@alexkroman

Copy link
Copy Markdown
Collaborator

getattr returns an untyped value off an arbitrary exception, so the prior
int(code)/int(status) coercion would raise on a non-numeric .code rather than
falling through to None. Guard each membership test with isinstance(..., int)
so the value is provably an int before returning it, dropping the redundant
int() call. Adds a non-auth (500) response-shape assertion to pin that only
401/403 qualify on either shape.

claude and others added 2 commits June 13, 2026 20:52
getattr returns an untyped value off an arbitrary exception, so the prior
int(code)/int(status) coercion would raise on a non-numeric .code rather than
falling through to None. Guard each membership test with isinstance(..., int)
so the value is provably an int before returning it, dropping the redundant
int() call. Adds a non-auth (500) response-shape assertion to pin that only
401/403 qualify on either shape.
@alexkroman alexkroman enabled auto-merge June 13, 2026 20:52
@alexkroman alexkroman added this pull request to the merge queue Jun 13, 2026
Merged via the queue into main with commit f00e2a9 Jun 13, 2026
16 checks passed
@alexkroman alexkroman deleted the claude/pydantic-code-quality-cpld8n branch June 13, 2026 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants