Ensure HTTPError.response is not None
The implementation of HTTPError
in requests
does not guarantee that
the response
property will always be set. So we need to ensure it is
not None
before looking for the return code, for example.
This also makes mypy checks pass again, as types-request
was updated
in 2.31.0.9 to better match this particular aspect. See:
https://github.com/python/typeshed/pull/10875
Merge request reports
Activity
assigned to @lunar
mentioned in merge request !507 (merged)
Jenkins job DLS/gitlab-builds #271 succeeded .
See Console Output and Coverage Report for more details.I understand that nothing prevents a HTTPError to be instantiated without response, but in practice requests really only raises HTTPError in
Response.raise_for_status
, and that always setsresponse=self
.Considering that, I'd much prefer adding specific type-checking-quiescing
assert e.response is not None
than adding cases for ae.response is None
that will never happen everywhere.Ugh, I see that this exact argument has happened in the upstream typeshed PR and that the typeshed developers went "meh, whatever, it's more correct". I stand by my point that generating a
response=None
HTTPError seems a bit bogus, even if upstream tests guarantee that you're able to do it.Jenkins job DLS/gitlab-builds #273 succeeded .
See Console Output and Coverage Report for more details.