From 6525c8c231d30d3567ba4b2a8da7b461e88e14d0 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Thu, 26 Mar 2026 10:32:19 +0100 Subject: [PATCH] Remove unused requests dependency (#6666) Co-authored-by: Claude Opus 4.6 (1M context) --- requirements.txt | 1 - requirements_tests.txt | 1 - supervisor/docker/interface.py | 18 ++++-------------- supervisor/docker/manager.py | 22 +++++----------------- supervisor/exceptions.py | 4 ---- 5 files changed, 9 insertions(+), 37 deletions(-) diff --git a/requirements.txt b/requirements.txt index bb4d7335a..24fd9c213 100644 --- a/requirements.txt +++ b/requirements.txt @@ -21,7 +21,6 @@ orjson==3.11.7 pulsectl==24.12.0 pyudev==0.24.4 PyYAML==6.0.3 -requests==2.33.0 securetar==2026.2.0 sentry-sdk==2.56.0 setuptools==82.0.1 diff --git a/requirements_tests.txt b/requirements_tests.txt index e6fe952c9..831ef8404 100644 --- a/requirements_tests.txt +++ b/requirements_tests.txt @@ -11,5 +11,4 @@ pytest==9.0.2 ruff==0.15.7 time-machine==3.2.0 types-pyyaml==6.0.12.20250915 -types-requests==2.32.4.20260324 urllib3==2.6.3 diff --git a/supervisor/docker/interface.py b/supervisor/docker/interface.py index 623895a22..038b62e7c 100644 --- a/supervisor/docker/interface.py +++ b/supervisor/docker/interface.py @@ -16,7 +16,6 @@ import aiodocker import aiohttp from awesomeversion import AwesomeVersion from awesomeversion.strategy import AwesomeVersionStrategy -import requests from ..const import ( ATTR_PASSWORD, @@ -34,7 +33,6 @@ from ..exceptions import ( DockerHubRateLimitExceeded, DockerJobError, DockerNotFound, - DockerRequestError, ) from ..jobs.const import JOB_GROUP_DOCKER_INTERFACE, JobConcurrency from ..jobs.decorator import Job @@ -328,7 +326,7 @@ class DockerInterface(JobGroup, ABC): async def exists(self) -> bool: """Return True if Docker image exists in local repository.""" - with suppress(aiodocker.DockerError, requests.RequestException): + with suppress(aiodocker.DockerError): await self.sys_docker.images.inspect(f"{self.image}:{self.version!s}") return True return False @@ -344,10 +342,6 @@ class DockerInterface(JobGroup, ABC): raise DockerAPIError( f"Docker API error occurred while getting container information: {err!s}" ) from err - except requests.RequestException as err: - raise DockerRequestError( - f"Error communicating with Docker to get container information: {err!s}" - ) from err async def is_running(self) -> bool: """Return True if Docker is running.""" @@ -368,7 +362,7 @@ class DockerInterface(JobGroup, ABC): self, version: AwesomeVersion, *, skip_state_event_if_down: bool = False ) -> None: """Attach to running Docker container.""" - with suppress(aiodocker.DockerError, requests.RequestException): + with suppress(aiodocker.DockerError): docker_container = await self.sys_docker.containers.get(self.name) self._meta = await docker_container.show() self.sys_docker.monitor.watch_container(self._meta) @@ -386,7 +380,7 @@ class DockerInterface(JobGroup, ABC): ), ) - with suppress(aiodocker.DockerError, requests.RequestException): + with suppress(aiodocker.DockerError): if not self._meta and self.image: self._meta = await self.sys_docker.images.inspect( f"{self.image}:{version!s}" @@ -489,7 +483,7 @@ class DockerInterface(JobGroup, ABC): if self.image == expected_image: try: image = await self.sys_docker.images.inspect(image_name) - except (aiodocker.DockerError, requests.RequestException) as err: + except aiodocker.DockerError as err: raise DockerError( f"Could not get {image_name} for check due to: {err!s}", _LOGGER.error, @@ -612,10 +606,6 @@ class DockerInterface(JobGroup, ABC): raise DockerNotFound( f"No version found for {self.image}", _LOGGER.info ) from err - except requests.RequestException as err: - raise DockerRequestError( - f"Communication issues with dockerd on Host: {err}", _LOGGER.warning - ) from err _LOGGER.info("Found %s versions: %s", self.image, available_version) diff --git a/supervisor/docker/manager.py b/supervisor/docker/manager.py index 347914261..bcd78c5e7 100644 --- a/supervisor/docker/manager.py +++ b/supervisor/docker/manager.py @@ -23,7 +23,6 @@ from aiodocker.stream import Stream from aiodocker.types import JSONObject from aiohttp import ClientTimeout, UnixConnector from awesomeversion import AwesomeVersion, AwesomeVersionCompareException -import requests from ..const import ( ATTR_ENABLE_IPV6, @@ -44,7 +43,6 @@ from ..exceptions import ( DockerError, DockerNoSpaceOnDevice, DockerNotFound, - DockerRequestError, ) from ..utils.common import FileConfiguration from ..validate import SCHEMA_DOCKER_CONFIG @@ -589,12 +587,6 @@ class DockerAPI(CoreSysAttributes): raise DockerAPIError( f"Can't start {name or container.id}: {err}", _LOGGER.error ) from err - except requests.RequestException as err: - raise DockerRequestError( - f"Dockerd connection issue for {name or container.id}: {err}", - _LOGGER.error, - ) from err - return container async def run( @@ -610,10 +602,6 @@ class DockerAPI(CoreSysAttributes): raise DockerAPIError( f"Can't inspect started container {name}: {err}", _LOGGER.error ) from err - except requests.RequestException as err: - raise DockerRequestError( - f"Dockerd connection issue for {name}: {err}", _LOGGER.error - ) from err return container_attrs @@ -992,7 +980,7 @@ class DockerAPI(CoreSysAttributes): if err.status != HTTPStatus.NOT_FOUND: raise - except (aiodocker.DockerError, requests.RequestException) as err: + except aiodocker.DockerError as err: raise DockerError( f"Can't remove image {image}: {err}", _LOGGER.warning ) from err @@ -1041,7 +1029,7 @@ class DockerAPI(CoreSysAttributes): try: return await self.images.inspect(docker_image_list[0]) - except (aiodocker.DockerError, requests.RequestException) as err: + except aiodocker.DockerError as err: raise DockerError( f"Could not inspect imported image due to: {err!s}", _LOGGER.error ) from err @@ -1095,7 +1083,7 @@ class DockerAPI(CoreSysAttributes): f"{current_image} not found for cleanup", _LOGGER.warning ) from None raise - except (aiodocker.DockerError, requests.RequestException) as err: + except aiodocker.DockerError as err: raise DockerError( f"Can't get {current_image} for cleanup", _LOGGER.warning ) from err @@ -1129,7 +1117,7 @@ class DockerAPI(CoreSysAttributes): images_list = await self.images.list( filters=json.dumps({"reference": image_names}) ) - except (aiodocker.DockerError, requests.RequestException) as err: + except aiodocker.DockerError as err: raise DockerError( f"Corrupt docker overlayfs found: {err}", _LOGGER.warning ) from err @@ -1138,6 +1126,6 @@ class DockerAPI(CoreSysAttributes): if docker_image["Id"] in keep: continue - with suppress(aiodocker.DockerError, requests.RequestException): + with suppress(aiodocker.DockerError): _LOGGER.info("Cleanup images: %s", docker_image["RepoTags"]) await self.images.delete(docker_image["Id"], force=True) diff --git a/supervisor/exceptions.py b/supervisor/exceptions.py index 2eba44292..ac28af47b 100644 --- a/supervisor/exceptions.py +++ b/supervisor/exceptions.py @@ -859,10 +859,6 @@ class DockerAPIError(DockerError): """Docker API error.""" -class DockerRequestError(DockerError): - """Dockerd OS issues.""" - - class DockerTrustError(DockerError): """Raise if images are not trusted."""