diff --git a/CHANGELOG.md b/CHANGELOG.md index aacc7d943..ab9c0b3b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,8 @@ ## Ongoing -- Add PEP 740 digital attestations (workaround until included in `uv publish`) -- Pin GitHub acions including our own from gh-actions +- Add PEP 740 digital attestations (workaround until included in `uv publish`), pin GitHub acions including our own from gh-actions, via PR [#891](https://github.com/plugwise/python-plugwise/pull/891) +- Solve aiohttp BasicAuth deprecation via PR [#890](https://github.com/plugwise/python-plugwise/pull/890) ## v1.12.0 diff --git a/plugwise/smilecomm.py b/plugwise/smilecomm.py index 61617a7e4..7d3425587 100644 --- a/plugwise/smilecomm.py +++ b/plugwise/smilecomm.py @@ -15,7 +15,13 @@ from plugwise.util import escape_illegal_xml_characters # This way of importing aiohttp is because of patch/mocking in testing (aiohttp timeouts) -from aiohttp import BasicAuth, ClientError, ClientResponse, ClientSession, ClientTimeout +from aiohttp import ( + ClientError, + ClientResponse, + ClientSession, + ClientTimeout, + encode_basic_auth, +) from defusedxml import ElementTree as etree @@ -42,7 +48,9 @@ def __init__( if host.count(":") > 2: # pragma: no cover host = f"[{host}]" - self._auth = BasicAuth(username, password=password) + self._base_header = { + "Authorization": encode_basic_auth(username, password=password) + } self._endpoint = f"http://{host}:{str(port)}" # Sensitive async def _request( @@ -58,28 +66,24 @@ async def _request( try: match method: case "delete": - resp = await self._websession.delete(url, auth=self._auth) + resp = await self._websession.delete(url, headers=self._base_header) case "get": # Work-around for Stretchv2, should not hurt the other smiles - headers = {"Accept-Encoding": "gzip"} - resp = await self._websession.get( - url, headers=headers, auth=self._auth - ) + headers = {**self._base_header, "Accept-Encoding": "gzip"} + resp = await self._websession.get(url, headers=headers) case "post": - headers = {"Content-type": "text/xml"} + headers = {**self._base_header, "Content-type": "text/xml"} resp = await self._websession.post( url, headers=headers, data=data, - auth=self._auth, ) case "put": - headers = {"Content-type": "text/xml"} + headers = {**self._base_header, "Content-type": "text/xml"} resp = await self._websession.put( url, headers=headers, data=data, - auth=self._auth, ) except ( ClientError diff --git a/pyproject.toml b/pyproject.toml index 997b1731c..c4b0ded55 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,7 +27,7 @@ maintainers = [ requires-python = ">=3.13" dependencies = [ "aiofiles", - "aiohttp", + "aiohttp>=3.14", "defusedxml", "munch", "python-dateutil",