Handle command_line missing discovery_info (#116873)

* command_line: Do not lead to erroring out code indexing None or empty discovery_info

* Apply suggestions from code review

Co-authored-by: Franck Nijhof <frenck@frenck.nl>

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
This commit is contained in:
Yaroslav Halchenko 2024-08-04 04:39:41 -10:00 committed by GitHub
parent 70704f67d3
commit e682d8c6e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -37,6 +37,8 @@ async def async_setup_platform(
) -> None: ) -> None:
"""Find and return switches controlled by shell commands.""" """Find and return switches controlled by shell commands."""
if not discovery_info:
return
switches = [] switches = []
discovery_info = cast(DiscoveryInfoType, discovery_info) discovery_info = cast(DiscoveryInfoType, discovery_info)
entities: dict[str, dict[str, Any]] = { entities: dict[str, dict[str, Any]] = {