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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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