Remove deprecated usages of HomeAssistantType (#59241)

This commit is contained in:
Marvin Wichmann 2021-11-06 19:48:02 +01:00 committed by GitHub
parent fdf1bfa140
commit c5b5c8c3ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 16 deletions

View File

@ -3,14 +3,13 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers import device_registry as dr from homeassistant.helpers import device_registry as dr
from homeassistant.helpers.typing import HomeAssistantType
from .const import DOMAIN, PLATFORMS from .const import DOMAIN, PLATFORMS
from .errors import CannotLoginException from .errors import CannotLoginException
from .router import NetgearRouter from .router import NetgearRouter
async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool: async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up Netgear component.""" """Set up Netgear component."""
router = NetgearRouter(hass, entry) router = NetgearRouter(hass, entry)
try: try:
@ -38,7 +37,7 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool
return True return True
async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool: async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry.""" """Unload a config entry."""
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS) unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)

View File

@ -19,10 +19,9 @@ from homeassistant.const import (
CONF_SSL, CONF_SSL,
CONF_USERNAME, CONF_USERNAME,
) )
from homeassistant.core import callback from homeassistant.core import HomeAssistant, callback
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import HomeAssistantType
from .const import DEVICE_ICONS, DOMAIN from .const import DEVICE_ICONS, DOMAIN
from .router import NetgearDeviceEntity, NetgearRouter, async_setup_netgear_entry from .router import NetgearDeviceEntity, NetgearRouter, async_setup_netgear_entry
@ -65,7 +64,7 @@ async def async_get_scanner(hass, config):
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistantType, entry: ConfigEntry, async_add_entities: AddEntitiesCallback hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None: ) -> None:
"""Set up device tracker for Netgear component.""" """Set up device tracker for Netgear component."""

View File

@ -16,7 +16,7 @@ from homeassistant.const import (
CONF_SSL, CONF_SSL,
CONF_USERNAME, CONF_USERNAME,
) )
from homeassistant.core import callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import device_registry as dr from homeassistant.helpers import device_registry as dr
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC, format_mac from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC, format_mac
from homeassistant.helpers.dispatcher import ( from homeassistant.helpers.dispatcher import (
@ -26,7 +26,6 @@ from homeassistant.helpers.dispatcher import (
from homeassistant.helpers.entity import DeviceInfo, Entity from homeassistant.helpers.entity import DeviceInfo, Entity
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.event import async_track_time_interval from homeassistant.helpers.event import async_track_time_interval
from homeassistant.helpers.typing import HomeAssistantType
from homeassistant.util import dt as dt_util from homeassistant.util import dt as dt_util
from .const import ( from .const import (
@ -61,7 +60,7 @@ def get_api(
@callback @callback
def async_setup_netgear_entry( def async_setup_netgear_entry(
hass: HomeAssistantType, hass: HomeAssistant,
entry: ConfigEntry, entry: ConfigEntry,
async_add_entities: AddEntitiesCallback, async_add_entities: AddEntitiesCallback,
entity_class_generator: Callable[[NetgearRouter, dict], list], entity_class_generator: Callable[[NetgearRouter, dict], list],
@ -103,7 +102,7 @@ def async_add_new_entities(router, async_add_entities, tracked, entity_class_gen
class NetgearRouter: class NetgearRouter:
"""Representation of a Netgear router.""" """Representation of a Netgear router."""
def __init__(self, hass: HomeAssistantType, entry: ConfigEntry) -> None: def __init__(self, hass: HomeAssistant, entry: ConfigEntry) -> None:
"""Initialize a Netgear router.""" """Initialize a Netgear router."""
self.hass = hass self.hass = hass
self.entry = entry self.entry = entry

View File

@ -6,9 +6,8 @@ from homeassistant.components.sensor import (
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import PERCENTAGE from homeassistant.const import PERCENTAGE
from homeassistant.core import callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import HomeAssistantType
from .router import NetgearDeviceEntity, NetgearRouter, async_setup_netgear_entry from .router import NetgearDeviceEntity, NetgearRouter, async_setup_netgear_entry
@ -40,7 +39,7 @@ SENSOR_TYPES = {
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistantType, entry: ConfigEntry, async_add_entities: AddEntitiesCallback hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None: ) -> None:
"""Set up device tracker for Netgear component.""" """Set up device tracker for Netgear component."""

View File

@ -3,13 +3,12 @@
from RFXtrx import get_device from RFXtrx import get_device
from homeassistant.core import callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import device_registry as dr from homeassistant.helpers import device_registry as dr
from homeassistant.helpers.typing import HomeAssistantType
@callback @callback
def async_get_device_object(hass: HomeAssistantType, device_id): def async_get_device_object(hass: HomeAssistant, device_id):
"""Get a device for the given device registry id.""" """Get a device for the given device registry id."""
device_registry = dr.async_get(hass) device_registry = dr.async_get(hass)
registry_device = device_registry.async_get(device_id) registry_device = device_registry.async_get(device_id)