-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typing of requests.HTTPError possibly too strict #10764
Comments
`requests` itself allows a `None` type for `Response`; it will internally attempt to read it from the `request` passed. Fixes python#10764
`requests` itself allows a `None` type for `Response`; it will internally attempt to read it from the `request` passed. There is thus no strict guarantee that a `HTTPError` will have a truthy `request`. Fixes python#10764
It looks like the type of
|
I still get an error like this in 2.31.0.6, is that intended?
the argument is indeed missing, but isn't that valid? |
#10776 made only the request optional. If the response should also be optional, we'd need a PR to be able to judge the impact. |
Some more discussion about |
This should be fixed in the latest version of |
Recent contributions #8989 and #10740 improved the typing of
requests.HTTPError
, so now we have:typeshed/stubs/requests/requests/exceptions.pyi
Lines 13 to 16 in 5b8193b
This is causing issues in our code as it appears to be incompatible to the way requests itself is using the type:
Now the
request
argument is mandatory. However, requests itself does not do it this way, e.g. see the implementation ofResponse.raise_for_status
:Secondly, the type is now restricted to be
Request
. In particular this prevents assigning aPreparedRequest
(which is not derived fromRequest
). However, this is exactly what requests is doing inRequestException.__init__
, in addition to explicitly allowing not to pass arequest
argument:Please reconsider the strict typing.
@JelleZijlstra @srittau
The text was updated successfully, but these errors were encountered: