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