diff --git a/abi3audit/_extract.py b/abi3audit/_extract.py index fb58918..6219507 100644 --- a/abi3audit/_extract.py +++ b/abi3audit/_extract.py @@ -18,6 +18,7 @@ from packaging.tags import Tag import abi3audit._object as _object +from abi3audit import __version__ from abi3audit._cache import caching_session from abi3audit._state import console, status @@ -216,14 +217,15 @@ def __init__(self, spec: PyPISpec) -> None: self.spec = spec self.parent = None self._session = caching_session() + self._session.headers.update( + {"Accept-Encoding": "gzip", "User-Agent": f"abi3audit/{__version__}"} + ) def __iter__(self) -> Iterator[_object.SharedObject]: status.update(f"{self}: querying PyPI") # TODO: Error handling for this request. - resp = self._session.get( - f"https://pypi.org/pypi/{self.spec}/json", headers={"Accept-Encoding": "gzip"} - ) + resp = self._session.get(f"https://pypi.org/pypi/{self.spec}/json") if not resp.ok: console.log(f"[red]:skull: {self}: PyPI returned {resp.status_code}")