Skip to content

Commit adc6cf7

Browse files
committed
Mypy
1 parent 202356a commit adc6cf7

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

airos/helpers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import aiohttp
66

77
from .airos6 import AirOS6
8-
from .airos8 import AirOS
8+
from .airos8 import AirOS8
99
from .exceptions import AirOSKeyDataMissingError
1010

1111

@@ -25,7 +25,7 @@ async def async_get_firmware_data(
2525
use_ssl: bool = True,
2626
) -> DetectDeviceData:
2727
"""Connect to a device and return the major firmware version."""
28-
detect = AirOS(host, username, password, session, use_ssl)
28+
detect: AirOS8 = AirOS8(host, username, password, session, use_ssl)
2929

3030
await detect.login()
3131
raw_status = await detect._request_json( # noqa: SLF001
@@ -50,8 +50,8 @@ async def async_get_firmware_data(
5050
raw_status, AirOS6.derived_wireless_data
5151
)
5252
else: # Assume AirOS 8 for all other versions
53-
derived_data = AirOS._derived_data_helper( # noqa: SLF001
54-
raw_status, AirOS.derived_wireless_data
53+
derived_data = AirOS8._derived_data_helper( # noqa: SLF001
54+
raw_status, AirOS8.derived_wireless_data
5555
)
5656

5757
# Extract MAC address and hostname from the derived data

tests/test_helpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import aiohttp
77
import pytest
88

9-
from airos.airos8 import AirOS
9+
from airos.airos8 import AirOS8
1010
from airos.exceptions import AirOSKeyDataMissingError
1111
from airos.helpers import DetectDeviceData, async_get_firmware_data
1212

@@ -112,7 +112,7 @@ async def test_firmware_detection(
112112
]
113113
)
114114

115-
with patch.object(AirOS, "_request_json", new=mock_request_json):
115+
with patch.object(AirOS8, "_request_json", new=mock_request_json):
116116
if expected_exception:
117117
with pytest.raises(expected_exception):
118118
await async_get_firmware_data(

tests/test_stations.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
"""Ubiquiti AirOS tests."""
1+
"""Ubiquiti AirOS8 tests."""
22

33
from http.cookies import SimpleCookie
44
import json
55
import os
6-
from typing import Any, cast
6+
from typing import Any
77
from unittest.mock import AsyncMock, MagicMock, patch
88

99
import aiofiles
1010
from mashumaro.exceptions import MissingField
1111
import pytest
1212

13-
from airos.airos8 import AirOS
14-
from airos.data import AirOS8Data as AirOSData, Wireless
13+
from airos.airos8 import AirOS8
14+
from airos.data import AirOS8Data, Wireless
1515
from airos.exceptions import AirOSDeviceConnectionError, AirOSKeyDataMissingError
1616

1717

@@ -32,7 +32,7 @@ async def _read_fixture(fixture: str = "loco5ac_ap-ptp") -> Any:
3232
@patch("airos.airos8._LOGGER")
3333
@pytest.mark.asyncio
3434
async def test_status_logs_redacted_data_on_invalid_value(
35-
mock_logger: MagicMock, airos8_device: AirOS
35+
mock_logger: MagicMock, airos8_device: AirOS8
3636
) -> None:
3737
"""Test that the status method correctly logs redacted data when it encounters an InvalidFieldValue during deserialization."""
3838
# --- Prepare fake POST /api/auth response with cookies ---
@@ -62,7 +62,7 @@ async def test_status_logs_redacted_data_on_invalid_value(
6262
patch(
6363
"airos.airos8.AirOSData.from_dict",
6464
side_effect=MissingField(
65-
field_name="wireless", field_type=Wireless, holder_class=AirOSData
65+
field_name="wireless", field_type=Wireless, holder_class=AirOS8Data
6666
),
6767
),
6868
):
@@ -98,7 +98,7 @@ async def test_status_logs_redacted_data_on_invalid_value(
9898
@patch("airos.airos8._LOGGER")
9999
@pytest.mark.asyncio
100100
async def test_status_logs_exception_on_missing_field(
101-
mock_logger: MagicMock, airos8_device: AirOS
101+
mock_logger: MagicMock, airos8_device: AirOS8
102102
) -> None:
103103
"""Test that the status method correctly logs a full exception when it encounters a MissingField during deserialization."""
104104
# --- Prepare fake POST /api/auth response with cookies ---
@@ -154,7 +154,7 @@ async def test_status_logs_exception_on_missing_field(
154154
)
155155
@pytest.mark.asyncio
156156
async def test_ap_object(
157-
airos8_device: AirOS, base_url: str, mode: str, fixture: str
157+
airos8_device: AirOS8, base_url: str, mode: str, fixture: str
158158
) -> None:
159159
"""Test device operation using the new _request_json method."""
160160
fixture_data = await _read_fixture(fixture)
@@ -175,7 +175,7 @@ async def test_ap_object(
175175
):
176176
# We don't need to patch the session directly anymore
177177
await airos8_device.login()
178-
status = cast(AirOSData, await airos8_device.status())
178+
status: AirOS8Data = await airos8_device.status()
179179

180180
# Assertions remain the same as they check the final result
181181
assert status.wireless.mode
@@ -189,7 +189,7 @@ async def test_ap_object(
189189

190190
@pytest.mark.skip(reason="broken, needs investigation")
191191
@pytest.mark.asyncio
192-
async def test_reconnect(airos8_device: AirOS, base_url: str) -> None:
192+
async def test_reconnect(airos8_device: AirOS8, base_url: str) -> None:
193193
"""Test reconnect client."""
194194
# --- Prepare fake POST /api/stakick response ---
195195
mock_stakick_response = MagicMock()

tests/test_stations6.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from http.cookies import SimpleCookie
44
import json
55
import os
6-
from typing import Any, cast
6+
from typing import Any
77
from unittest.mock import AsyncMock, patch
88

99
import aiofiles
@@ -55,7 +55,7 @@ async def test_ap_object(
5555
):
5656
# We don't need to patch the session directly anymore
5757
await airos6_device.login()
58-
status = cast(AirOS6Data, await airos6_device.status())
58+
status: AirOS6Data = await airos6_device.status()
5959

6060
# Assertions remain the same as they check the final result
6161
assert status.wireless.mode

0 commit comments

Comments
 (0)