Skip to content
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.

update to python 3.10 #202

Merged
merged 1 commit into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ repos:
rev: v2.34.0
hooks:
- id: pyupgrade
args: [--py39-plus]
args: [--py310-plus]
- repo: https://github.com/psf/black
rev: 22.3.0
rev: 22.6.0
hooks:
- id: black
args:
Expand Down
3 changes: 1 addition & 2 deletions custom_components/deebot/binary_sensor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Binary sensor module."""
import logging
from typing import Optional

from deebot_client.events import WaterInfoEvent
from deebot_client.events.event_bus import EventListener
Expand Down Expand Up @@ -46,7 +45,7 @@ class DeebotMopAttachedBinarySensor(DeebotEntity, BinarySensorEntity): # type:
)

@property
def icon(self) -> Optional[str]:
def icon(self) -> str | None:
"""Return the icon to use in the frontend, if any."""
return "mdi:water" if self.is_on else "mdi:water-off"

Expand Down
5 changes: 2 additions & 3 deletions custom_components/deebot/camera.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Support for Deebot Vaccums."""
import base64
import logging
from typing import Optional

from homeassistant.components.camera import Camera
from homeassistant.config_entries import ConfigEntry
Expand Down Expand Up @@ -43,8 +42,8 @@ class DeeboLiveCamera(DeebotEntity, Camera): # type: ignore
_attr_should_poll = True

async def async_camera_image(
self, width: Optional[int] = None, height: Optional[int] = None
) -> Optional[bytes]:
self, width: int | None = None, height: int | None = None
) -> bytes | None:
"""Return a still image response from the camera.

Integrations may choose to ignore the height parameter in order to preserve aspect ratio
Expand Down
12 changes: 6 additions & 6 deletions custom_components/deebot/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
import random
import string
from typing import Any, Optional
from typing import Any

import homeassistant.helpers.config_validation as cv
import voluptuous as vol
Expand Down Expand Up @@ -49,8 +49,8 @@ class DeebotConfigFlow(ConfigFlow, domain=DOMAIN): # type: ignore
def __init__(self) -> None:
self._data: dict[str, Any] = {}
self._robot_list: list[DeviceInfo] = []
self._mode: Optional[str] = None
self._entry: Optional[ConfigEntry] = None
self._mode: str | None = None
self._entry: ConfigEntry | None = None

async def _async_retrieve_bots(
self, domain_config: dict[str, Any]
Expand All @@ -73,7 +73,7 @@ async def _async_retrieve_bots(
return await api_client.get_devices()

async def async_step_user(
self, user_input: Optional[dict[str, Any]] = None
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
"""Handle the initial step."""
errors = {}
Expand Down Expand Up @@ -148,7 +148,7 @@ async def async_step_user(
)

async def async_step_user_advanced(
self, user_input: Optional[dict[str, Any]] = None
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
"""Handle an advanced mode flow initialized by the user."""
if user_input is not None:
Expand All @@ -173,7 +173,7 @@ async def async_step_user_advanced(
return self.async_show_form(step_id="user_advanced", data_schema=data_schema)

async def async_step_robots(
self, user_input: Optional[dict[str, Any]] = None
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
"""Handle the robots selection step."""

Expand Down
6 changes: 2 additions & 4 deletions custom_components/deebot/entity.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""Deebot entity module."""
from typing import Optional

from deebot_client.events import StatusEvent
from deebot_client.events.event_bus import EventListener
from deebot_client.vacuum_bot import VacuumBot
Expand All @@ -18,7 +16,7 @@ class DeebotEntity(Entity): # type: ignore # lgtm [py/missing-equals]
def __init__(
self,
vacuum_bot: VacuumBot,
entity_description: Optional[EntityDescription] = None,
entity_description: EntityDescription | None = None,
):
"""Initialize the Sensor."""
super().__init__()
Expand Down Expand Up @@ -52,7 +50,7 @@ def __init__(
)

@property
def device_info(self) -> Optional[DeviceInfo]:
def device_info(self) -> DeviceInfo | None:
"""Return device specific attributes."""
device = self._vacuum_bot.device_info
info = DeviceInfo(
Expand Down
4 changes: 1 addition & 3 deletions custom_components/deebot/number.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""Number module."""
from typing import Optional

from deebot_client.commands import SetVolume
from deebot_client.events import VolumeEvent
from deebot_client.events.event_bus import EventListener
Expand Down Expand Up @@ -62,7 +60,7 @@ async def on_volume(event: VolumeEvent) -> None:
self.async_on_remove(listener.unsubscribe)

@property
def icon(self) -> Optional[str]:
def icon(self) -> str | None:
"""Return the icon to use in the frontend, if any."""
if self._attr_native_value is not None:
arrays = array_split(
Expand Down
3 changes: 1 addition & 2 deletions custom_components/deebot/select.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Select module."""
import logging
from typing import Optional

from deebot_client.commands import SetWaterInfo
from deebot_client.events import WaterAmount, WaterInfoEvent
Expand Down Expand Up @@ -45,7 +44,7 @@ class WaterInfoSelect(DeebotEntity, SelectEntity): # type: ignore
)

_attr_options = [amount.display_name for amount in WaterAmount]
_attr_current_option: Optional[str] = None
_attr_current_option: str | None = None

async def async_added_to_hass(self) -> None:
"""Set up the event listeners now that hass is ready."""
Expand Down
18 changes: 9 additions & 9 deletions custom_components/deebot/vacuum.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Support for Deebot Vaccums."""
import logging
from typing import Any, Mapping, Optional
from typing import Any, Mapping

import voluptuous as vol
from deebot_client.commands import (
Expand Down Expand Up @@ -115,11 +115,11 @@ def __init__(self, vacuum_bot: VacuumBot):

super().__init__(vacuum_bot, StateVacuumEntityDescription(key="", name=name))

self._battery: Optional[int] = None
self._fan_speed: Optional[str] = None
self._state: Optional[VacuumState] = None
self._battery: int | None = None
self._fan_speed: str | None = None
self._state: VacuumState | None = None
self._rooms: list[Room] = []
self._last_error: Optional[ErrorEvent] = None
self._last_error: ErrorEvent | None = None

async def async_added_to_hass(self) -> None:
"""Set up the event listeners now that hass is ready."""
Expand Down Expand Up @@ -169,12 +169,12 @@ def state(self) -> StateType:
return VACUUMSTATE_TO_STATE[self._state]

@property
def battery_level(self) -> Optional[int]:
def battery_level(self) -> int | None:
"""Return the battery level of the vacuum cleaner."""
return self._battery

@property
def fan_speed(self) -> Optional[str]:
def fan_speed(self) -> str | None:
"""Return the fan speed of the vacuum cleaner."""
return self._fan_speed

Expand All @@ -184,7 +184,7 @@ def fan_speed_list(self) -> list[str]:
return [level.display_name for level in FanSpeedLevel]

@property
def extra_state_attributes(self) -> Optional[Mapping[str, Any]]:
def extra_state_attributes(self) -> Mapping[str, Any] | None:
"""Return entity specific state attributes.

Implemented by platform classes. Convention for attribute names
Expand Down Expand Up @@ -239,7 +239,7 @@ async def async_locate(self, **kwargs: Any) -> None:
await self._vacuum_bot.execute_command(PlaySound())

async def async_send_command(
self, command: str, params: Optional[dict[str, Any]] = None, **kwargs: Any
self, command: str, params: dict[str, Any] | None = None, **kwargs: Any
) -> None:
"""Send a command to a vacuum cleaner."""
_LOGGER.debug("async_send_command %s with %s", command, params)
Expand Down