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]):
try:
scanner = None
setup = None
setup: bool | None = None
if hasattr(self.platform, "async_get_scanner"):
scanner = await self.platform.async_get_scanner(
hass, {DOMAIN: self.config}
@ -267,7 +267,7 @@ class DeviceTrackerPlatform:
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(
"Error setting up platform %s %s", self.type, self.name
)

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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