Repository: home-assistant/core
File: homeassistant/components/tractive/__init__.py (Python)

Code before:
    )
    entry.async_on_unload(tractive.unsubscribe)

    return True


async def _generate_trackables(
    client: aiotractive.Tractive,
    trackable: aiotractive.trackable_object.TrackableObject,
) -> Trackables | None:
    """Generate trackables."""
    trackable = await trackable.details()

    # Check that the pet has tracker linked.
    if not trackable.get("device_id"):
        return None

    if "details" not in trackable:
        _LOGGER.warning(
            "Tracker %s has no details and will be skipped. This happens for shared trackers",
            trackable["device_id"],
        )
        return None

    tracker = client.tracker(trackable["device_id"])
    trackable_obj = client.trackable_object(trackable["_id"])

    tracker_details, hw_info, pos_report, health_overview = await asyncio.gather(
        tracker.details(),
        tracker.hw_info(),
        tracker.pos_report(),
        trackable_obj.health_overview(),
    )

    if not tracker_details.get("_id"):
        raise ConfigEntryNotReady(
            f"Tractive API returns incomplete data for tracker {trackable['device_id']}",
        )

    return Trackables(
        tracker, trackable, tracker_details, hw_info, pos_report, health_overview
    )


async def async_unload_entry(hass: HomeAssistant, entry: TractiveConfigEntry) -> bool:
    """Unload a config entry."""
    return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)


class TractiveClient:
    """A Tractive client."""

Review comment (suggestion):
```suggestion
    trackable_pet = client.trackable_pet(trackable["_id"])
```

Code after:
    )
    entry.async_on_unload(tractive.unsubscribe)

    return True


async def _generate_trackables(
    client: aiotractive.Tractive,
    trackable: aiotractive.trackable_object.TrackableObject,
) -> Trackables | None:
    """Generate trackables."""
    trackable = await trackable.details()

    # Check that the pet has tracker linked.
    if not trackable.get("device_id"):
        return None

    if "details" not in trackable:
        _LOGGER.warning(
            "Tracker %s has no details and will be skipped. This happens for shared trackers",
            trackable["device_id"],
        )
        return None

    tracker = client.tracker(trackable["device_id"])
    trackable_pet = client.trackable_object(trackable["_id"])

    tracker_details, hw_info, pos_report, health_overview = await asyncio.gather(
        tracker.details(),
        tracker.hw_info(),
        tracker.pos_report(),
        trackable_pet.health_overview(),
    )

    if not tracker_details.get("_id"):
        raise ConfigEntryNotReady(
            f"Tractive API returns incomplete data for tracker {trackable['device_id']}",
        )

    return Trackables(
        tracker, trackable, tracker_details, hw_info, pos_report, health_overview
    )


async def async_unload_entry(hass: HomeAssistant, entry: TractiveConfigEntry) -> bool:
    """Unload a config entry."""
    return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)


class TractiveClient:
    """A Tractive client."""