mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Remove xbox from mypy ignore list (#74504)
This commit is contained in:
parent
f53bf1127f
commit
da133a7f05
@ -180,7 +180,7 @@ class XboxUpdateCoordinator(DataUpdateCoordinator):
|
|||||||
name=DOMAIN,
|
name=DOMAIN,
|
||||||
update_interval=timedelta(seconds=10),
|
update_interval=timedelta(seconds=10),
|
||||||
)
|
)
|
||||||
self.data: XboxData = XboxData({}, [])
|
self.data: XboxData = XboxData({}, {})
|
||||||
self.client: XboxLiveClient = client
|
self.client: XboxLiveClient = client
|
||||||
self.consoles: SmartglassConsoleList = consoles
|
self.consoles: SmartglassConsoleList = consoles
|
||||||
|
|
||||||
@ -230,7 +230,7 @@ class XboxUpdateCoordinator(DataUpdateCoordinator):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Update user presence
|
# Update user presence
|
||||||
presence_data = {}
|
presence_data: dict[str, PresenceData] = {}
|
||||||
batch: PeopleResponse = await self.client.people.get_friends_own_batch(
|
batch: PeopleResponse = await self.client.people.get_friends_own_batch(
|
||||||
[self.client.xuid]
|
[self.client.xuid]
|
||||||
)
|
)
|
||||||
@ -262,7 +262,7 @@ def _build_presence_data(person: Person) -> PresenceData:
|
|||||||
online=person.presence_state == "Online",
|
online=person.presence_state == "Online",
|
||||||
status=person.presence_text,
|
status=person.presence_text,
|
||||||
in_party=person.multiplayer_summary.in_party > 0,
|
in_party=person.multiplayer_summary.in_party > 0,
|
||||||
in_game=active_app and active_app.is_game,
|
in_game=active_app is not None and active_app.is_game,
|
||||||
in_multiplayer=person.multiplayer_summary.in_multiplayer_session,
|
in_multiplayer=person.multiplayer_summary.in_multiplayer_session,
|
||||||
gamer_score=person.gamer_score,
|
gamer_score=person.gamer_score,
|
||||||
gold_tenure=person.detail.tenure,
|
gold_tenure=person.detail.tenure,
|
||||||
|
@ -33,7 +33,7 @@ class XboxBaseSensorEntity(CoordinatorEntity[XboxUpdateCoordinator]):
|
|||||||
return self.coordinator.data.presence.get(self.xuid)
|
return self.coordinator.data.presence.get(self.xuid)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self) -> str:
|
def name(self) -> str | None:
|
||||||
"""Return the name of the sensor."""
|
"""Return the name of the sensor."""
|
||||||
if not self.data:
|
if not self.data:
|
||||||
return None
|
return None
|
||||||
@ -45,7 +45,7 @@ class XboxBaseSensorEntity(CoordinatorEntity[XboxUpdateCoordinator]):
|
|||||||
return f"{self.data.gamertag} {attr_name}"
|
return f"{self.data.gamertag} {attr_name}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def entity_picture(self) -> str:
|
def entity_picture(self) -> str | None:
|
||||||
"""Return the gamer pic."""
|
"""Return the gamer pic."""
|
||||||
if not self.data:
|
if not self.data:
|
||||||
return None
|
return None
|
||||||
|
@ -54,7 +54,7 @@ def async_update_friends(
|
|||||||
current_ids = set(current)
|
current_ids = set(current)
|
||||||
|
|
||||||
# Process new favorites, add them to Home Assistant
|
# Process new favorites, add them to Home Assistant
|
||||||
new_entities = []
|
new_entities: list[XboxBinarySensorEntity] = []
|
||||||
for xuid in new_ids - current_ids:
|
for xuid in new_ids - current_ids:
|
||||||
current[xuid] = [
|
current[xuid] = [
|
||||||
XboxBinarySensorEntity(coordinator, xuid, attribute)
|
XboxBinarySensorEntity(coordinator, xuid, attribute)
|
||||||
@ -75,7 +75,7 @@ def async_update_friends(
|
|||||||
async def async_remove_entities(
|
async def async_remove_entities(
|
||||||
xuid: str,
|
xuid: str,
|
||||||
coordinator: XboxUpdateCoordinator,
|
coordinator: XboxUpdateCoordinator,
|
||||||
current: dict[str, XboxBinarySensorEntity],
|
current: dict[str, list[XboxBinarySensorEntity]],
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Remove friend sensors from Home Assistant."""
|
"""Remove friend sensors from Home Assistant."""
|
||||||
registry = er.async_get(coordinator.hass)
|
registry = er.async_get(coordinator.hass)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
"""Support for media browsing."""
|
"""Support for media browsing."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import NamedTuple
|
from typing import TYPE_CHECKING, NamedTuple
|
||||||
|
|
||||||
from xbox.webapi.api.client import XboxLiveClient
|
from xbox.webapi.api.client import XboxLiveClient
|
||||||
from xbox.webapi.api.provider.catalog.const import HOME_APP_IDS, SYSTEM_PFN_ID_MAP
|
from xbox.webapi.api.provider.catalog.const import HOME_APP_IDS, SYSTEM_PFN_ID_MAP
|
||||||
@ -65,6 +65,8 @@ async def build_item_response(
|
|||||||
can_expand=True,
|
can_expand=True,
|
||||||
children=[],
|
children=[],
|
||||||
)
|
)
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
assert library_info.children is not None
|
||||||
|
|
||||||
# Add Home
|
# Add Home
|
||||||
id_type = AlternateIdType.LEGACY_XBOX_PRODUCT_ID
|
id_type = AlternateIdType.LEGACY_XBOX_PRODUCT_ID
|
||||||
@ -84,7 +86,7 @@ async def build_item_response(
|
|||||||
title="Home",
|
title="Home",
|
||||||
can_play=True,
|
can_play=True,
|
||||||
can_expand=False,
|
can_expand=False,
|
||||||
thumbnail=home_thumb.uri,
|
thumbnail=None if home_thumb is None else home_thumb.uri,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -107,7 +109,7 @@ async def build_item_response(
|
|||||||
title="Live TV",
|
title="Live TV",
|
||||||
can_play=True,
|
can_play=True,
|
||||||
can_expand=False,
|
can_expand=False,
|
||||||
thumbnail=tv_thumb.uri,
|
thumbnail=None if tv_thumb is None else tv_thumb.uri,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ def async_parse_identifier(
|
|||||||
identifier = item.identifier or ""
|
identifier = item.identifier or ""
|
||||||
start = ["", "", ""]
|
start = ["", "", ""]
|
||||||
items = identifier.lstrip("/").split("~~", 2)
|
items = identifier.lstrip("/").split("~~", 2)
|
||||||
return tuple(items + start[len(items) :])
|
return tuple(items + start[len(items) :]) # type: ignore[return-value]
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
@ -201,7 +201,7 @@ class XboxSource(MediaSource):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _build_game_item(item: InstalledPackage, images: list[Image]):
|
def _build_game_item(item: InstalledPackage, images: dict[str, list[Image]]):
|
||||||
"""Build individual game."""
|
"""Build individual game."""
|
||||||
thumbnail = ""
|
thumbnail = ""
|
||||||
image = _find_media_image(images.get(item.one_store_product_id, []))
|
image = _find_media_image(images.get(item.one_store_product_id, []))
|
||||||
|
@ -56,7 +56,7 @@ def async_update_friends(
|
|||||||
current_ids = set(current)
|
current_ids = set(current)
|
||||||
|
|
||||||
# Process new favorites, add them to Home Assistant
|
# Process new favorites, add them to Home Assistant
|
||||||
new_entities = []
|
new_entities: list[XboxSensorEntity] = []
|
||||||
for xuid in new_ids - current_ids:
|
for xuid in new_ids - current_ids:
|
||||||
current[xuid] = [
|
current[xuid] = [
|
||||||
XboxSensorEntity(coordinator, xuid, attribute)
|
XboxSensorEntity(coordinator, xuid, attribute)
|
||||||
@ -77,7 +77,7 @@ def async_update_friends(
|
|||||||
async def async_remove_entities(
|
async def async_remove_entities(
|
||||||
xuid: str,
|
xuid: str,
|
||||||
coordinator: XboxUpdateCoordinator,
|
coordinator: XboxUpdateCoordinator,
|
||||||
current: dict[str, XboxSensorEntity],
|
current: dict[str, list[XboxSensorEntity]],
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Remove friend sensors from Home Assistant."""
|
"""Remove friend sensors from Home Assistant."""
|
||||||
registry = er.async_get(coordinator.hass)
|
registry = er.async_get(coordinator.hass)
|
||||||
|
18
mypy.ini
18
mypy.ini
@ -2842,21 +2842,3 @@ ignore_errors = true
|
|||||||
|
|
||||||
[mypy-homeassistant.components.withings.config_flow]
|
[mypy-homeassistant.components.withings.config_flow]
|
||||||
ignore_errors = true
|
ignore_errors = true
|
||||||
|
|
||||||
[mypy-homeassistant.components.xbox]
|
|
||||||
ignore_errors = true
|
|
||||||
|
|
||||||
[mypy-homeassistant.components.xbox.base_sensor]
|
|
||||||
ignore_errors = true
|
|
||||||
|
|
||||||
[mypy-homeassistant.components.xbox.binary_sensor]
|
|
||||||
ignore_errors = true
|
|
||||||
|
|
||||||
[mypy-homeassistant.components.xbox.browse_media]
|
|
||||||
ignore_errors = true
|
|
||||||
|
|
||||||
[mypy-homeassistant.components.xbox.media_source]
|
|
||||||
ignore_errors = true
|
|
||||||
|
|
||||||
[mypy-homeassistant.components.xbox.sensor]
|
|
||||||
ignore_errors = true
|
|
||||||
|
@ -82,12 +82,6 @@ IGNORED_MODULES: Final[list[str]] = [
|
|||||||
"homeassistant.components.withings.binary_sensor",
|
"homeassistant.components.withings.binary_sensor",
|
||||||
"homeassistant.components.withings.common",
|
"homeassistant.components.withings.common",
|
||||||
"homeassistant.components.withings.config_flow",
|
"homeassistant.components.withings.config_flow",
|
||||||
"homeassistant.components.xbox",
|
|
||||||
"homeassistant.components.xbox.base_sensor",
|
|
||||||
"homeassistant.components.xbox.binary_sensor",
|
|
||||||
"homeassistant.components.xbox.browse_media",
|
|
||||||
"homeassistant.components.xbox.media_source",
|
|
||||||
"homeassistant.components.xbox.sensor",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
# Component modules which should set no_implicit_reexport = true.
|
# Component modules which should set no_implicit_reexport = true.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user