[requests] Allow "connect" timeout to be None in timeout configuration tuple#14700
Merged
Conversation
Individual values of the timeout configuration tuple (connect timeout, read timeout) can be set to None, making the timeout indefinite.
Contributor
|
Diff from mypy_primer, showing the effect of this PR on open source code: discord.py (https://github.com/Rapptz/discord.py)
- discord/ext/commands/hybrid.py:508: error: Overlap between argument names and ** TypedDict items: "description", "name" [misc]
+ discord/ext/commands/hybrid.py:508: error: Overlap between argument names and ** TypedDict items: "name", "description" [misc]
- discord/ext/commands/hybrid.py:629: error: Overlap between argument names and ** TypedDict items: "name", "description" [misc]
+ discord/ext/commands/hybrid.py:629: error: Overlap between argument names and ** TypedDict items: "description", "name" [misc]
|
brianschubert
approved these changes
Sep 12, 2025
Collaborator
brianschubert
left a comment
There was a problem hiding this comment.
Following the calls, None does seem to be accepted in the first tuple entry:
- https://github.com/psf/requests/blob/v2.32.4/src/requests/adapters.py#L652-L664
- https://github.com/urllib3/urllib3/blob/4dad8713f127d0b9b63ecb30712de2847c39df42/src/urllib3/util/timeout.py#L66-L84
And it works at runtime:
uv run -w 'requests==2.32.4' python -c 'import requests; r = requests.get("https://example.com", timeout=(None, 1)); print(r.status_code)'
200I don't see anything contrary in the docs or in the original PR discussion (#7696).
So, LGTM! Thanks!
None values in timeout configuration tupleNone in timeout configuration tuple
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Individual values of the timeout configuration tuple (connect timeout, read timeout) can be set to
None, making the timeout indefinite.Previously, only the
readtimeout could be set toNone.