Skip to content

Commit 95bb092

Browse files
authored
Set "from __future__ import annotations" as required import (#402)
1 parent ddde659 commit 95bb092

File tree

120 files changed

+532
-174
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+532
-174
lines changed

deebot_client/api_client.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
"""Api client module."""
2-
from typing import Any
2+
from __future__ import annotations
3+
4+
from typing import TYPE_CHECKING, Any
35

46
from deebot_client.hardware.deebot import get_static_device_info
57

6-
from .authentication import Authenticator
78
from .const import PATH_API_APPSVR_APP, PATH_API_PIM_PRODUCT_IOT_MAP
89
from .exceptions import ApiError
910
from .logging_filter import get_logger
1011
from .models import ApiDeviceInfo, DeviceInfo
1112

13+
if TYPE_CHECKING:
14+
from .authentication import Authenticator
15+
1216
_LOGGER = get_logger(__name__)
1317

1418

deebot_client/authentication.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
"""Authentication module."""
2+
from __future__ import annotations
3+
24
import asyncio
3-
from collections.abc import Callable, Coroutine, Mapping
45
from http import HTTPStatus
56
import time
6-
from typing import Any
7+
from typing import TYPE_CHECKING, Any
78
from urllib.parse import urljoin
89

910
from aiohttp import ClientResponseError, hdrs
@@ -14,6 +15,9 @@
1415
from .models import Configuration, Credentials
1516
from .util import cancel, create_task, md5
1617

18+
if TYPE_CHECKING:
19+
from collections.abc import Callable, Coroutine, Mapping
20+
1721
_LOGGER = get_logger(__name__)
1822

1923
_CLIENT_KEY = "1520391301804"

deebot_client/capabilities.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
"""Device capabilities module."""
2-
from collections.abc import Callable
2+
from __future__ import annotations
3+
34
from dataclasses import dataclass, field, fields, is_dataclass
45
from types import MappingProxyType
56
from typing import TYPE_CHECKING, Any, Generic, TypeVar
67

7-
from deebot_client.command import Command, SetCommand
88
from deebot_client.events import (
99
AdvancedModeEvent,
1010
AvailabilityEvent,
@@ -41,19 +41,23 @@
4141
WorkMode,
4242
WorkModeEvent,
4343
)
44-
from deebot_client.events.efficiency_mode import EfficiencyMode, EfficiencyModeEvent
45-
from deebot_client.models import CleanAction, CleanMode
4644

4745
if TYPE_CHECKING:
46+
from collections.abc import Callable
47+
4848
from _typeshed import DataclassInstance
4949

50+
from deebot_client.command import Command, SetCommand
51+
from deebot_client.events.efficiency_mode import EfficiencyMode, EfficiencyModeEvent
52+
from deebot_client.models import CleanAction, CleanMode
53+
5054

5155
_T = TypeVar("_T")
5256
_EVENT = TypeVar("_EVENT", bound=Event)
5357

5458

5559
def _get_events(
56-
capabilities: "DataclassInstance",
60+
capabilities: DataclassInstance,
5761
) -> MappingProxyType[type[Event], list[Command]]:
5862
events = {}
5963
for field_ in fields(capabilities):

deebot_client/command.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
"""Base command."""
2+
from __future__ import annotations
3+
24
from abc import ABC, abstractmethod
35
import asyncio
46
from dataclasses import dataclass, field
5-
from types import MappingProxyType
6-
from typing import Any, final
7+
from typing import TYPE_CHECKING, Any, final
78

89
from deebot_client.events import AvailabilityEvent
910
from deebot_client.exceptions import DeebotError
1011

11-
from .authentication import Authenticator
1212
from .const import PATH_API_IOT_DEVMANAGER, REQUEST_HEADERS, DataType
13-
from .event_bus import EventBus
1413
from .logging_filter import get_logger
1514
from .message import HandlingResult, HandlingState, Message
16-
from .models import DeviceInfo
15+
16+
if TYPE_CHECKING:
17+
from types import MappingProxyType
18+
19+
from .authentication import Authenticator
20+
from .event_bus import EventBus
21+
from .models import DeviceInfo
1722

1823
_LOGGER = get_logger(__name__)
1924

@@ -22,15 +27,15 @@
2227
class CommandResult(HandlingResult):
2328
"""Command result object."""
2429

25-
requested_commands: list["Command"] = field(default_factory=list)
30+
requested_commands: list[Command] = field(default_factory=list)
2631

2732
@classmethod
28-
def success(cls) -> "CommandResult":
33+
def success(cls) -> CommandResult:
2934
"""Create result with handling success."""
3035
return CommandResult(HandlingState.SUCCESS)
3136

3237
@classmethod
33-
def analyse(cls) -> "CommandResult":
38+
def analyse(cls) -> CommandResult:
3439
"""Create result with handling analyse."""
3540
return CommandResult(HandlingState.ANALYSE)
3641

@@ -252,7 +257,7 @@ def handle_mqtt_p2p(self, event_bus: EventBus, response: dict[str, Any]) -> None
252257
"""Handle response received over the mqtt channel "p2p"."""
253258

254259
@classmethod
255-
def create_from_mqtt(cls, data: dict[str, Any]) -> "CommandMqttP2P":
260+
def create_from_mqtt(cls, data: dict[str, Any]) -> CommandMqttP2P:
256261
"""Create a command from the mqtt data."""
257262
values: dict[str, Any] = {}
258263
if not hasattr(cls, "_mqtt_params"):

deebot_client/commands/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
"""Commands module."""
2-
from deebot_client.command import Command, CommandMqttP2P
2+
from __future__ import annotations
3+
4+
from typing import TYPE_CHECKING
5+
36
from deebot_client.const import DataType
47

58
from .json import (
69
COMMANDS as JSON_COMMANDS,
710
COMMANDS_WITH_MQTT_P2P_HANDLING as JSON_COMMANDS_WITH_MQTT_P2P_HANDLING,
811
)
912

13+
if TYPE_CHECKING:
14+
from deebot_client.command import Command, CommandMqttP2P
15+
1016
COMMANDS: dict[DataType, dict[str, type[Command]]] = {DataType.JSON: JSON_COMMANDS}
1117

1218
COMMANDS_WITH_MQTT_P2P_HANDLING: dict[DataType, dict[str, type[CommandMqttP2P]]] = {

deebot_client/commands/json/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
"""Json commands module."""
2+
from __future__ import annotations
3+
4+
from typing import TYPE_CHECKING
5+
26
from deebot_client.command import Command, CommandMqttP2P
37

48
from .advanced_mode import GetAdvancedMode, SetAdvancedMode
@@ -10,7 +14,6 @@
1014
from .clean_count import GetCleanCount, SetCleanCount
1115
from .clean_logs import GetCleanLogs
1216
from .clean_preference import GetCleanPreference, SetCleanPreference
13-
from .common import JsonCommand
1417
from .continuous_cleaning import GetContinuousCleaning, SetContinuousCleaning
1518
from .efficiency import GetEfficiencyMode, SetEfficiencyMode
1619
from .error import GetError
@@ -36,6 +39,9 @@
3639
from .water_info import GetWaterInfo, SetWaterInfo
3740
from .work_mode import GetWorkMode, SetWorkMode
3841

42+
if TYPE_CHECKING:
43+
from .common import JsonCommand
44+
3945
__all__ = [
4046
"GetAdvancedMode",
4147
"SetAdvancedMode",

deebot_client/commands/json/advanced_mode.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Advanced mode command module."""
2+
from __future__ import annotations
23

34
from deebot_client.events import AdvancedModeEvent
45

deebot_client/commands/json/battery.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
"""Battery commands."""
2+
from __future__ import annotations
3+
24
from deebot_client.messages.json import OnBattery
35

46
from .common import JsonCommandWithMessageHandling

deebot_client/commands/json/carpet.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Carpet pressure command module."""
2+
from __future__ import annotations
23

34
from deebot_client.events import CarpetAutoFanBoostEvent
45

deebot_client/commands/json/charge.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
"""Charge commands."""
2-
from typing import Any
2+
from __future__ import annotations
3+
4+
from typing import TYPE_CHECKING, Any
35

4-
from deebot_client.event_bus import EventBus
56
from deebot_client.events import StateEvent
67
from deebot_client.logging_filter import get_logger
78
from deebot_client.message import HandlingResult
@@ -10,6 +11,9 @@
1011
from .common import ExecuteCommand
1112
from .const import CODE
1213

14+
if TYPE_CHECKING:
15+
from deebot_client.event_bus import EventBus
16+
1317
_LOGGER = get_logger(__name__)
1418

1519

deebot_client/commands/json/charge_state.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
"""Charge state commands."""
2-
from typing import Any
2+
from __future__ import annotations
3+
4+
from typing import TYPE_CHECKING, Any
35

4-
from deebot_client.event_bus import EventBus
56
from deebot_client.events import StateEvent
67
from deebot_client.message import HandlingResult, MessageBodyDataDict
78
from deebot_client.models import State
89

910
from .common import JsonCommandWithMessageHandling
1011
from .const import CODE
1112

13+
if TYPE_CHECKING:
14+
from deebot_client.event_bus import EventBus
15+
1216

1317
class GetChargeState(JsonCommandWithMessageHandling, MessageBodyDataDict):
1418
"""Get charge state command."""

deebot_client/commands/json/clean.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
"""Clean commands."""
2-
from typing import Any
2+
from __future__ import annotations
3+
4+
from typing import TYPE_CHECKING, Any
35

4-
from deebot_client.authentication import Authenticator
5-
from deebot_client.command import CommandResult
6-
from deebot_client.event_bus import EventBus
76
from deebot_client.events import StateEvent
87
from deebot_client.logging_filter import get_logger
98
from deebot_client.message import HandlingResult, MessageBodyDataDict
109
from deebot_client.models import CleanAction, CleanMode, DeviceInfo, State
1110

1211
from .common import ExecuteCommand, JsonCommandWithMessageHandling
1312

13+
if TYPE_CHECKING:
14+
from deebot_client.authentication import Authenticator
15+
from deebot_client.command import CommandResult
16+
from deebot_client.event_bus import EventBus
17+
1418
_LOGGER = get_logger(__name__)
1519

1620

deebot_client/commands/json/clean_count.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
"""Clean count command module."""
2+
from __future__ import annotations
23

34
from types import MappingProxyType
4-
from typing import Any
5+
from typing import TYPE_CHECKING, Any
56

67
from deebot_client.command import InitParam
7-
from deebot_client.event_bus import EventBus
88
from deebot_client.events import CleanCountEvent
99
from deebot_client.message import HandlingResult
1010

1111
from .common import JsonGetCommand, JsonSetCommand
1212

13+
if TYPE_CHECKING:
14+
from deebot_client.event_bus import EventBus
15+
1316

1417
class GetCleanCount(JsonGetCommand):
1518
"""Get clean count command."""

deebot_client/commands/json/clean_logs.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
"""clean log commands."""
2-
from typing import Any
2+
from __future__ import annotations
3+
4+
from typing import TYPE_CHECKING, Any
35

4-
from deebot_client.authentication import Authenticator
56
from deebot_client.command import CommandResult
67
from deebot_client.const import PATH_API_LG_LOG, REQUEST_HEADERS
7-
from deebot_client.event_bus import EventBus
88
from deebot_client.events import CleanJobStatus, CleanLogEntry, CleanLogEvent
99
from deebot_client.logging_filter import get_logger
10-
from deebot_client.models import DeviceInfo
1110

1211
from .common import JsonCommand
1312

13+
if TYPE_CHECKING:
14+
from deebot_client.authentication import Authenticator
15+
from deebot_client.event_bus import EventBus
16+
from deebot_client.models import DeviceInfo
17+
1418
_LOGGER = get_logger(__name__)
1519

1620

deebot_client/commands/json/clean_preference.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Clean preference command module."""
2+
from __future__ import annotations
23

34
from deebot_client.events import CleanPreferenceEvent
45

deebot_client/commands/json/common.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
"""Base commands."""
2+
from __future__ import annotations
3+
24
from abc import ABC, abstractmethod
35
from datetime import datetime
46
from types import MappingProxyType
5-
from typing import Any
7+
from typing import TYPE_CHECKING, Any
68

79
from deebot_client.command import (
810
Command,
@@ -12,8 +14,6 @@
1214
SetCommand,
1315
)
1416
from deebot_client.const import DataType
15-
from deebot_client.event_bus import EventBus
16-
from deebot_client.events import EnableEvent
1717
from deebot_client.logging_filter import get_logger
1818
from deebot_client.message import (
1919
HandlingResult,
@@ -24,6 +24,10 @@
2424

2525
from .const import CODE
2626

27+
if TYPE_CHECKING:
28+
from deebot_client.event_bus import EventBus
29+
from deebot_client.events import EnableEvent
30+
2731
_LOGGER = get_logger(__name__)
2832

2933

deebot_client/commands/json/const.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
"""Command constants module."""
2+
from __future__ import annotations
23

34
CODE = "code"

deebot_client/commands/json/continuous_cleaning.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Continuous cleaning (break point) command module."""
2+
from __future__ import annotations
23

34
from deebot_client.events import ContinuousCleaningEvent
45

deebot_client/commands/json/custom.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
"""Custom command module."""
2-
from typing import Any
2+
from __future__ import annotations
3+
4+
from typing import TYPE_CHECKING, Any
35

46
from deebot_client.command import CommandResult
57
from deebot_client.commands.json.common import JsonCommand
6-
from deebot_client.event_bus import EventBus
78
from deebot_client.events import CustomCommandEvent
89
from deebot_client.logging_filter import get_logger
910
from deebot_client.message import HandlingState
1011

12+
if TYPE_CHECKING:
13+
from deebot_client.event_bus import EventBus
14+
1115
_LOGGER = get_logger(__name__)
1216

1317

0 commit comments

Comments
 (0)