-
-
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
[requests] Improve exception class constructors #10740
[requests] Improve exception class constructors #10740
Conversation
eff7274
to
56db738
Compare
This comment has been minimized.
This comment has been minimized.
Should we make the arguments also optional on HTTPError? |
Diff from mypy_primer, showing the effect of this PR on open source code: cloud-init (https://github.com/canonical/cloud-init)
+ tests/unittests/sources/azure/test_errors.py:169: error: Missing named argument "request" for "HTTPError" [call-arg]
+ tests/unittests/sources/azure/test_errors.py:169: error: Missing named argument "response" for "HTTPError" [call-arg]
+ tests/unittests/sources/azure/test_imds.py:64: error: Missing named argument "request" for "HTTPError" [call-arg]
+ tests/unittests/sources/test_azure.py:343: error: Missing named argument "request" for "HTTPError" [call-arg]
paasta (https://github.com/yelp/paasta)
+ paasta_tools/mesos_maintenance.py:213: error: Missing named argument "request" for "HTTPError" [call-arg]
+ paasta_tools/mesos_maintenance.py:213: error: Missing named argument "response" for "HTTPError" [call-arg]
apprise (https://github.com/caronc/apprise)
+ test/helpers/rest.py:63: error: Missing named argument "request" for "HTTPError" [call-arg]
+ test/helpers/rest.py:63: error: Missing named argument "response" for "HTTPError" [call-arg]
+ test/test_attach_http.py:59: error: Missing named argument "request" for "HTTPError" [call-arg]
+ test/test_attach_http.py:59: error: Missing named argument "response" for "HTTPError" [call-arg]
+ test/test_config_http.py:54: error: Missing named argument "request" for "HTTPError" [call-arg]
+ test/test_config_http.py:54: error: Missing named argument "response" for "HTTPError" [call-arg]
|
Why add |
#8989 created an assumption that class HTTPError(RequestException):
request: Request # <-- can't be None
response: Response # <-- can't be None That assumption is true for errors originating from Relaxing |
It's a tradeoff. The primer output is a bit concerning, although most of the problems seem to be in test code. I'm fine with this change, despite the primer output. Otherwise we should revert the |
Somewhat related to #8989.
Relevant code: https://requests.readthedocs.io/en/latest/_modules/requests/exceptions/#RequestException