From 93e674690f33c4ba1fdfec6ca2f641100cd83f8d Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Tue, 28 Jul 2026 18:21:08 +0000 Subject: [PATCH 1/5] Bump for ruff/mypy --- airos/base.py | 2 ++ airos/discovery.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/airos/base.py b/airos/base.py index de2eee3..f206886 100644 --- a/airos/base.py +++ b/airos/base.py @@ -50,6 +50,7 @@ def __init__( username: str, password: str, session: aiohttp.ClientSession, + *, use_ssl: bool = True, ): """Initialize AirOS class.""" @@ -262,6 +263,7 @@ async def _request_json( self, method: str, url: str, + *, headers: dict[str, Any] | None = None, json_data: dict[str, Any] | None = None, form_data: dict[str, Any] | None = None, diff --git a/airos/discovery.py b/airos/discovery.py index dd0a6ad..790e847 100644 --- a/airos/discovery.py +++ b/airos/discovery.py @@ -82,7 +82,7 @@ def connection_lost(self, exc: Exception | None) -> None: """Handle connection is lost or closed.""" _LOGGER.debug("AirOSDiscoveryProtocol connection lost.") if exc: - _LOGGER.exception("AirOSDiscoveryProtocol connection lost due to") + _LOGGER.error("AirOSDiscoveryProtocol connection lost due to") raise AirOSDiscoveryError from None def parse_airos_packet(self, data: bytes, host_ip: str) -> dict[str, Any] | None: From ba9d0e93936b999945660c2a03a6e64d208cf894 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Tue, 28 Jul 2026 18:24:38 +0000 Subject: [PATCH 2/5] Bump for ruff/mypy --- airos/discovery.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airos/discovery.py b/airos/discovery.py index 790e847..cd06352 100644 --- a/airos/discovery.py +++ b/airos/discovery.py @@ -82,7 +82,7 @@ def connection_lost(self, exc: Exception | None) -> None: """Handle connection is lost or closed.""" _LOGGER.debug("AirOSDiscoveryProtocol connection lost.") if exc: - _LOGGER.error("AirOSDiscoveryProtocol connection lost due to") + _LOGGER.error("AirOSDiscoveryProtocol connection lost due to %s", exc) raise AirOSDiscoveryError from None def parse_airos_packet(self, data: bytes, host_ip: str) -> dict[str, Any] | None: From d17ff2148e6dcd8bdce44b95a20b7dfa040fecd1 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Tue, 28 Jul 2026 18:33:17 +0000 Subject: [PATCH 3/5] Bump for ruff/mypy fix test --- tests/test_discovery.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tests/test_discovery.py b/tests/test_discovery.py index bbc25ed..65d4965 100644 --- a/tests/test_discovery.py +++ b/tests/test_discovery.py @@ -180,14 +180,16 @@ async def test_connection_made_sets_transport() -> None: @pytest.mark.asyncio -async def test_connection_lost_without_exception() -> None: - """Test connection_lost without an exception.""" +async def test_connection_lost_with_exception() -> None: + """Test connection_lost with an exception.""" protocol = AirOSDiscoveryProtocol(AsyncMock()) - with patch("airos.discovery._LOGGER.debug") as mock_log_debug: - protocol.connection_lost(None) - mock_log_debug.assert_called_once_with( - "AirOSDiscoveryProtocol connection lost." - ) + test_exception = Exception("Test connection lost error") + with ( + patch("airos.discovery._LOGGER.error") as mock_log_error, + pytest.raises(AirOSDiscoveryError), + ): + protocol.connection_lost(test_exception) + mock_log_error.assert_called_once() @pytest.mark.asyncio From ef66f05855a5174c526791e63ba99c7db4057f0c Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Tue, 28 Jul 2026 18:36:15 +0000 Subject: [PATCH 4/5] Bump for ruff/mypy fix correct test --- tests/test_discovery.py | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/tests/test_discovery.py b/tests/test_discovery.py index 65d4965..b1bfdda 100644 --- a/tests/test_discovery.py +++ b/tests/test_discovery.py @@ -180,17 +180,14 @@ async def test_connection_made_sets_transport() -> None: @pytest.mark.asyncio -async def test_connection_lost_with_exception() -> None: - """Test connection_lost with an exception.""" +async def test_connection_lost_without_exception() -> None: + """Test connection_lost without an exception.""" protocol = AirOSDiscoveryProtocol(AsyncMock()) - test_exception = Exception("Test connection lost error") - with ( - patch("airos.discovery._LOGGER.error") as mock_log_error, - pytest.raises(AirOSDiscoveryError), - ): - protocol.connection_lost(test_exception) - mock_log_error.assert_called_once() - + with patch("airos.discovery._LOGGER.debug") as mock_log_debug: + protocol.connection_lost(None) + mock_log_debug.assert_called_once_with( + "AirOSDiscoveryProtocol connection lost." + ) @pytest.mark.asyncio async def test_connection_lost_with_exception() -> None: @@ -198,13 +195,11 @@ async def test_connection_lost_with_exception() -> None: protocol = AirOSDiscoveryProtocol(AsyncMock()) test_exception = Exception("Test connection lost error") with ( - patch("airos.discovery._LOGGER.exception") as mock_log_exception, - pytest.raises( - AirOSDiscoveryError - ), # connection_lost now re-raises AirOSDiscoveryError + patch("airos.discovery._LOGGER.error") as mock_log_error, + pytest.raises(AirOSDiscoveryError), ): protocol.connection_lost(test_exception) - mock_log_exception.assert_called_once() + mock_log_error.assert_called_once() @pytest.mark.asyncio From 4ac1fbedc9461c709b1da6b9fcfc1e6850ff01cf Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Tue, 28 Jul 2026 18:38:06 +0000 Subject: [PATCH 5/5] Bump for ruff/mypy fix correct test ruff --- tests/test_discovery.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_discovery.py b/tests/test_discovery.py index b1bfdda..65316e8 100644 --- a/tests/test_discovery.py +++ b/tests/test_discovery.py @@ -189,6 +189,7 @@ async def test_connection_lost_without_exception() -> None: "AirOSDiscoveryProtocol connection lost." ) + @pytest.mark.asyncio async def test_connection_lost_with_exception() -> None: """Test connection_lost with an exception."""