Update Optional typing (2) [Py310] (#86419)

This commit is contained in:
Marc Mueller 2023-01-23 09:10:05 +01:00 committed by GitHub
parent 40be2324cc
commit da35097803
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 26 additions and 92 deletions

View File

@ -1,8 +1,6 @@
"""Support for Aranet sensors."""
from __future__ import annotations
from typing import Optional, Union
from aranet4.client import Aranet4Advertisement
from bleak.backends.device import BLEDevice
@ -145,9 +143,7 @@ async def async_setup_entry(
class Aranet4BluetoothSensorEntity(
PassiveBluetoothProcessorEntity[
PassiveBluetoothDataProcessor[Optional[Union[float, int]]]
],
PassiveBluetoothProcessorEntity[PassiveBluetoothDataProcessor[float | int | None]],
SensorEntity,
):
"""Representation of an Aranet sensor."""

View File

@ -1,8 +1,6 @@
"""Support for BlueMaestro sensors."""
from __future__ import annotations
from typing import Optional, Union
from bluemaestro_ble import (
SensorDeviceClass as BlueMaestroSensorDeviceClass,
SensorUpdate,
@ -137,9 +135,7 @@ async def async_setup_entry(
class BlueMaestroBluetoothSensorEntity(
PassiveBluetoothProcessorEntity[
PassiveBluetoothDataProcessor[Optional[Union[float, int]]]
],
PassiveBluetoothProcessorEntity[PassiveBluetoothDataProcessor[float | int | None]],
SensorEntity,
):
"""Representation of a BlueMaestro sensor."""

View File

@ -1,8 +1,6 @@
"""Support for BTHome sensors."""
from __future__ import annotations
from typing import Optional, Union
from bthome_ble import SensorDeviceClass as BTHomeSensorDeviceClass, SensorUpdate, Units
from homeassistant import config_entries
@ -332,9 +330,7 @@ async def async_setup_entry(
class BTHomeBluetoothSensorEntity(
PassiveBluetoothProcessorEntity[
PassiveBluetoothDataProcessor[Optional[Union[float, int]]]
],
PassiveBluetoothProcessorEntity[PassiveBluetoothDataProcessor[float | int | None]],
SensorEntity,
):
"""Representation of a BTHome BLE sensor."""

View File

@ -6,7 +6,7 @@ from functools import partial
from ipaddress import IPv6Address, ip_address
import logging
from pprint import pformat
from typing import Any, Optional, cast
from typing import Any, cast
from urllib.parse import urlparse
from async_upnp_client.client import UpnpError
@ -36,7 +36,7 @@ from .data import get_domain_data
LOGGER = logging.getLogger(__name__)
FlowInput = Optional[Mapping[str, Any]]
FlowInput = Mapping[str, Any] | None
class ConnectError(IntegrationError):

View File

@ -1,8 +1,6 @@
"""Support for govee ble sensors."""
from __future__ import annotations
from typing import Optional, Union
from govee_ble import DeviceClass, DeviceKey, SensorUpdate, Units
from govee_ble.parser import ERROR
@ -117,7 +115,7 @@ async def async_setup_entry(
class GoveeBluetoothSensorEntity(
PassiveBluetoothProcessorEntity[
PassiveBluetoothDataProcessor[Optional[Union[float, int, str]]]
PassiveBluetoothDataProcessor[float | int | str | None]
],
SensorEntity,
):

View File

@ -1,8 +1,6 @@
"""Support for inkbird ble sensors."""
from __future__ import annotations
from typing import Optional, Union
from inkbird_ble import DeviceClass, DeviceKey, SensorUpdate, Units
from homeassistant import config_entries
@ -115,9 +113,7 @@ async def async_setup_entry(
class INKBIRDBluetoothSensorEntity(
PassiveBluetoothProcessorEntity[
PassiveBluetoothDataProcessor[Optional[Union[float, int]]]
],
PassiveBluetoothProcessorEntity[PassiveBluetoothDataProcessor[float | int | None]],
SensorEntity,
):
"""Representation of a inkbird ble sensor."""

View File

@ -1,8 +1,6 @@
"""Support for Kegtron sensors."""
from __future__ import annotations
from typing import Optional, Union
from kegtron_ble import (
SensorDeviceClass as KegtronSensorDeviceClass,
SensorUpdate,
@ -126,9 +124,7 @@ async def async_setup_entry(
class KegtronBluetoothSensorEntity(
PassiveBluetoothProcessorEntity[
PassiveBluetoothDataProcessor[Optional[Union[float, int]]]
],
PassiveBluetoothProcessorEntity[PassiveBluetoothDataProcessor[float | int | None]],
SensorEntity,
):
"""Representation of a Kegtron sensor."""

View File

@ -1,8 +1,6 @@
"""Support for moat ble sensors."""
from __future__ import annotations
from typing import Optional, Union
from moat_ble import DeviceClass, DeviceKey, SensorUpdate, Units
from homeassistant import config_entries
@ -122,9 +120,7 @@ async def async_setup_entry(
class MoatBluetoothSensorEntity(
PassiveBluetoothProcessorEntity[
PassiveBluetoothDataProcessor[Optional[Union[float, int]]]
],
PassiveBluetoothProcessorEntity[PassiveBluetoothDataProcessor[float | int | None]],
SensorEntity,
):
"""Representation of a moat ble sensor."""

View File

@ -3,7 +3,7 @@ from __future__ import annotations
from datetime import datetime
import logging
from typing import Any, Optional
from typing import Any
from homeassistant.components.binary_sensor import BinarySensorEntity
from homeassistant.const import (
@ -123,7 +123,7 @@ class ModbusBinarySensor(BasePlatform, RestoreEntity, BinarySensorEntity):
class SlaveSensor(
CoordinatorEntity[DataUpdateCoordinator[Optional[list[int]]]],
CoordinatorEntity[DataUpdateCoordinator[list[int] | None]],
RestoreEntity,
BinarySensorEntity,
):

View File

@ -3,7 +3,7 @@ from __future__ import annotations
from datetime import datetime
import logging
from typing import Any, Optional
from typing import Any
from homeassistant.components.sensor import CONF_STATE_CLASS, SensorEntity
from homeassistant.const import (
@ -134,7 +134,7 @@ class ModbusRegisterSensor(BaseStructPlatform, RestoreEntity, SensorEntity):
class SlaveSensor(
CoordinatorEntity[DataUpdateCoordinator[Optional[list[int]]]],
CoordinatorEntity[DataUpdateCoordinator[list[int] | None]],
RestoreEntity,
SensorEntity,
):

View File

@ -1,8 +1,6 @@
"""Support for OralB sensors."""
from __future__ import annotations
from typing import Optional, Union
from oralb_ble import OralBSensor, SensorUpdate
from homeassistant import config_entries
@ -117,9 +115,7 @@ async def async_setup_entry(
class OralBBluetoothSensorEntity(
PassiveBluetoothProcessorEntity[
PassiveBluetoothDataProcessor[Optional[Union[str, int]]]
],
PassiveBluetoothProcessorEntity[PassiveBluetoothDataProcessor[str | int | None]],
SensorEntity,
):
"""Representation of a OralB sensor."""

View File

@ -1,8 +1,6 @@
"""Support for Qingping sensors."""
from __future__ import annotations
from typing import Optional, Union
from qingping_ble import (
SensorDeviceClass as QingpingSensorDeviceClass,
SensorUpdate,
@ -161,9 +159,7 @@ async def async_setup_entry(
class QingpingBluetoothSensorEntity(
PassiveBluetoothProcessorEntity[
PassiveBluetoothDataProcessor[Optional[Union[float, int]]]
],
PassiveBluetoothProcessorEntity[PassiveBluetoothDataProcessor[float | int | None]],
SensorEntity,
):
"""Representation of a Qingping sensor."""

View File

@ -1,8 +1,6 @@
"""Support for RuuviTag sensors."""
from __future__ import annotations
from typing import Optional, Union
from sensor_state_data import (
DeviceKey,
SensorDescription,
@ -143,9 +141,7 @@ async def async_setup_entry(
class RuuvitagBluetoothSensorEntity(
PassiveBluetoothProcessorEntity[
PassiveBluetoothDataProcessor[Optional[Union[float, int]]]
],
PassiveBluetoothProcessorEntity[PassiveBluetoothDataProcessor[float | int | None]],
SensorEntity,
):
"""Representation of a Ruuvitag BLE sensor."""

View File

@ -1,8 +1,6 @@
"""Support for Sensirion sensors."""
from __future__ import annotations
from typing import Optional, Union
from sensor_state_data import (
DeviceKey,
SensorDescription,
@ -123,9 +121,7 @@ async def async_setup_entry(
class SensirionBluetoothSensorEntity(
PassiveBluetoothProcessorEntity[
PassiveBluetoothDataProcessor[Optional[Union[float, int]]]
],
PassiveBluetoothProcessorEntity[PassiveBluetoothDataProcessor[float | int | None]],
SensorEntity,
):
"""Representation of a Sensirion BLE sensor."""

View File

@ -1,8 +1,6 @@
"""Support for SensorPro sensors."""
from __future__ import annotations
from typing import Optional, Union
from sensorpro_ble import (
SensorDeviceClass as SensorProSensorDeviceClass,
SensorUpdate,
@ -128,9 +126,7 @@ async def async_setup_entry(
class SensorProBluetoothSensorEntity(
PassiveBluetoothProcessorEntity[
PassiveBluetoothDataProcessor[Optional[Union[float, int]]]
],
PassiveBluetoothProcessorEntity[PassiveBluetoothDataProcessor[float | int | None]],
SensorEntity,
):
"""Representation of a SensorPro sensor."""

View File

@ -1,8 +1,6 @@
"""Support for sensorpush ble sensors."""
from __future__ import annotations
from typing import Optional, Union
from sensorpush_ble import DeviceClass, DeviceKey, SensorUpdate, Units
from homeassistant import config_entries
@ -116,9 +114,7 @@ async def async_setup_entry(
class SensorPushBluetoothSensorEntity(
PassiveBluetoothProcessorEntity[
PassiveBluetoothDataProcessor[Optional[Union[float, int]]]
],
PassiveBluetoothProcessorEntity[PassiveBluetoothDataProcessor[float | int | None]],
SensorEntity,
):
"""Representation of a sensorpush ble sensor."""

View File

@ -1,8 +1,6 @@
"""Support for ThermoBeacon sensors."""
from __future__ import annotations
from typing import Optional, Union
from thermobeacon_ble import (
SensorDeviceClass as ThermoBeaconSensorDeviceClass,
SensorUpdate,
@ -128,9 +126,7 @@ async def async_setup_entry(
class ThermoBeaconBluetoothSensorEntity(
PassiveBluetoothProcessorEntity[
PassiveBluetoothDataProcessor[Optional[Union[float, int]]]
],
PassiveBluetoothProcessorEntity[PassiveBluetoothDataProcessor[float | int | None]],
SensorEntity,
):
"""Representation of a ThermoBeacon sensor."""

View File

@ -1,8 +1,6 @@
"""Support for thermopro ble sensors."""
from __future__ import annotations
from typing import Optional, Union
from thermopro_ble import (
DeviceKey,
SensorDeviceClass as ThermoProSensorDeviceClass,
@ -117,9 +115,7 @@ async def async_setup_entry(
class ThermoProBluetoothSensorEntity(
PassiveBluetoothProcessorEntity[
PassiveBluetoothDataProcessor[Optional[Union[float, int]]]
],
PassiveBluetoothProcessorEntity[PassiveBluetoothDataProcessor[float | int | None]],
SensorEntity,
):
"""Representation of a thermopro ble sensor."""

View File

@ -1,8 +1,6 @@
"""Support for Tilt Hydrometers."""
from __future__ import annotations
from typing import Optional, Union
from tilt_ble import DeviceClass, DeviceKey, SensorUpdate, Units
from homeassistant import config_entries
@ -103,9 +101,7 @@ async def async_setup_entry(
class TiltBluetoothSensorEntity(
PassiveBluetoothProcessorEntity[
PassiveBluetoothDataProcessor[Optional[Union[float, int]]]
],
PassiveBluetoothProcessorEntity[PassiveBluetoothDataProcessor[float | int | None]],
SensorEntity,
):
"""Representation of a Tilt Hydrometer BLE sensor."""

View File

@ -1,8 +1,6 @@
"""Support for xiaomi ble sensors."""
from __future__ import annotations
from typing import Optional, Union
from xiaomi_ble import DeviceClass, SensorUpdate, Units
from homeassistant import config_entries
@ -162,9 +160,7 @@ async def async_setup_entry(
class XiaomiBluetoothSensorEntity(
PassiveBluetoothProcessorEntity[
PassiveBluetoothDataProcessor[Optional[Union[float, int]]]
],
PassiveBluetoothProcessorEntity[PassiveBluetoothDataProcessor[float | int | None]],
SensorEntity,
):
"""Representation of a xiaomi ble sensor."""

View File

@ -1,7 +1,7 @@
"""Typing Helpers for Home Assistant."""
from collections.abc import Mapping
from enum import Enum
from typing import Any, Optional, Union
from typing import Any
import homeassistant.core
@ -11,8 +11,8 @@ ContextType = homeassistant.core.Context
DiscoveryInfoType = dict[str, Any]
EventType = homeassistant.core.Event
ServiceDataType = dict[str, Any]
StateType = Union[None, str, int, float]
TemplateVarsType = Optional[Mapping[str, Any]]
StateType = str | int | float | None
TemplateVarsType = Mapping[str, Any] | None
# Custom type for recorder Queries
QueryType = Any