Fix incorrect type hint in async_setup_scanner (#63833)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2022-01-10 22:47:24 +01:00 committed by GitHub
parent 0030f114f9
commit 0ac9b62f97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 15 additions and 9 deletions

View File

@ -236,7 +236,7 @@ class DeviceTrackerPlatform:
with async_start_setup(hass, [full_name]): with async_start_setup(hass, [full_name]):
try: try:
scanner = None scanner = None
setup = None setup: bool | None = None
if hasattr(self.platform, "async_get_scanner"): if hasattr(self.platform, "async_get_scanner"):
scanner = await self.platform.async_get_scanner( scanner = await self.platform.async_get_scanner(
hass, {DOMAIN: self.config} hass, {DOMAIN: self.config}
@ -267,7 +267,7 @@ class DeviceTrackerPlatform:
hass, self.config, scanner, tracker.async_see, self.type hass, self.config, scanner, tracker.async_see, self.type
) )
if setup is None and scanner is None: if not setup and scanner is None:
LOGGER.error( LOGGER.error(
"Error setting up platform %s %s", self.type, self.name "Error setting up platform %s %s", self.type, self.name
) )

View File

@ -27,7 +27,7 @@ async def async_setup_scanner(
config: ConfigType, config: ConfigType,
see: Callable[..., Awaitable[None]], see: Callable[..., Awaitable[None]],
discovery_info: DiscoveryInfoType | None = None, discovery_info: DiscoveryInfoType | None = None,
) -> None: ) -> bool:
"""Old way of setting up the iCloud tracker.""" """Old way of setting up the iCloud tracker."""

View File

@ -36,10 +36,12 @@ async def async_setup_scanner(
config: ConfigType, config: ConfigType,
async_see: Callable[..., Awaitable[None]], async_see: Callable[..., Awaitable[None]],
discovery_info: DiscoveryInfoType | None = None, discovery_info: DiscoveryInfoType | None = None,
) -> None: ) -> bool:
"""Set up an endpoint for the Meraki tracker.""" """Set up an endpoint for the Meraki tracker."""
hass.http.register_view(MerakiView(config, async_see)) hass.http.register_view(MerakiView(config, async_see))
return True
class MerakiView(HomeAssistantView): class MerakiView(HomeAssistantView):
"""View to handle Meraki requests.""" """View to handle Meraki requests."""

View File

@ -45,7 +45,7 @@ async def async_setup_scanner(
config: ConfigType, config: ConfigType,
async_see: Callable[..., Awaitable[None]], async_see: Callable[..., Awaitable[None]],
discovery_info: DiscoveryInfoType | None = None, discovery_info: DiscoveryInfoType | None = None,
) -> None: ) -> bool:
"""Set up the MQTT JSON tracker.""" """Set up the MQTT JSON tracker."""
devices = config[CONF_DEVICES] devices = config[CONF_DEVICES]
qos = config[CONF_QOS] qos = config[CONF_QOS]
@ -73,6 +73,8 @@ async def async_setup_scanner(
await mqtt.async_subscribe(hass, topic, async_message_received, qos) await mqtt.async_subscribe(hass, topic, async_message_received, qos)
return True
def _parse_see_args(dev_id, data): def _parse_see_args(dev_id, data):
"""Parse the payload location parameters, into the format see expects.""" """Parse the payload location parameters, into the format see expects."""

View File

@ -87,7 +87,7 @@ async def async_setup_scanner(
config: ConfigType, config: ConfigType,
async_see: Callable[..., Awaitable[None]], async_see: Callable[..., Awaitable[None]],
discovery_info: DiscoveryInfoType | None = None, discovery_info: DiscoveryInfoType | None = None,
) -> None: ) -> bool:
"""Set up the Host objects and return the update function.""" """Set up the Host objects and return the update function."""
privileged = hass.data[DOMAIN][PING_PRIVS] privileged = hass.data[DOMAIN][PING_PRIVS]

View File

@ -168,7 +168,7 @@ async def async_setup_scanner(
config: ConfigType, config: ConfigType,
async_see: Callable[..., Awaitable[None]], async_see: Callable[..., Awaitable[None]],
discovery_info: DiscoveryInfoType | None = None, discovery_info: DiscoveryInfoType | None = None,
) -> None: ) -> bool:
"""Validate the configuration and return a Traccar scanner.""" """Validate the configuration and return a Traccar scanner."""
session = async_get_clientsession(hass, config[CONF_VERIFY_SSL]) session = async_get_clientsession(hass, config[CONF_VERIFY_SSL])

View File

@ -17,10 +17,10 @@ async def async_setup_scanner(
config: ConfigType, config: ConfigType,
async_see: Callable[..., Awaitable[None]], async_see: Callable[..., Awaitable[None]],
discovery_info: DiscoveryInfoType | None = None, discovery_info: DiscoveryInfoType | None = None,
) -> None: ) -> bool:
"""Set up the Volvo tracker.""" """Set up the Volvo tracker."""
if discovery_info is None: if discovery_info is None:
return return False
vin, component, attr, slug_attr = discovery_info vin, component, attr, slug_attr = discovery_info
data = hass.data[DATA_KEY] data = hass.data[DATA_KEY]
@ -39,3 +39,5 @@ async def async_setup_scanner(
) )
async_dispatcher_connect(hass, SIGNAL_STATE_UPDATED, see_vehicle) async_dispatcher_connect(hass, SIGNAL_STATE_UPDATED, see_vehicle)
return True