From a3dc1fd36089d1decffb14142f4cd29cdc6289d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A6rkeren?= <164513459+Faerkeren@users.noreply.github.com> Date: Wed, 27 May 2026 10:16:30 -0100 Subject: [PATCH] refactor: remove unused SharedSession helper (#77) SharedSession was never imported or instantiated by production code or tests. Session ownership is handled directly by AiohttpRestAdapter and AiohttpWebSocketAdapter, so the helper served no runtime purpose and was the sole reason config.py needed to import aiohttp. Delete the class, drop the now-unused aiohttp import, and tighten the module docstring accordingly. --- src/haclient/config.py | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/src/haclient/config.py b/src/haclient/config.py index 515007a..cc87984 100644 --- a/src/haclient/config.py +++ b/src/haclient/config.py @@ -1,8 +1,8 @@ """Configuration objects for `HAClient`. -The connection settings, URL handling, and aiohttp session ownership are -captured in `ConnectionConfig`. This isolates configuration parsing from -the rest of the package and keeps `HAClient.__init__` boring. +The connection settings and URL handling are captured in +`ConnectionConfig`. This isolates configuration parsing from the rest of +the package and keeps `HAClient.__init__` boring. """ from __future__ import annotations @@ -11,8 +11,6 @@ from typing import Literal from urllib.parse import urlparse, urlunparse -import aiohttp - ServicePolicy = Literal["ws", "rest", "auto"] """How `ServiceCaller` should choose between WebSocket and REST. @@ -126,25 +124,3 @@ def from_url( verify_ssl=verify_ssl, service_policy=service_policy, ) - - -class SharedSession: - """Holder for an optional shared `aiohttp.ClientSession`. - - Both REST and WebSocket adapters can use the same session instance, - which is the recommended pattern for users who already manage their - own ``aiohttp.ClientSession``. When no session is provided here, each - adapter creates and owns its own. - """ - - def __init__(self, session: aiohttp.ClientSession | None = None) -> None: - """Wrap *session* and record whether it was externally owned. - - Parameters - ---------- - session : aiohttp.ClientSession or None, optional - Pre-existing session to share between transports. ``None`` - leaves each adapter to manage its own session. - """ - self.session = session - self.shared = session is not None