mirror of
https://github.com/home-assistant/core.git
synced 2025-06-25 01:21:51 +02:00
Enable pydantic.v1 mypy plugin (#132907)
This commit is contained in:
@ -137,7 +137,7 @@ VALID_MEDIA_TYPES: Final[tuple] = (
|
||||
# Fallback sources to use in case of API failure.
|
||||
FALLBACK_SOURCES: Final[SourceArray] = SourceArray(
|
||||
items=[
|
||||
Source( # type: ignore[call-arg]
|
||||
Source(
|
||||
id="uriStreamer",
|
||||
is_enabled=True,
|
||||
is_playable=True,
|
||||
@ -145,7 +145,7 @@ FALLBACK_SOURCES: Final[SourceArray] = SourceArray(
|
||||
type=SourceTypeEnum(value="uriStreamer"),
|
||||
is_seekable=False,
|
||||
),
|
||||
Source( # type: ignore[call-arg]
|
||||
Source(
|
||||
id="bluetooth",
|
||||
is_enabled=True,
|
||||
is_playable=True,
|
||||
@ -153,7 +153,7 @@ FALLBACK_SOURCES: Final[SourceArray] = SourceArray(
|
||||
type=SourceTypeEnum(value="bluetooth"),
|
||||
is_seekable=False,
|
||||
),
|
||||
Source( # type: ignore[call-arg]
|
||||
Source(
|
||||
id="spotify",
|
||||
is_enabled=True,
|
||||
is_playable=True,
|
||||
@ -161,7 +161,7 @@ FALLBACK_SOURCES: Final[SourceArray] = SourceArray(
|
||||
type=SourceTypeEnum(value="spotify"),
|
||||
is_seekable=True,
|
||||
),
|
||||
Source( # type: ignore[call-arg]
|
||||
Source(
|
||||
id="lineIn",
|
||||
is_enabled=True,
|
||||
is_playable=True,
|
||||
@ -169,7 +169,7 @@ FALLBACK_SOURCES: Final[SourceArray] = SourceArray(
|
||||
type=SourceTypeEnum(value="lineIn"),
|
||||
is_seekable=False,
|
||||
),
|
||||
Source( # type: ignore[call-arg]
|
||||
Source(
|
||||
id="spdif",
|
||||
is_enabled=True,
|
||||
is_playable=True,
|
||||
@ -177,7 +177,7 @@ FALLBACK_SOURCES: Final[SourceArray] = SourceArray(
|
||||
type=SourceTypeEnum(value="spdif"),
|
||||
is_seekable=False,
|
||||
),
|
||||
Source( # type: ignore[call-arg]
|
||||
Source(
|
||||
id="netRadio",
|
||||
is_enabled=True,
|
||||
is_playable=True,
|
||||
@ -185,7 +185,7 @@ FALLBACK_SOURCES: Final[SourceArray] = SourceArray(
|
||||
type=SourceTypeEnum(value="netRadio"),
|
||||
is_seekable=False,
|
||||
),
|
||||
Source( # type: ignore[call-arg]
|
||||
Source(
|
||||
id="deezer",
|
||||
is_enabled=True,
|
||||
is_playable=True,
|
||||
@ -193,7 +193,7 @@ FALLBACK_SOURCES: Final[SourceArray] = SourceArray(
|
||||
type=SourceTypeEnum(value="deezer"),
|
||||
is_seekable=True,
|
||||
),
|
||||
Source( # type: ignore[call-arg]
|
||||
Source(
|
||||
id="tidalConnect",
|
||||
is_enabled=True,
|
||||
is_playable=True,
|
||||
|
@ -42,7 +42,7 @@ class BangOlufsenBase:
|
||||
|
||||
# Objects that get directly updated by notifications.
|
||||
self._playback_metadata: PlaybackContentMetadata = PlaybackContentMetadata()
|
||||
self._playback_progress: PlaybackProgress = PlaybackProgress(total_duration=0) # type: ignore[call-arg]
|
||||
self._playback_progress: PlaybackProgress = PlaybackProgress(total_duration=0)
|
||||
self._playback_source: Source = Source()
|
||||
self._playback_state: RenderingState = RenderingState()
|
||||
self._source_change: Source = Source()
|
||||
|
@ -210,9 +210,9 @@ class BangOlufsenMediaPlayer(BangOlufsenEntity, MediaPlayerEntity):
|
||||
# Misc. variables.
|
||||
self._audio_sources: dict[str, str] = {}
|
||||
self._media_image: Art = Art()
|
||||
self._software_status: SoftwareUpdateStatus = SoftwareUpdateStatus( # type: ignore[call-arg]
|
||||
self._software_status: SoftwareUpdateStatus = SoftwareUpdateStatus(
|
||||
software_version="",
|
||||
state=SoftwareUpdateState(seconds_remaining=0, value="idle"), # type: ignore[call-arg]
|
||||
state=SoftwareUpdateState(seconds_remaining=0, value="idle"),
|
||||
)
|
||||
self._sources: dict[str, str] = {}
|
||||
self._state: str = MediaPlayerState.IDLE
|
||||
@ -896,9 +896,9 @@ class BangOlufsenMediaPlayer(BangOlufsenEntity, MediaPlayerEntity):
|
||||
|
||||
elif media_type == BangOlufsenMediaType.RADIO:
|
||||
await self._client.run_provided_scene(
|
||||
scene_properties=SceneProperties( # type: ignore[call-arg]
|
||||
scene_properties=SceneProperties(
|
||||
action_list=[
|
||||
Action( # type: ignore[call-arg]
|
||||
Action(
|
||||
type="radio",
|
||||
radio_station_id=media_id,
|
||||
)
|
||||
@ -919,7 +919,7 @@ class BangOlufsenMediaPlayer(BangOlufsenEntity, MediaPlayerEntity):
|
||||
deezer_id = kwargs[ATTR_MEDIA_EXTRA]["id"]
|
||||
|
||||
await self._client.start_deezer_flow(
|
||||
user_flow=UserFlow(user_id=deezer_id) # type: ignore[call-arg]
|
||||
user_flow=UserFlow(user_id=deezer_id)
|
||||
)
|
||||
|
||||
# Play a playlist or album.
|
||||
@ -929,7 +929,7 @@ class BangOlufsenMediaPlayer(BangOlufsenEntity, MediaPlayerEntity):
|
||||
start_from = kwargs[ATTR_MEDIA_EXTRA]["start_from"]
|
||||
|
||||
await self._client.add_to_queue(
|
||||
play_queue_item=PlayQueueItem( # type: ignore[call-arg]
|
||||
play_queue_item=PlayQueueItem(
|
||||
provider=PlayQueueItemType(value=media_type),
|
||||
start_now_from_position=start_from,
|
||||
type="playlist",
|
||||
@ -940,7 +940,7 @@ class BangOlufsenMediaPlayer(BangOlufsenEntity, MediaPlayerEntity):
|
||||
# Play a track.
|
||||
else:
|
||||
await self._client.add_to_queue(
|
||||
play_queue_item=PlayQueueItem( # type: ignore[call-arg]
|
||||
play_queue_item=PlayQueueItem(
|
||||
provider=PlayQueueItemType(value=media_type),
|
||||
start_now_from_position=0,
|
||||
type="track",
|
||||
|
@ -277,10 +277,10 @@ async def async_setup_add_event_service(
|
||||
elif EVENT_START_DATETIME in call.data and EVENT_END_DATETIME in call.data:
|
||||
start_dt = call.data[EVENT_START_DATETIME]
|
||||
end_dt = call.data[EVENT_END_DATETIME]
|
||||
start = DateOrDatetime( # type: ignore[call-arg]
|
||||
start = DateOrDatetime(
|
||||
date_time=start_dt, timezone=str(hass.config.time_zone)
|
||||
)
|
||||
end = DateOrDatetime(date_time=end_dt, timezone=str(hass.config.time_zone)) # type: ignore[call-arg]
|
||||
end = DateOrDatetime(date_time=end_dt, timezone=str(hass.config.time_zone))
|
||||
|
||||
if start is None or end is None:
|
||||
raise ValueError(
|
||||
|
@ -272,7 +272,7 @@ async def async_setup_entry(
|
||||
entity_description.search,
|
||||
)
|
||||
else:
|
||||
request_template = SyncEventsRequest( # type: ignore[call-arg]
|
||||
request_template = SyncEventsRequest(
|
||||
calendar_id=calendar_id,
|
||||
start_time=dt_util.now() + SYNC_EVENT_MIN_TIME,
|
||||
)
|
||||
@ -437,11 +437,11 @@ class GoogleCalendarEntity(
|
||||
start: DateOrDatetime
|
||||
end: DateOrDatetime
|
||||
if isinstance(dtstart, datetime):
|
||||
start = DateOrDatetime( # type: ignore[call-arg]
|
||||
start = DateOrDatetime(
|
||||
date_time=dt_util.as_local(dtstart),
|
||||
timezone=str(dt_util.get_default_time_zone()),
|
||||
)
|
||||
end = DateOrDatetime( # type: ignore[call-arg]
|
||||
end = DateOrDatetime(
|
||||
date_time=dt_util.as_local(dtend),
|
||||
timezone=str(dt_util.get_default_time_zone()),
|
||||
)
|
||||
@ -543,8 +543,8 @@ async def async_create_event(entity: GoogleCalendarEntity, call: ServiceCall) ->
|
||||
elif EVENT_START_DATETIME in call.data and EVENT_END_DATETIME in call.data:
|
||||
start_dt = call.data[EVENT_START_DATETIME]
|
||||
end_dt = call.data[EVENT_END_DATETIME]
|
||||
start = DateOrDatetime(date_time=start_dt, timezone=str(hass.config.time_zone)) # type: ignore[call-arg]
|
||||
end = DateOrDatetime(date_time=end_dt, timezone=str(hass.config.time_zone)) # type: ignore[call-arg]
|
||||
start = DateOrDatetime(date_time=start_dt, timezone=str(hass.config.time_zone))
|
||||
end = DateOrDatetime(date_time=end_dt, timezone=str(hass.config.time_zone))
|
||||
|
||||
if start is None or end is None:
|
||||
raise ValueError("Missing required fields to set start or end date/datetime")
|
||||
|
@ -131,7 +131,7 @@ class CalendarQueryUpdateCoordinator(DataUpdateCoordinator[list[Event]]):
|
||||
self, start_date: datetime, end_date: datetime
|
||||
) -> Iterable[Event]:
|
||||
"""Get all events in a specific time frame."""
|
||||
request = ListEventsRequest( # type: ignore[call-arg]
|
||||
request = ListEventsRequest(
|
||||
calendar_id=self.calendar_id,
|
||||
start_time=start_date,
|
||||
end_time=end_date,
|
||||
@ -149,7 +149,7 @@ class CalendarQueryUpdateCoordinator(DataUpdateCoordinator[list[Event]]):
|
||||
|
||||
async def _async_update_data(self) -> list[Event]:
|
||||
"""Fetch data from API endpoint."""
|
||||
request = ListEventsRequest(calendar_id=self.calendar_id, search=self._search) # type: ignore[call-arg]
|
||||
request = ListEventsRequest(calendar_id=self.calendar_id, search=self._search)
|
||||
try:
|
||||
result = await self.calendar_service.async_list_events(request)
|
||||
except ApiException as err:
|
||||
|
2
mypy.ini
2
mypy.ini
@ -5,7 +5,7 @@
|
||||
[mypy]
|
||||
python_version = 3.12
|
||||
platform = linux
|
||||
plugins = pydantic.mypy
|
||||
plugins = pydantic.mypy, pydantic.v1.mypy
|
||||
show_error_codes = true
|
||||
follow_imports = normal
|
||||
local_partial_types = true
|
||||
|
@ -33,7 +33,12 @@ HEADER: Final = """
|
||||
GENERAL_SETTINGS: Final[dict[str, str]] = {
|
||||
"python_version": ".".join(str(x) for x in REQUIRED_PYTHON_VER[:2]),
|
||||
"platform": "linux",
|
||||
"plugins": "pydantic.mypy",
|
||||
"plugins": ", ".join( # noqa: FLY002
|
||||
[
|
||||
"pydantic.mypy",
|
||||
"pydantic.v1.mypy",
|
||||
]
|
||||
),
|
||||
"show_error_codes": "true",
|
||||
"follow_imports": "normal",
|
||||
# "enable_incomplete_feature": ", ".join( # noqa: FLY002
|
||||
|
Reference in New Issue
Block a user