diff --git a/homeassistant/components/august/sensor.py b/homeassistant/components/august/sensor.py index 6116e7d7601..29f17c69661 100644 --- a/homeassistant/components/august/sensor.py +++ b/homeassistant/components/august/sensor.py @@ -52,19 +52,19 @@ def _retrieve_linked_keypad_battery_state(detail: KeypadDetail) -> int | None: return detail.battery_percentage -T = TypeVar("T", LockDetail, KeypadDetail) +_T = TypeVar("_T", LockDetail, KeypadDetail) @dataclass -class AugustRequiredKeysMixin(Generic[T]): +class AugustRequiredKeysMixin(Generic[_T]): """Mixin for required keys.""" - value_fn: Callable[[T], int | None] + value_fn: Callable[[_T], int | None] @dataclass class AugustSensorEntityDescription( - SensorEntityDescription, AugustRequiredKeysMixin[T] + SensorEntityDescription, AugustRequiredKeysMixin[_T] ): """Describes August sensor entity.""" @@ -255,10 +255,10 @@ class AugustOperatorSensor(AugustEntityMixin, RestoreEntity, SensorEntity): return f"{self._device_id}_lock_operator" -class AugustBatterySensor(AugustEntityMixin, SensorEntity, Generic[T]): +class AugustBatterySensor(AugustEntityMixin, SensorEntity, Generic[_T]): """Representation of an August sensor.""" - entity_description: AugustSensorEntityDescription[T] + entity_description: AugustSensorEntityDescription[_T] _attr_device_class = SensorDeviceClass.BATTERY _attr_native_unit_of_measurement = PERCENTAGE @@ -267,7 +267,7 @@ class AugustBatterySensor(AugustEntityMixin, SensorEntity, Generic[T]): data: AugustData, device, old_device, - description: AugustSensorEntityDescription[T], + description: AugustSensorEntityDescription[_T], ): """Initialize the sensor.""" super().__init__(data, device) diff --git a/homeassistant/components/dlna_dms/dms.py b/homeassistant/components/dlna_dms/dms.py index 4cb1477778a..b43051ea4b4 100644 --- a/homeassistant/components/dlna_dms/dms.py +++ b/homeassistant/components/dlna_dms/dms.py @@ -47,7 +47,7 @@ from .const import ( ) _DlnaDmsDeviceMethod = TypeVar("_DlnaDmsDeviceMethod", bound="DmsDeviceSource") -_RetType = TypeVar("_RetType") +_R = TypeVar("_R") class DlnaDmsData: @@ -167,12 +167,12 @@ class ActionError(DlnaDmsDeviceError): def catch_request_errors( - func: Callable[[_DlnaDmsDeviceMethod, str], Coroutine[Any, Any, _RetType]] -) -> Callable[[_DlnaDmsDeviceMethod, str], Coroutine[Any, Any, _RetType]]: + func: Callable[[_DlnaDmsDeviceMethod, str], Coroutine[Any, Any, _R]] +) -> Callable[[_DlnaDmsDeviceMethod, str], Coroutine[Any, Any, _R]]: """Catch UpnpError errors.""" @functools.wraps(func) - async def wrapper(self: _DlnaDmsDeviceMethod, req_param: str) -> _RetType: + async def wrapper(self: _DlnaDmsDeviceMethod, req_param: str) -> _R: """Catch UpnpError errors and check availability before and after request.""" if not self.available: LOGGER.warning("Device disappeared when trying to call %s", func.__name__) diff --git a/homeassistant/components/fronius/__init__.py b/homeassistant/components/fronius/__init__.py index 12811e84079..03340f19081 100644 --- a/homeassistant/components/fronius/__init__.py +++ b/homeassistant/components/fronius/__init__.py @@ -30,7 +30,7 @@ from .coordinator import ( _LOGGER: Final = logging.getLogger(__name__) PLATFORMS: Final = [Platform.SENSOR] -FroniusCoordinatorType = TypeVar("FroniusCoordinatorType", bound=FroniusCoordinatorBase) +_FroniusCoordinatorT = TypeVar("_FroniusCoordinatorT", bound=FroniusCoordinatorBase) async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: @@ -199,8 +199,8 @@ class FroniusSolarNet: @staticmethod async def _init_optional_coordinator( - coordinator: FroniusCoordinatorType, - ) -> FroniusCoordinatorType | None: + coordinator: _FroniusCoordinatorT, + ) -> _FroniusCoordinatorT | None: """Initialize an update coordinator and return it if devices are found.""" try: await coordinator.async_config_entry_first_refresh() diff --git a/homeassistant/components/fronius/coordinator.py b/homeassistant/components/fronius/coordinator.py index e9d47296864..c1090dab1b1 100644 --- a/homeassistant/components/fronius/coordinator.py +++ b/homeassistant/components/fronius/coordinator.py @@ -31,7 +31,7 @@ if TYPE_CHECKING: from . import FroniusSolarNet from .sensor import _FroniusSensorEntity - FroniusEntityType = TypeVar("FroniusEntityType", bound=_FroniusSensorEntity) + _FroniusEntityT = TypeVar("_FroniusEntityT", bound=_FroniusSensorEntity) class FroniusCoordinatorBase( @@ -84,7 +84,7 @@ class FroniusCoordinatorBase( def add_entities_for_seen_keys( self, async_add_entities: AddEntitiesCallback, - entity_constructor: type[FroniusEntityType], + entity_constructor: type[_FroniusEntityT], ) -> None: """ Add entities for received keys and registers listener for future seen keys. diff --git a/homeassistant/components/vera/__init__.py b/homeassistant/components/vera/__init__.py index ef293c279be..d7cd8db051b 100644 --- a/homeassistant/components/vera/__init__.py +++ b/homeassistant/components/vera/__init__.py @@ -214,14 +214,14 @@ def map_vera_device( ) -DeviceType = TypeVar("DeviceType", bound=veraApi.VeraDevice) +_DeviceTypeT = TypeVar("_DeviceTypeT", bound=veraApi.VeraDevice) -class VeraDevice(Generic[DeviceType], Entity): +class VeraDevice(Generic[_DeviceTypeT], Entity): """Representation of a Vera device entity.""" def __init__( - self, vera_device: DeviceType, controller_data: ControllerData + self, vera_device: _DeviceTypeT, controller_data: ControllerData ) -> None: """Initialize the device.""" self.vera_device = vera_device @@ -242,7 +242,7 @@ class VeraDevice(Generic[DeviceType], Entity): """Subscribe to updates.""" self.controller.register(self.vera_device, self._update_callback) - def _update_callback(self, _device: DeviceType) -> None: + def _update_callback(self, _device: _DeviceTypeT) -> None: """Update the state.""" self.schedule_update_ha_state(True) diff --git a/tests/components/google/conftest.py b/tests/components/google/conftest.py index 8efeac9983d..c3b8ae4e172 100644 --- a/tests/components/google/conftest.py +++ b/tests/components/google/conftest.py @@ -24,8 +24,8 @@ ORIG_TIMEZONE = dt_util.DEFAULT_TIME_ZONE ApiResult = Callable[[dict[str, Any]], None] ComponentSetup = Callable[[], Awaitable[bool]] -T = TypeVar("T") -YieldFixture = Generator[T, None, None] +_T = TypeVar("_T") +YieldFixture = Generator[_T, None, None] CALENDAR_ID = "qwertyuiopasdfghjklzxcvbnm@import.calendar.google.com" diff --git a/tests/components/nest/common.py b/tests/components/nest/common.py index e80ca84d58f..c2a9c6db157 100644 --- a/tests/components/nest/common.py +++ b/tests/components/nest/common.py @@ -22,8 +22,8 @@ from tests.common import MockConfigEntry # Typing helpers PlatformSetup = Callable[[], Awaitable[None]] -T = TypeVar("T") -YieldFixture = Generator[T, None, None] +_T = TypeVar("_T") +YieldFixture = Generator[_T, None, None] PROJECT_ID = "some-project-id" CLIENT_ID = "some-client-id" diff --git a/tests/components/rtsp_to_webrtc/conftest.py b/tests/components/rtsp_to_webrtc/conftest.py index 7148896e454..5e737efc397 100644 --- a/tests/components/rtsp_to_webrtc/conftest.py +++ b/tests/components/rtsp_to_webrtc/conftest.py @@ -24,8 +24,8 @@ CONFIG_ENTRY_DATA = {"server_url": SERVER_URL} # Typing helpers ComponentSetup = Callable[[], Awaitable[None]] -T = TypeVar("T") -YieldFixture = Generator[T, None, None] +_T = TypeVar("_T") +YieldFixture = Generator[_T, None, None] @pytest.fixture(autouse=True)