Skip to content

Constrain Response.reason to str#7437

Merged
nateprewitt merged 1 commit into
mainfrom
reason_str
May 13, 2026
Merged

Constrain Response.reason to str#7437
nateprewitt merged 1 commit into
mainfrom
reason_str

Conversation

@nateprewitt
Copy link
Copy Markdown
Member

Similar to how we moved status_code to int to avoid needing to do None checks before doing status_code<400 comparisons, we'll do the same ignore for reason.

While reason is explicitly optional, in practice, urllib3 will always supply an empty str ('') when it's not present in the status line. This is an ergonomics change where the types may not represent all possible values, but a Response initialized by Requests will always populate the field. Anyone instantiating Responses manually will need to take considerations for their construction.

@nateprewitt nateprewitt marked this pull request as ready for review May 12, 2026 18:01
@nateprewitt nateprewitt merged commit 2144213 into main May 13, 2026
61 checks passed
@nateprewitt nateprewitt deleted the reason_str branch May 13, 2026 14:42
@nateprewitt nateprewitt mentioned this pull request May 13, 2026
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