Skip to content

docs: document exceptions raised by request()#7356

Open
DORI2001 wants to merge 1 commit intopsf:mainfrom
DORI2001:docs/document-request-exceptions
Open

docs: document exceptions raised by request()#7356
DORI2001 wants to merge 1 commit intopsf:mainfrom
DORI2001:docs/document-request-exceptions

Conversation

@DORI2001
Copy link
Copy Markdown

Closes #6653

Summary

Adds :raises: RST docstring entries to the request() function documenting the exceptions that callers should be prepared to handle.

The documentation is added only on the main request() function (not repeated on each convenience method like get(), post(), etc.) to avoid duplication — all convenience methods delegate to request() and can raise the same exceptions.

Exceptions documented

Exception When raised
ConnectionError Network problem (DNS failure, refused connection, etc.)
Timeout Request timed out (wraps ConnectTimeout and ReadTimeout)
TooManyRedirects Configured redirect limit exceeded
URLRequired No URL provided
MissingSchema URL has no scheme (e.g. missing http://)
InvalidSchema URL scheme is invalid or unsupported
InvalidURL URL is otherwise malformed
InvalidHeader A header value is invalid

These match the exceptions listed in the Requests exceptions API docs that are relevant to the request() call itself (as opposed to exceptions from response processing like JSONDecodeError).

Adds :raises: entries to the request() docstring listing the exceptions
that can be raised, as requested in psf#6653.

The exceptions are documented on the main request() function only to avoid
duplication across the convenience methods (get, post, put, etc.) that all
delegate to request().

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@DORI2001
Copy link
Copy Markdown
Author

Hi! Just checking in on this PR — happy to make any changes if needed. Thanks!

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.

Document which exceptions request() might raise

1 participant