Skip to content

Split async_get_issue_tracker loader function #130856

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 26 additions & 12 deletions homeassistant/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -1685,6 +1685,29 @@ def is_component_module_loaded(hass: HomeAssistant, module: str) -> bool:
return module in hass.data[DATA_COMPONENTS]


@callback
def async_get_issue_integration(
hass: HomeAssistant | None,
integration_domain: str | None,
) -> Integration | None:
"""Return details of an integration for issue reporting."""
integration: Integration | None = None
if not hass or not integration_domain:
# We are unable to get the integration
return None

if (comps_or_future := hass.data.get(DATA_CUSTOM_COMPONENTS)) and not isinstance(
comps_or_future, asyncio.Future
):
integration = comps_or_future.get(integration_domain)

if not integration:
with suppress(IntegrationNotLoaded):
integration = async_get_loaded_integration(hass, integration_domain)

return integration


@callback
def async_get_issue_tracker(
hass: HomeAssistant | None,
Expand All @@ -1698,20 +1721,11 @@ def async_get_issue_tracker(
"https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue"
)
if not integration and not integration_domain and not module:
# If we know nothing about the entity, suggest opening an issue on HA core
# If we know nothing about the integration, suggest opening an issue on HA core
return issue_tracker

if (
not integration
and (hass and integration_domain)
and (comps_or_future := hass.data.get(DATA_CUSTOM_COMPONENTS))
and not isinstance(comps_or_future, asyncio.Future)
):
integration = comps_or_future.get(integration_domain)

if not integration and (hass and integration_domain):
with suppress(IntegrationNotLoaded):
integration = async_get_loaded_integration(hass, integration_domain)
if not integration:
integration = async_get_issue_integration(hass, integration_domain)

if integration and not integration.is_built_in:
return integration.issue_tracker
Expand Down