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
This commit is contained in:
Jérémy Bobbio (Lunar) 2023-10-18 10:14:55 +02:00
parent 968ddef295
commit 7344d264e7
7 changed files with 8 additions and 2 deletions

View file

@ -125,6 +125,7 @@ class GitwebLister(StatelessLister[Repositories]):
try:
bs = self._get_and_parse(repository_url)
except HTTPError as e:
assert e.response is not None
logger.warning(
"Unexpected HTTP status code %s on %s",
e.response.status_code,