From 27c08bcb5efbe705438c2ff6751f49ea789815f9 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Thu, 13 Jun 2024 11:57:45 +0200 Subject: [PATCH] Fix dangerous-default-value warnings in lastfm tests (#119601) --- tests/components/lastfm/__init__.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/components/lastfm/__init__.py b/tests/components/lastfm/__init__.py index 8f133607c8d..9fe946f8dff 100644 --- a/tests/components/lastfm/__init__.py +++ b/tests/components/lastfm/__init__.py @@ -6,6 +6,7 @@ from pylast import PyLastError, Track from homeassistant.components.lastfm.const import CONF_MAIN_USER, CONF_USERS from homeassistant.const import CONF_API_KEY +from homeassistant.helpers.typing import UNDEFINED, UndefinedType API_KEY = "asdasdasdasdasd" USERNAME_1 = "testaccount1" @@ -52,16 +53,16 @@ class MockUser: username: str = USERNAME_1, now_playing_result: Track | None = None, thrown_error: Exception | None = None, - friends: list = [], - recent_tracks: list[Track] = [], - top_tracks: list[Track] = [], + friends: list | UndefinedType = UNDEFINED, + recent_tracks: list[Track] | UndefinedType = UNDEFINED, + top_tracks: list[Track] | UndefinedType = UNDEFINED, ) -> None: """Initialize the mock.""" self._now_playing_result = now_playing_result self._thrown_error = thrown_error - self._friends = friends - self._recent_tracks = recent_tracks - self._top_tracks = top_tracks + self._friends = [] if friends is UNDEFINED else friends + self._recent_tracks = [] if recent_tracks is UNDEFINED else recent_tracks + self._top_tracks = [] if top_tracks is UNDEFINED else top_tracks self.name = username def get_name(self, capitalized: bool) -> str: