From 301e9e6ea4b20cd7cc69796722aa3ed0d72d21b2 Mon Sep 17 00:00:00 2001 From: "Ilya (Marshal)" Date: Sun, 21 May 2023 23:06:31 +0200 Subject: [PATCH 1/5] =?UTF-8?q?=D0=9F=D0=BE=D0=BB=D0=B5=20pretty=5Fname=20?= =?UTF-8?q?=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D0=B0=20LyricsMajor=20=D1=82?= =?UTF-8?q?=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20=D0=BE=D0=BF=D1=86=D0=B8=D0=BE?= =?UTF-8?q?=D0=BD=D0=B0=D0=BB=D1=8C=D0=BD=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_lyrics_major.py | 3 +-- yandex_music/track/lyrics_major.py | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/test_lyrics_major.py b/tests/test_lyrics_major.py index a74878c1..3a80d6ec 100644 --- a/tests/test_lyrics_major.py +++ b/tests/test_lyrics_major.py @@ -15,12 +15,11 @@ def test_de_json_none(self, client): assert LyricsMajor.de_json({}, client) is None def test_de_json_required(self, client): - json_dict = {'id': self.id, 'name': self.name, 'pretty_name': self.pretty_name} + json_dict = {'id': self.id, 'name': self.name} lyrics_major = LyricsMajor.de_json(json_dict, client) assert lyrics_major.id == self.id assert lyrics_major.name == self.name - assert lyrics_major.pretty_name == self.pretty_name def test_de_json_all(self, client): json_dict = {'id': self.id, 'name': self.name, 'pretty_name': self.pretty_name} diff --git a/yandex_music/track/lyrics_major.py b/yandex_music/track/lyrics_major.py index d1445fe4..a00db453 100644 --- a/yandex_music/track/lyrics_major.py +++ b/yandex_music/track/lyrics_major.py @@ -15,13 +15,13 @@ class LyricsMajor(YandexMusicObject): Args: id (:obj:`int`): Уникальный идентификатор сервиса. name (:obj:`str`): Имя сервиса. - pretty_name (:obj:`str`): Человекочитаемое имя сервиса. + pretty_name (:obj:`str`, optional): Человекочитаемое имя сервиса. client (:obj:`yandex_music.Client`, optional): Клиент Yandex Music. """ id: int name: str - pretty_name: str + pretty_name: Optional[str] = None client: Optional['Client'] = None def __post_init__(self): From 1e458312c6342b82f75198ecc498b8ab04947f2b Mon Sep 17 00:00:00 2001 From: "Ilya (Marshal)" Date: Sun, 21 May 2023 23:40:58 +0200 Subject: [PATCH 2/5] =?UTF-8?q?Revert=20"=D0=9F=D0=BE=D0=BB=D0=B5=20pretty?= =?UTF-8?q?=5Fname=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D0=B0=20LyricsMajor=20?= =?UTF-8?q?=D1=82=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20=D0=BE=D0=BF=D1=86=D0=B8?= =?UTF-8?q?=D0=BE=D0=BD=D0=B0=D0=BB=D1=8C=D0=BD=D0=BE"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 301e9e6ea4b20cd7cc69796722aa3ed0d72d21b2. --- tests/test_lyrics_major.py | 3 ++- yandex_music/track/lyrics_major.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/test_lyrics_major.py b/tests/test_lyrics_major.py index 3a80d6ec..a74878c1 100644 --- a/tests/test_lyrics_major.py +++ b/tests/test_lyrics_major.py @@ -15,11 +15,12 @@ def test_de_json_none(self, client): assert LyricsMajor.de_json({}, client) is None def test_de_json_required(self, client): - json_dict = {'id': self.id, 'name': self.name} + json_dict = {'id': self.id, 'name': self.name, 'pretty_name': self.pretty_name} lyrics_major = LyricsMajor.de_json(json_dict, client) assert lyrics_major.id == self.id assert lyrics_major.name == self.name + assert lyrics_major.pretty_name == self.pretty_name def test_de_json_all(self, client): json_dict = {'id': self.id, 'name': self.name, 'pretty_name': self.pretty_name} diff --git a/yandex_music/track/lyrics_major.py b/yandex_music/track/lyrics_major.py index a00db453..d1445fe4 100644 --- a/yandex_music/track/lyrics_major.py +++ b/yandex_music/track/lyrics_major.py @@ -15,13 +15,13 @@ class LyricsMajor(YandexMusicObject): Args: id (:obj:`int`): Уникальный идентификатор сервиса. name (:obj:`str`): Имя сервиса. - pretty_name (:obj:`str`, optional): Человекочитаемое имя сервиса. + pretty_name (:obj:`str`): Человекочитаемое имя сервиса. client (:obj:`yandex_music.Client`, optional): Клиент Yandex Music. """ id: int name: str - pretty_name: Optional[str] = None + pretty_name: str client: Optional['Client'] = None def __post_init__(self): From 84deae40435a7b21eec8fbeb6d12b6ebd62d695f Mon Sep 17 00:00:00 2001 From: Rirusha <95986183+Rirusha@users.noreply.github.com> Date: Wed, 14 Jun 2023 05:03:29 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=20=D1=82=D0=B8=D0=BF=20=D0=BF=D0=BE=D0=BB=D1=8F=20?= =?UTF-8?q?items=5Furi=20=D0=B2=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D0=B5=20C?= =?UTF-8?q?over=20(#603)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_cover.py | 5 ++++- yandex_music/cover.py | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/test_cover.py b/tests/test_cover.py index ce82c371..fc9fedce 100644 --- a/tests/test_cover.py +++ b/tests/test_cover.py @@ -4,7 +4,10 @@ class TestCover: type = 'pic' uri = 'avatars.yandex.net/get-music-user-playlist/38125/q0ahkhfQE3neTk/%%?1572609906461' - items_uri = None + items_uri = [ + 'avatars.yandex.net/get-music-user-playlist/38125/q0ahkhfQE3neTk/%%?1572609906461', + 'avatars.yandex.net/get-music-user-playlist/38125/q0ahkhfQE3neTk/%%?1572609906461', + ] dir = '/get-music-user-playlist/34120/pvg900XixWaHcr/' version = '1572609906461' custom = True diff --git a/yandex_music/cover.py b/yandex_music/cover.py index 6239817d..fb6c6d8d 100644 --- a/yandex_music/cover.py +++ b/yandex_music/cover.py @@ -14,7 +14,7 @@ class Cover(YandexMusicObject): Attributes: type (:obj:`str`, optional): Тип обложки. uri (:obj:`str`, optional): Ссылка на изображение. - items_uri (:obj:`str`, optional): Список ссылок на изображения. + items_uri (:obj:`list` из :obj:`str`, optional): Список ссылок на изображения. dir (:obj:`str`, optional): Директория хранения изображения на сервере. version (:obj:`str`, optional): Версия. is_custom (:obj:`bool`, optional): Является ли обложка пользовательской. @@ -28,7 +28,7 @@ class Cover(YandexMusicObject): type: Optional[str] = None uri: Optional[str] = None - items_uri: Optional[str] = None + items_uri: Optional[List[str]] = None dir: Optional[str] = None version: Optional[str] = None custom: Optional[bool] = None From a17158323ac7700043db8e93677522d2719300a4 Mon Sep 17 00:00:00 2001 From: "Ilya (Marshal)" Date: Tue, 20 Jun 2023 14:23:41 +0200 Subject: [PATCH 4/5] =?UTF-8?q?=D0=9F=D0=BE=D0=BB=D0=B5=20common=5Fperiod?= =?UTF-8?q?=5Fduration=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D0=B0=20Product=20?= =?UTF-8?q?=D1=82=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20=D0=BE=D0=BF=D1=86=D0=B8?= =?UTF-8?q?=D0=BE=D0=BD=D0=B0=D0=BB=D1=8C=D0=BD=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/conftest.py | 4 ++-- tests/test_product.py | 5 ----- yandex_music/account/product.py | 9 ++++----- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index a7301719..2ec8d935 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -968,13 +968,13 @@ def product(price, licence_text_part): return Product( TestProduct.product_id, TestProduct.type, - TestProduct.common_period_duration, TestProduct.duration, TestProduct.trial_duration, - price, TestProduct.feature, TestProduct.debug, TestProduct.plus, + price, + TestProduct.common_period_duration, TestProduct.cheapest, TestProduct.title, TestProduct.family_sub, diff --git a/tests/test_product.py b/tests/test_product.py index c8192325..5e9428fa 100644 --- a/tests/test_product.py +++ b/tests/test_product.py @@ -69,7 +69,6 @@ def test_de_json_required(self, client, price): json_dict = { 'product_id': self.product_id, 'type': self.type, - 'common_period_duration': self.common_period_duration, 'duration': self.duration, 'trial_duration': self.trial_duration, 'price': price.to_dict(), @@ -81,7 +80,6 @@ def test_de_json_required(self, client, price): assert product.product_id == self.product_id assert product.type == self.type - assert product.common_period_duration == self.common_period_duration assert product.duration == self.duration assert product.trial_duration == self.trial_duration assert product.price == price @@ -157,7 +155,6 @@ def test_equality(self, price): a = Product( self.product_id, self.type, - self.common_period_duration, self.duration, self.trial_duration, price, @@ -168,7 +165,6 @@ def test_equality(self, price): b = Product( '', self.type, - self.common_period_duration, self.duration, self.trial_duration, price, @@ -179,7 +175,6 @@ def test_equality(self, price): c = Product( self.product_id, self.type, - self.common_period_duration, self.duration, self.trial_duration, price, diff --git a/yandex_music/account/product.py b/yandex_music/account/product.py index add4c202..2e3108f3 100644 --- a/yandex_music/account/product.py +++ b/yandex_music/account/product.py @@ -14,13 +14,13 @@ class Product(YandexMusicObject): Attributes: product_id (:obj:`str`): Уникальный идентификатор. type (:obj:`str`): Тип продаваемого. - common_period_duration (:obj:`str`): Длительность общего периода. duration (:obj:`int`): Длительность. trial_duration (:obj:`int`): Длительность испытательного срока. - price (:obj:`yandex_music.Price`): Цена. feature (:obj:`str`): Предоставляемая возможность. debug (:obj:`bool`): Отладочный продукт. plus (:obj:`bool`): Даёт ли подписку "Плюс". + price (:obj:`yandex_music.Price`, optional): Цена. + common_period_duration (:obj:`str`, optional): Длительность общего периода. cheapest (:obj:`bool`, optional): Самый дешёвый (лучшее предложение). title (:obj:`str`, optional): Заголовок продукта. family_sub (:obj:`bool`, optional): Семейная ли подписка. @@ -47,13 +47,13 @@ class Product(YandexMusicObject): product_id: str type: str - common_period_duration: str duration: int trial_duration: int - price: Optional['Price'] feature: str debug: bool plus: bool + price: Optional['Price'] = None + common_period_duration: Optional[str] = None cheapest: Optional[bool] = None title: Optional[str] = None family_sub: Optional[bool] = None @@ -80,7 +80,6 @@ def __post_init__(self): self._id_attrs = ( self.product_id, self.type, - self.common_period_duration, self.duration, self.trial_duration, self.product_id, From 2e7bd8f0104be6e810929b36c12dd607c789a4d1 Mon Sep 17 00:00:00 2001 From: Ilya Siamionau Date: Tue, 15 Aug 2023 14:04:38 +0400 Subject: [PATCH 5/5] =?UTF-8?q?Fallback=20=D0=B4=D0=BE=20None=20=D0=B8?= =?UTF-8?q?=D0=BB=D0=B8=20[]=20=D0=BF=D1=80=D0=B8=20=D0=B4=D0=B0=D0=BD?= =?UTF-8?q?=D0=BD=D1=8B=D1=85=20=D0=BD=D0=B5=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=D1=8C=D0=BD=D0=BE=D0=B3=D0=BE=20=D1=82=D0=B8=D0=BF=D0=B0?= =?UTF-8?q?;=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=20ty?= =?UTF-8?q?pe=20hint=20de=5Flist=20=D0=B8=20=D1=82=D0=B5=D1=81=D1=82=D1=8B?= =?UTF-8?q?=20=D0=BD=D0=B0=20empty=20list=20(#612)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_album.py | 2 +- tests/test_album_event.py | 2 +- tests/test_artist.py | 2 +- tests/test_artist_event.py | 2 +- tests/test_auto_renewable.py | 2 +- tests/test_block.py | 2 +- tests/test_block_entity.py | 2 +- tests/test_chart.py | 2 +- tests/test_chart_item.py | 2 +- tests/test_cover.py | 2 +- tests/test_day.py | 2 +- tests/test_deactivation.py | 2 +- tests/test_download_info.py | 2 +- tests/test_event.py | 2 +- tests/test_generated_playlist.py | 2 +- tests/test_genre.py | 2 +- tests/test_label.py | 2 +- tests/test_licence_text_part.py | 2 +- tests/test_like.py | 2 +- tests/test_link.py | 2 +- tests/test_mix_link.py | 2 +- tests/test_operator.py | 2 +- tests/test_passport_phone.py | 2 +- tests/test_playlist.py | 2 +- tests/test_playlist_id.py | 2 +- tests/test_poetry_lover_match.py | 2 +- tests/test_product.py | 2 +- tests/test_promotion.py | 2 +- tests/test_queue_item.py | 2 +- tests/test_sequence.py | 2 +- tests/test_shot.py | 2 +- tests/test_station_result.py | 2 +- tests/test_track.py | 2 +- tests/test_track_id.py | 2 +- tests/test_track_short.py | 2 +- tests/test_track_short_old.py | 2 +- tests/test_track_with_ads.py | 2 +- tests/test_user.py | 2 +- tests/test_value.py | 2 +- tests/test_video.py | 2 +- tests/test_video_supplement.py | 2 +- tests/test_vinyl.py | 2 +- yandex_music/account/account.py | 2 +- yandex_music/account/alert.py | 2 +- yandex_music/account/alert_button.py | 2 +- yandex_music/account/auto_renewable.py | 6 +++--- yandex_music/account/deactivation.py | 6 +++--- yandex_music/account/non_auto_renewable.py | 2 +- yandex_music/account/operator.py | 6 +++--- yandex_music/account/passport_phone.py | 6 +++--- yandex_music/account/permissions.py | 2 +- yandex_music/account/plus.py | 2 +- yandex_music/account/price.py | 2 +- yandex_music/account/product.py | 6 +++--- yandex_music/account/renewable_remainder.py | 2 +- yandex_music/account/status.py | 2 +- yandex_music/account/subscription.py | 2 +- yandex_music/account/user_settings.py | 2 +- yandex_music/album/album.py | 18 ++++++++++++++---- yandex_music/album/deprecation.py | 2 +- yandex_music/album/label.py | 6 +++--- yandex_music/album/track_position.py | 2 +- yandex_music/artist/artist.py | 6 +++--- yandex_music/artist/artist_albums.py | 2 +- yandex_music/artist/artist_tracks.py | 2 +- yandex_music/artist/brief_info.py | 2 +- yandex_music/artist/counts.py | 2 +- yandex_music/artist/description.py | 2 +- yandex_music/artist/link.py | 6 +++--- yandex_music/artist/ratings.py | 2 +- yandex_music/artist/vinyl.py | 6 +++--- yandex_music/base.py | 11 +++++++++-- yandex_music/cover.py | 6 +++--- yandex_music/download_info.py | 8 ++++---- yandex_music/experiments.py | 2 +- yandex_music/feed/album_event.py | 6 +++--- yandex_music/feed/artist_event.py | 6 +++--- yandex_music/feed/day.py | 6 +++--- yandex_music/feed/event.py | 6 +++--- yandex_music/feed/feed.py | 2 +- yandex_music/feed/generated_playlist.py | 6 +++--- yandex_music/feed/track_with_ads.py | 6 +++--- yandex_music/genre/genre.py | 6 +++--- yandex_music/genre/images.py | 2 +- yandex_music/genre/title.py | 2 +- yandex_music/icon.py | 2 +- yandex_music/invocation_info.py | 2 +- yandex_music/landing/block.py | 6 +++--- yandex_music/landing/block_entity.py | 6 +++--- yandex_music/landing/chart.py | 6 +++--- yandex_music/landing/chart_info.py | 2 +- yandex_music/landing/chart_info_menu.py | 2 +- yandex_music/landing/chart_info_menu_item.py | 4 ++-- yandex_music/landing/chart_item.py | 6 +++--- yandex_music/landing/landing.py | 2 +- yandex_music/landing/landing_list.py | 2 +- yandex_music/landing/mix_link.py | 6 +++--- .../landing/personal_playlists_data.py | 2 +- yandex_music/landing/play_context.py | 2 +- yandex_music/landing/play_contexts_data.py | 2 +- yandex_music/landing/promotion.py | 6 +++--- yandex_music/landing/track_id.py | 6 +++--- yandex_music/landing/track_short_old.py | 6 +++--- yandex_music/like.py | 6 +++--- yandex_music/pager.py | 2 +- yandex_music/permission_alerts.py | 2 +- yandex_music/playlist/brand.py | 2 +- yandex_music/playlist/case_forms.py | 2 +- yandex_music/playlist/contest.py | 2 +- yandex_music/playlist/custom_wave.py | 2 +- yandex_music/playlist/made_for.py | 2 +- yandex_music/playlist/open_graph_data.py | 2 +- yandex_music/playlist/play_counter.py | 2 +- yandex_music/playlist/playlist.py | 6 +++--- yandex_music/playlist/playlist_absence.py | 2 +- yandex_music/playlist/playlist_id.py | 6 +++--- .../playlist/playlist_recommendation.py | 2 +- yandex_music/playlist/tag.py | 2 +- yandex_music/playlist/tag_result.py | 2 +- yandex_music/playlist/user.py | 6 +++--- yandex_music/promo_code_status.py | 2 +- yandex_music/queue/context.py | 2 +- yandex_music/queue/queue.py | 2 +- yandex_music/queue/queue_item.py | 6 +++--- yandex_music/rotor/ad_params.py | 2 +- yandex_music/rotor/dashboard.py | 2 +- yandex_music/rotor/discrete_scale.py | 2 +- yandex_music/rotor/enum.py | 2 +- yandex_music/rotor/id.py | 2 +- yandex_music/rotor/restrictions.py | 2 +- yandex_music/rotor/rotor_settings.py | 2 +- yandex_music/rotor/sequence.py | 6 +++--- yandex_music/rotor/station.py | 2 +- yandex_music/rotor/station_data.py | 2 +- yandex_music/rotor/station_result.py | 6 +++--- yandex_music/rotor/station_tracks_result.py | 2 +- yandex_music/rotor/value.py | 6 +++--- yandex_music/search/best.py | 2 +- yandex_music/search/search.py | 2 +- yandex_music/search/search_result.py | 2 +- yandex_music/search/suggestions.py | 2 +- yandex_music/settings.py | 2 +- yandex_music/shot/shot.py | 6 +++--- yandex_music/shot/shot_data.py | 2 +- yandex_music/shot/shot_event.py | 2 +- yandex_music/shot/shot_type.py | 2 +- yandex_music/supplement/lyrics.py | 2 +- yandex_music/supplement/supplement.py | 2 +- yandex_music/supplement/video_supplement.py | 6 +++--- yandex_music/track/licence_text_part.py | 6 +++--- yandex_music/track/lyrics_info.py | 2 +- yandex_music/track/lyrics_major.py | 2 +- yandex_music/track/major.py | 2 +- yandex_music/track/meta_data.py | 2 +- yandex_music/track/normalization.py | 2 +- yandex_music/track/poetry_lover_match.py | 6 +++--- yandex_music/track/r128.py | 2 +- yandex_music/track/track.py | 6 +++--- yandex_music/track/track_lyrics.py | 2 +- yandex_music/track/tracks_similar.py | 2 +- yandex_music/track_short.py | 6 +++--- yandex_music/tracks_list.py | 2 +- yandex_music/utils/response.py | 2 +- yandex_music/video.py | 6 +++--- 164 files changed, 269 insertions(+), 252 deletions(-) diff --git a/tests/test_album.py b/tests/test_album.py index d150f59b..674bff6b 100644 --- a/tests/test_album.py +++ b/tests/test_album.py @@ -108,7 +108,7 @@ def test_de_json_none(self, client): assert Album.de_json({}, client) is None def test_de_list_none(self, client): - assert Album.de_list({}, client) == [] + assert Album.de_list([], client) == [] def test_de_json_required(self, client): json_dict = {'id': self.id} diff --git a/tests/test_album_event.py b/tests/test_album_event.py index 65e21737..0b477923 100644 --- a/tests/test_album_event.py +++ b/tests/test_album_event.py @@ -10,7 +10,7 @@ def test_de_json_none(self, client): assert AlbumEvent.de_json({}, client) is None def test_de_list_none(self, client): - assert AlbumEvent.de_list({}, client) == [] + assert AlbumEvent.de_list([], client) == [] def test_de_json_required(self, client, album, track): json_dict = {'album': album.to_dict(), 'tracks': [track.to_dict()]} diff --git a/tests/test_artist.py b/tests/test_artist.py index edcf6963..180fc3bd 100644 --- a/tests/test_artist.py +++ b/tests/test_artist.py @@ -67,7 +67,7 @@ def test_de_json_none(self, client): assert Artist.de_json({}, client) is None def test_de_list_none(self, client): - assert Artist.de_list({}, client) == [] + assert Artist.de_list([], client) == [] def test_de_json_required(self, client, cover): json_dict = {'id': self.id} diff --git a/tests/test_artist_event.py b/tests/test_artist_event.py index a0be46c1..f4da6a1c 100644 --- a/tests/test_artist_event.py +++ b/tests/test_artist_event.py @@ -14,7 +14,7 @@ def test_de_json_none(self, client): assert ArtistEvent.de_json({}, client) is None def test_de_list_none(self, client): - assert ArtistEvent.de_list({}, client) == [] + assert ArtistEvent.de_list([], client) == [] def test_de_json_required(self, client, artist, track): json_dict = { diff --git a/tests/test_auto_renewable.py b/tests/test_auto_renewable.py index 441ff5f1..f20b5509 100644 --- a/tests/test_auto_renewable.py +++ b/tests/test_auto_renewable.py @@ -23,7 +23,7 @@ def test_de_json_none(self, client): assert AutoRenewable.de_json({}, client) is None def test_de_list_none(self, client): - assert AutoRenewable.de_list({}, client) == [] + assert AutoRenewable.de_list([], client) == [] def test_de_json_required(self, client, product): json_dict = { diff --git a/tests/test_block.py b/tests/test_block.py index 7d58f47b..b5f358d9 100644 --- a/tests/test_block.py +++ b/tests/test_block.py @@ -42,7 +42,7 @@ def test_de_json_none(self, client): assert Block.de_json({}, client) is None def test_de_list_none(self, client): - assert Block.de_list({}, client) == [] + assert Block.de_list([], client) == [] def test_de_json_required(self, client, block_entity): json_dict = { diff --git a/tests/test_block_entity.py b/tests/test_block_entity.py index 9de57342..122fa1a8 100644 --- a/tests/test_block_entity.py +++ b/tests/test_block_entity.py @@ -29,7 +29,7 @@ def test_expected_values(self, block_entity_with_data_and_type): assert block_entity.data == data def test_de_list_none(self, client): - assert BlockEntity.de_list({}, client) == [] + assert BlockEntity.de_list([], client) == [] def test_de_json_none(self, client): assert BlockEntity.de_json({}, client) is None diff --git a/tests/test_chart.py b/tests/test_chart.py index 229284b8..45c4f44c 100644 --- a/tests/test_chart.py +++ b/tests/test_chart.py @@ -20,7 +20,7 @@ def test_de_json_none(self, client): assert Chart.de_json({}, client) is None def test_de_list_none(self, client): - assert Chart.de_list({}, client) == [] + assert Chart.de_list([], client) == [] def test_de_json_required(self, client): json_dict = { diff --git a/tests/test_chart_item.py b/tests/test_chart_item.py index 190b11a3..c31a0585 100644 --- a/tests/test_chart_item.py +++ b/tests/test_chart_item.py @@ -10,7 +10,7 @@ def test_de_json_none(self, client): assert ChartItem.de_json({}, client) is None def test_de_list_none(self, client): - assert ChartItem.de_list({}, client) == [] + assert ChartItem.de_list([], client) == [] def test_de_json_required(self, client, track, chart): json_dict = {'track': track.to_dict(), 'chart': chart.to_dict()} diff --git a/tests/test_cover.py b/tests/test_cover.py index fc9fedce..9c9f9908 100644 --- a/tests/test_cover.py +++ b/tests/test_cover.py @@ -34,7 +34,7 @@ def test_de_json_none(self, client): assert Cover.de_json({}, client) is None def test_de_list_none(self, client): - assert Cover.de_list({}, client) == [] + assert Cover.de_list([], client) == [] def test_de_json_required(self, client): json_dict = {} diff --git a/tests/test_day.py b/tests/test_day.py index d24141a3..a2e3880d 100644 --- a/tests/test_day.py +++ b/tests/test_day.py @@ -14,7 +14,7 @@ def test_de_json_none(self, client): assert Day.de_json({}, client) is None def test_de_list_none(self, client): - assert Day.de_list({}, client) == [] + assert Day.de_list([], client) == [] def test_de_json_required(self, client, event, track_with_ads, track): json_dict = { diff --git a/tests/test_deactivation.py b/tests/test_deactivation.py index f495b384..18bb3c4f 100644 --- a/tests/test_deactivation.py +++ b/tests/test_deactivation.py @@ -13,7 +13,7 @@ def test_de_json_none(self, client): assert Deactivation.de_json({}, client) is None def test_de_list_none(self, client): - assert Deactivation.de_list({}, client) == [] + assert Deactivation.de_list([], client) == [] def test_de_json_required(self, client): json_dict = {'method': self.method} diff --git a/tests/test_download_info.py b/tests/test_download_info.py index 7d13396f..b58043c3 100644 --- a/tests/test_download_info.py +++ b/tests/test_download_info.py @@ -38,7 +38,7 @@ def test_de_json_none(self, client): assert DownloadInfo.de_json({}, client) is None def test_de_list_none(self, client): - assert DownloadInfo.de_list({}, client) == [] + assert DownloadInfo.de_list([], client) == [] def test_de_json_required(self, client): json_dict = { diff --git a/tests/test_event.py b/tests/test_event.py index 17f8afd5..f71c29fe 100644 --- a/tests/test_event.py +++ b/tests/test_event.py @@ -28,7 +28,7 @@ def test_de_json_none(self, client): assert Event.de_json({}, client) is None def test_de_list_none(self, client): - assert Event.de_list({}, client) == [] + assert Event.de_list([], client) == [] def test_de_json_required(self, client): json_dict = {'id': self.id, 'type': self.type} diff --git a/tests/test_generated_playlist.py b/tests/test_generated_playlist.py index 25af9053..c2e7f667 100644 --- a/tests/test_generated_playlist.py +++ b/tests/test_generated_playlist.py @@ -20,7 +20,7 @@ def test_de_json_none(self, client): assert GeneratedPlaylist.de_json({}, client) is None def test_de_list_none(self, client): - assert GeneratedPlaylist.de_list({}, client) == [] + assert GeneratedPlaylist.de_list([], client) == [] def test_de_json_required(self, client, playlist): json_dict = {'type': self.type, 'ready': self.ready, 'notify': self.notify, 'data': playlist.to_dict()} diff --git a/tests/test_genre.py b/tests/test_genre.py index cb069a30..72081f7b 100644 --- a/tests/test_genre.py +++ b/tests/test_genre.py @@ -68,7 +68,7 @@ def test_de_json_none(self, client): assert Genre.de_json({}, client) is None def test_de_list_none(self, client): - assert Genre.de_list({}, client) == [] + assert Genre.de_list([], client) == [] def test_de_json_required(self, client, title, images): json_dict = { diff --git a/tests/test_label.py b/tests/test_label.py index 317e8e3a..84f3c5ab 100644 --- a/tests/test_label.py +++ b/tests/test_label.py @@ -15,7 +15,7 @@ def test_expected_values(self, label): assert label.name == self.name def test_de_list_none(self, client): - assert Label.de_list({}, client) == [] + assert Label.de_list([], client) == [] def test_de_json_none(self, client): assert Label.de_json({}, client) is None diff --git a/tests/test_licence_text_part.py b/tests/test_licence_text_part.py index d291bf4f..9c28cc60 100644 --- a/tests/test_licence_text_part.py +++ b/tests/test_licence_text_part.py @@ -13,7 +13,7 @@ def test_de_json_none(self, client): assert LicenceTextPart.de_json({}, client) is None def test_de_list_none(self, client): - assert LicenceTextPart.de_list({}, client) == [] + assert LicenceTextPart.de_list([], client) == [] def test_de_json_required(self, client): json_dict = {'text': self.text} diff --git a/tests/test_like.py b/tests/test_like.py index c47d4188..fefe65f9 100644 --- a/tests/test_like.py +++ b/tests/test_like.py @@ -49,7 +49,7 @@ def test_de_json_none(self, client): assert Like.de_json({}, client) is None def test_de_list_none(self, client): - assert Like.de_list({}, client) == [] + assert Like.de_list([], client) == [] @pytest.mark.parametrize('param', [2, 3, 4]) def test_de_json_all(self, results, types, client, param): diff --git a/tests/test_link.py b/tests/test_link.py index 124fcc92..b54addc5 100644 --- a/tests/test_link.py +++ b/tests/test_link.py @@ -17,7 +17,7 @@ def test_de_json_none(self, client): assert Link.de_json({}, client) is None def test_de_list_none(self, client): - assert Link.de_list({}, client) == [] + assert Link.de_list([], client) == [] def test_de_json_required(self, client): json_dict = {'title': self.title, 'href': self.href, 'type': self.type} diff --git a/tests/test_mix_link.py b/tests/test_mix_link.py index 6fcd8218..3e1c4340 100644 --- a/tests/test_mix_link.py +++ b/tests/test_mix_link.py @@ -27,7 +27,7 @@ def test_de_json_none(self, client): assert MixLink.de_json({}, client) is None def test_de_list_none(self, client): - assert MixLink.de_list({}, client) == [] + assert MixLink.de_list([], client) == [] def test_de_json_required(self, client): json_dict = { diff --git a/tests/test_operator.py b/tests/test_operator.py index eb4ac39d..97995e56 100644 --- a/tests/test_operator.py +++ b/tests/test_operator.py @@ -20,7 +20,7 @@ def test_de_json_none(self, client): assert Operator.de_json({}, client) is None def test_de_list_none(self, client): - assert Operator.de_list({}, client) == [] + assert Operator.de_list([], client) == [] def test_de_json_required(self, client, deactivation): json_dict = { diff --git a/tests/test_passport_phone.py b/tests/test_passport_phone.py index c3e198b3..48c41133 100644 --- a/tests/test_passport_phone.py +++ b/tests/test_passport_phone.py @@ -11,7 +11,7 @@ def test_de_json_none(self, client): assert PassportPhone.de_json({}, client) is None def test_de_list_none(self, client): - assert PassportPhone.de_list({}, client) == [] + assert PassportPhone.de_list([], client) == [] def test_de_json_required(self, client): json_dict = {'phone': self.phone} diff --git a/tests/test_playlist.py b/tests/test_playlist.py index 88927d1c..e2067994 100644 --- a/tests/test_playlist.py +++ b/tests/test_playlist.py @@ -124,7 +124,7 @@ def test_de_json_none(self, client): assert Playlist.de_json({}, client) is None def test_de_list_none(self, client): - assert Playlist.de_list({}, client) == [] + assert Playlist.de_list([], client) == [] def test_de_json_required(self, client, user, cover, made_for, play_counter, playlist_absence): json_dict = { diff --git a/tests/test_playlist_id.py b/tests/test_playlist_id.py index a9398315..9a534530 100644 --- a/tests/test_playlist_id.py +++ b/tests/test_playlist_id.py @@ -13,7 +13,7 @@ def test_de_json_none(self, client): assert PlaylistId.de_json({}, client) is None def test_de_list_none(self, client): - assert PlaylistId.de_list({}, client) == [] + assert PlaylistId.de_list([], client) == [] def test_de_json_required(self, client): json_dict = {'uid': self.uid, 'kind': self.kind} diff --git a/tests/test_poetry_lover_match.py b/tests/test_poetry_lover_match.py index 979767df..36269ed0 100644 --- a/tests/test_poetry_lover_match.py +++ b/tests/test_poetry_lover_match.py @@ -15,7 +15,7 @@ def test_de_json_none(self, client): assert PoetryLoverMatch.de_json({}, client) is None def test_de_list_none(self, client): - assert PoetryLoverMatch.de_list({}, client) == [] + assert PoetryLoverMatch.de_list([], client) == [] def test_de_json_required(self, client): json_dict = {'begin': self.begin, 'end': self.end, 'line': self.line} diff --git a/tests/test_product.py b/tests/test_product.py index 5e9428fa..9836bca6 100644 --- a/tests/test_product.py +++ b/tests/test_product.py @@ -63,7 +63,7 @@ def test_de_json_none(self, client): assert Product.de_json({}, client) is None def test_de_list_none(self, client): - assert Product.de_list({}, client) == [] + assert Product.de_list([], client) == [] def test_de_json_required(self, client, price): json_dict = { diff --git a/tests/test_promotion.py b/tests/test_promotion.py index 5c6b6aa8..b56b765f 100644 --- a/tests/test_promotion.py +++ b/tests/test_promotion.py @@ -24,7 +24,7 @@ def test_expected_values(self, promotion): assert promotion.image == self.image def test_de_list_none(self, client): - assert Promotion.de_list({}, client) == [] + assert Promotion.de_list([], client) == [] def test_de_json_none(self, client): assert Promotion.de_json({}, client) is None diff --git a/tests/test_queue_item.py b/tests/test_queue_item.py index 2a415d56..076254c3 100644 --- a/tests/test_queue_item.py +++ b/tests/test_queue_item.py @@ -21,7 +21,7 @@ def test_de_json_none(self, client): assert QueueItem.de_json({}, client) is None def test_de_list_none(self, client): - assert QueueItem.de_list({}, client) == [] + assert QueueItem.de_list([], client) == [] def test_de_json_required(self, client, context): json_dict = {'id': self.id_, 'context': context.to_dict(), 'modified': self.modified} diff --git a/tests/test_sequence.py b/tests/test_sequence.py index 0a551b55..2a96f2b4 100644 --- a/tests/test_sequence.py +++ b/tests/test_sequence.py @@ -14,7 +14,7 @@ def test_de_json_none(self, client): assert Sequence.de_json({}, client) is None def test_de_list_none(self, client): - assert Sequence.de_list({}, client) == [] + assert Sequence.de_list([], client) == [] def test_de_json_required(self, client, track): json_dict = {'type': self.type, 'track': track.to_dict(), 'liked': self.liked} diff --git a/tests/test_shot.py b/tests/test_shot.py index 94f4c00a..9975696b 100644 --- a/tests/test_shot.py +++ b/tests/test_shot.py @@ -18,7 +18,7 @@ def test_de_json_none(self, client): assert Shot.de_json({}, client) is None def test_de_list_none(self, client): - assert Shot.de_list({}, client) == [] + assert Shot.de_list([], client) == [] def test_de_json_required(self, client, shot_data): json_dict = { diff --git a/tests/test_station_result.py b/tests/test_station_result.py index e4d1e914..cf64fc1f 100644 --- a/tests/test_station_result.py +++ b/tests/test_station_result.py @@ -23,7 +23,7 @@ def test_de_json_none(self, client): assert StationResult.de_json({}, client) is None def test_de_list_none(self, client): - assert StationResult.de_list({}, client) == [] + assert StationResult.de_list([], client) == [] def test_de_json_required(self, client, station, rotor_settings, ad_params): json_dict = { diff --git a/tests/test_track.py b/tests/test_track.py index 49940b55..21993d67 100644 --- a/tests/test_track.py +++ b/tests/test_track.py @@ -102,7 +102,7 @@ def test_de_json_none(self, client): assert Track.de_json({}, client) is None def test_de_list_none(self, client): - assert Track.de_list({}, client) == [] + assert Track.de_list([], client) == [] def test_de_json_required(self, client, artist, album): json_dict = {'id': self.id} diff --git a/tests/test_track_id.py b/tests/test_track_id.py index a37d8626..dcc0f0ba 100644 --- a/tests/test_track_id.py +++ b/tests/test_track_id.py @@ -17,7 +17,7 @@ def test_de_json_none(self, client): assert TrackId.de_json({}, client) is None def test_de_list_none(self, client): - assert TrackId.de_list({}, client) == [] + assert TrackId.de_list([], client) == [] def test_de_json_all(self, client): json_dict = {'id': self.id, 'track_id': self.track_id, 'album_id': self.album_id, 'from_': self.from_} diff --git a/tests/test_track_short.py b/tests/test_track_short.py index aec00bf8..05688201 100644 --- a/tests/test_track_short.py +++ b/tests/test_track_short.py @@ -39,7 +39,7 @@ def test_de_json_none(self, client): assert TrackShort.de_json({}, client) is None def test_de_list_none(self, client): - assert TrackShort.de_list({}, client) == [] + assert TrackShort.de_list([], client) == [] def test_de_json_required(self, client): json_dict = {'id': self.id, 'timestamp': self.timestamp} diff --git a/tests/test_track_short_old.py b/tests/test_track_short_old.py index 70fab7f5..e7c5e7ee 100644 --- a/tests/test_track_short_old.py +++ b/tests/test_track_short_old.py @@ -12,7 +12,7 @@ def test_de_json_none(self, client): assert TrackShortOld.de_json({}, client) is None def test_de_list_none(self, client): - assert TrackShortOld.de_list({}, client) == [] + assert TrackShortOld.de_list([], client) == [] def test_de_json_required(self, client, track_id): json_dict = {'track_id': track_id.to_dict(), 'timestamp': self.timestamp} diff --git a/tests/test_track_with_ads.py b/tests/test_track_with_ads.py index c3ae287b..79c2cff3 100644 --- a/tests/test_track_with_ads.py +++ b/tests/test_track_with_ads.py @@ -12,7 +12,7 @@ def test_de_json_none(self, client): assert TrackWithAds.de_json({}, client) is None def test_de_list_none(self, client): - assert TrackWithAds.de_list({}, client) == [] + assert TrackWithAds.de_list([], client) == [] def test_de_json_required(self, client, track): json_dict = {'type': self.type, 'track': track.to_dict()} diff --git a/tests/test_user.py b/tests/test_user.py index 700b9776..9167a5f1 100644 --- a/tests/test_user.py +++ b/tests/test_user.py @@ -25,7 +25,7 @@ def test_de_json_none(self, client): assert User.de_json({}, client) is None def test_de_list_none(self, client): - assert User.de_list({}, client) == [] + assert User.de_list([], client) == [] def test_de_json_required(self, client): json_dict = {'uid': self.uid, 'login': self.login} diff --git a/tests/test_value.py b/tests/test_value.py index 7cd2ea4d..e870149b 100644 --- a/tests/test_value.py +++ b/tests/test_value.py @@ -13,7 +13,7 @@ def test_de_json_none(self, client): assert Value.de_json({}, client) is None def test_de_list_none(self, client): - assert Value.de_list({}, client) == [] + assert Value.de_list([], client) == [] def test_de_json_required(self, client): json_dict = {'value': self.value, 'name': self.name} diff --git a/tests/test_video.py b/tests/test_video.py index cf366c98..6391460d 100644 --- a/tests/test_video.py +++ b/tests/test_video.py @@ -31,7 +31,7 @@ def test_de_json_none(self, client): assert Video.de_json({}, client) is None def test_de_list_none(self, client): - assert Video.de_list({}, client) == [] + assert Video.de_list([], client) == [] def test_de_json_required(self, client): json_dict = {'title': self.title} diff --git a/tests/test_video_supplement.py b/tests/test_video_supplement.py index f28bed26..81e43a14 100644 --- a/tests/test_video_supplement.py +++ b/tests/test_video_supplement.py @@ -27,7 +27,7 @@ def test_de_json_none(self, client): assert VideoSupplement.de_json({}, client) is None def test_de_list_none(self, client): - assert VideoSupplement.de_list({}, client) == [] + assert VideoSupplement.de_list([], client) == [] def test_de_json_required(self, client): json_dict = {'cover': self.cover, 'provider': self.provider} diff --git a/tests/test_vinyl.py b/tests/test_vinyl.py index 2a131a45..ea1e1044 100644 --- a/tests/test_vinyl.py +++ b/tests/test_vinyl.py @@ -25,7 +25,7 @@ def test_de_json_none(self, client): assert Vinyl.de_json({}, client) is None def test_de_list_none(self, client): - assert Vinyl.de_list({}, client) == [] + assert Vinyl.de_list([], client) == [] def test_de_json_required(self, client): json_dict = { diff --git a/yandex_music/account/account.py b/yandex_music/account/account.py index 5d9e1a50..d383599e 100644 --- a/yandex_music/account/account.py +++ b/yandex_music/account/account.py @@ -63,7 +63,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Account']: Returns: :obj:`yandex_music.Account`: Основная информация об аккаунте пользователя. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Account, cls).de_json(data, client) diff --git a/yandex_music/account/alert.py b/yandex_music/account/alert.py index a4066828..0faa6fa2 100644 --- a/yandex_music/account/alert.py +++ b/yandex_music/account/alert.py @@ -51,7 +51,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Alert']: Returns: :obj:`yandex_music.Alert`: Сообщение о статусе подписки. """ - if not data: + if not cls.is_valid_model_data(data): return None from yandex_music import AlertButton diff --git a/yandex_music/account/alert_button.py b/yandex_music/account/alert_button.py index 9a18d332..971fdfd8 100644 --- a/yandex_music/account/alert_button.py +++ b/yandex_music/account/alert_button.py @@ -39,7 +39,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['AlertButton']: Returns: :obj:`yandex_music.AlertButton`: Кнопка в статусе о подписки. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(AlertButton, cls).de_json(data, client) diff --git a/yandex_music/account/auto_renewable.py b/yandex_music/account/auto_renewable.py index 577fcc92..f7a996cd 100644 --- a/yandex_music/account/auto_renewable.py +++ b/yandex_music/account/auto_renewable.py @@ -47,7 +47,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['AutoRenewable']: Returns: :obj:`yandex_music.AutoRenewable`: Информация об автопродлении подписки. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(AutoRenewable, cls).de_json(data, client) @@ -59,7 +59,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['AutoRenewable']: return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client') -> List['AutoRenewable']: + def de_list(cls, data: list, client: 'Client') -> List['AutoRenewable']: """Десериализация списка объектов. Args: @@ -69,7 +69,7 @@ def de_list(cls, data: dict, client: 'Client') -> List['AutoRenewable']: Returns: :obj:`list` из :obj:`yandex_music.AutoRenewable`: Информация об автопродлении подписки. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] return [cls.de_json(auto_renewable, client) for auto_renewable in data] diff --git a/yandex_music/account/deactivation.py b/yandex_music/account/deactivation.py index f90ecf58..6070e764 100644 --- a/yandex_music/account/deactivation.py +++ b/yandex_music/account/deactivation.py @@ -38,7 +38,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Deactivation']: Returns: :obj:`yandex_music.Deactivation`: Способ отключения услуги. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Deactivation, cls).de_json(data, client) @@ -46,7 +46,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Deactivation']: return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client') -> List['Deactivation']: + def de_list(cls, data: list, client: 'Client') -> List['Deactivation']: """Десериализация списка объектов. Args: @@ -56,7 +56,7 @@ def de_list(cls, data: dict, client: 'Client') -> List['Deactivation']: Returns: :obj:`list` из :obj:`yandex_music.Deactivation`: Способы отключения услуги. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] return [cls.de_json(deactivation, client) for deactivation in data] diff --git a/yandex_music/account/non_auto_renewable.py b/yandex_music/account/non_auto_renewable.py index 09a61742..716e5a1c 100644 --- a/yandex_music/account/non_auto_renewable.py +++ b/yandex_music/account/non_auto_renewable.py @@ -35,7 +35,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['NonAutoRenewable']: Returns: :obj:`yandex_music.NonAutoRenewable`: Отключённое автопродление. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(NonAutoRenewable, cls).de_json(data, client) diff --git a/yandex_music/account/operator.py b/yandex_music/account/operator.py index d8c2d904..be98e177 100644 --- a/yandex_music/account/operator.py +++ b/yandex_music/account/operator.py @@ -43,7 +43,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Operator']: Returns: :obj:`yandex_music.Operator`: Услуга сотового оператора. """ - if not data: + if not cls.is_valid_model_data(data): return None from yandex_music import Deactivation @@ -55,7 +55,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Operator']: return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client') -> List['Operator']: + def de_list(cls, data: list, client: 'Client') -> List['Operator']: """Десериализация списка объектов. Args: @@ -65,7 +65,7 @@ def de_list(cls, data: dict, client: 'Client') -> List['Operator']: Returns: :obj:`list` из :obj:`yandex_music.Operator`: Услуги сотового оператора. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] return [cls.de_json(operator, client) for operator in data] diff --git a/yandex_music/account/passport_phone.py b/yandex_music/account/passport_phone.py index c7168908..f9d097cd 100644 --- a/yandex_music/account/passport_phone.py +++ b/yandex_music/account/passport_phone.py @@ -33,7 +33,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['PassportPhone']: Returns: :obj:`yandex_music.PassportPhone`: Номер телефона пользователя. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(PassportPhone, cls).de_json(data, client) @@ -41,7 +41,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['PassportPhone']: return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client') -> List['PassportPhone']: + def de_list(cls, data: list, client: 'Client') -> List['PassportPhone']: """Десериализация списка объектов. Args: @@ -51,7 +51,7 @@ def de_list(cls, data: dict, client: 'Client') -> List['PassportPhone']: Returns: :obj:`list` из :obj:`yandex_music.PassportPhone`: Номера телефонов пользователя. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] return [cls.de_json(phone, client) for phone in data] diff --git a/yandex_music/account/permissions.py b/yandex_music/account/permissions.py index 55aabe8d..c57b0978 100644 --- a/yandex_music/account/permissions.py +++ b/yandex_music/account/permissions.py @@ -38,7 +38,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Permissions']: :obj:`yandex_music.Permissions`: Информация о правах пользователя, их изначальных значениях и даты окончания. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Permissions, cls).de_json(data, client) diff --git a/yandex_music/account/plus.py b/yandex_music/account/plus.py index ad45da9c..f661700e 100644 --- a/yandex_music/account/plus.py +++ b/yandex_music/account/plus.py @@ -35,7 +35,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Plus']: Returns: :obj:`yandex_music.Plus`: Plus подписка. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Plus, cls).de_json(data, client) diff --git a/yandex_music/account/price.py b/yandex_music/account/price.py index bc1384b8..cad00c96 100644 --- a/yandex_music/account/price.py +++ b/yandex_music/account/price.py @@ -35,7 +35,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Price']: Returns: :obj:`yandex_music.Price`: Цена. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Price, cls).de_json(data, client) diff --git a/yandex_music/account/product.py b/yandex_music/account/product.py index 2e3108f3..d98347bd 100644 --- a/yandex_music/account/product.py +++ b/yandex_music/account/product.py @@ -98,7 +98,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Product']: Returns: :obj:`yandex_music.Product`: Продаваемый продукт. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Product, cls).de_json(data, client) @@ -112,7 +112,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Product']: return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client') -> List['Product']: + def de_list(cls, data: list, client: 'Client') -> List['Product']: """Десериализация списка объектов. Args: @@ -122,7 +122,7 @@ def de_list(cls, data: dict, client: 'Client') -> List['Product']: Returns: :obj:`list` из :obj:`yandex_music.Product`: Продаваемые продукты. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] return [cls.de_json(product, client) for product in data] diff --git a/yandex_music/account/renewable_remainder.py b/yandex_music/account/renewable_remainder.py index a5d1822d..b4cee114 100644 --- a/yandex_music/account/renewable_remainder.py +++ b/yandex_music/account/renewable_remainder.py @@ -36,7 +36,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['RenewableRemainder'] Returns: :obj:`yandex_music.PassportPhone`: Напоминание о продлении подписки. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(RenewableRemainder, cls).de_json(data, client) diff --git a/yandex_music/account/status.py b/yandex_music/account/status.py index 7e501ca7..14fe6da8 100644 --- a/yandex_music/account/status.py +++ b/yandex_music/account/status.py @@ -65,7 +65,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Status']: Returns: :obj:`yandex_music.Status`: Информация об аккаунте пользователя. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Status, cls).de_json(data, client) diff --git a/yandex_music/account/subscription.py b/yandex_music/account/subscription.py index 1fa0dd33..db2cfb92 100644 --- a/yandex_music/account/subscription.py +++ b/yandex_music/account/subscription.py @@ -49,7 +49,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Subscription']: Returns: :obj:`yandex_music.Subscription`: Информация о подписках пользователя. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Subscription, cls).de_json(data, client) diff --git a/yandex_music/account/user_settings.py b/yandex_music/account/user_settings.py index a26076b7..007ebc9e 100644 --- a/yandex_music/account/user_settings.py +++ b/yandex_music/account/user_settings.py @@ -93,7 +93,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['UserSettings']: Returns: :obj:`yandex_music.UserSettings`: Настройки пользователя. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(UserSettings, cls).de_json(data, client) diff --git a/yandex_music/album/album.py b/yandex_music/album/album.py index a9b7af4c..dbee0467 100644 --- a/yandex_music/album/album.py +++ b/yandex_music/album/album.py @@ -295,14 +295,24 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Album']: Returns: :obj:`yandex_music.Album`: Альбом. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Album, cls).de_json(data, client) from yandex_music import Artist, Label, TrackPosition, Track, Deprecation data['artists'] = Artist.de_list(data.get('artists'), client) - data['labels'] = Label.de_list(data.get('labels'), client) + + # В зависимости от запроса содержимое лейблов может быть списком объектом или списком строк. + labels = data.get('labels') + if cls.is_valid_model_data(labels, array=True): + data['labels'] = Label.de_list(labels, client) + elif labels and all(isinstance(item, str) for item in data): + data['labels'] = labels + else: + # Поддержка формата. Все листы [] по умолчанию вместо None даже если данных нет. + data['labels'] = [] + data['track_position'] = TrackPosition.de_json(data.get('track_position'), client) data['duplicates'] = Album.de_list(data.get('duplicates'), client) data['albums'] = Album.de_list(data.get('albums'), client) @@ -313,7 +323,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Album']: return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client') -> List['Album']: + def de_list(cls, data: list, client: 'Client') -> List['Album']: """Десериализация списка объектов. Args: @@ -323,7 +333,7 @@ def de_list(cls, data: dict, client: 'Client') -> List['Album']: Returns: :obj:`list` из :obj:`yandex_music.Album`: Альбомы. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] return [cls.de_json(album, client) for album in data] diff --git a/yandex_music/album/deprecation.py b/yandex_music/album/deprecation.py index 758c27b1..8dc6f6b3 100644 --- a/yandex_music/album/deprecation.py +++ b/yandex_music/album/deprecation.py @@ -36,7 +36,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Deprecation']: Returns: :obj:`yandex_music.Deprecation`: TODO. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Deprecation, cls).de_json(data, client) diff --git a/yandex_music/album/label.py b/yandex_music/album/label.py index 142537de..88c6b933 100644 --- a/yandex_music/album/label.py +++ b/yandex_music/album/label.py @@ -34,7 +34,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Label']: Returns: :obj:`yandex_music.Label`: Лейбл. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Label, cls).de_json(data, client) @@ -42,7 +42,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Label']: return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client') -> List[Union['Label', str]]: + def de_list(cls, data: list, client: 'Client') -> List[Union['Label', str]]: """Десериализация списка объектов. Args: @@ -55,7 +55,7 @@ def de_list(cls, data: dict, client: 'Client') -> List[Union['Label', str]]: Returns: :obj:`list` из :obj:`yandex_music.Label` или :obj:`str`: Лейблы. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] labels = list() diff --git a/yandex_music/album/track_position.py b/yandex_music/album/track_position.py index 74fb6cfc..733aab3f 100644 --- a/yandex_music/album/track_position.py +++ b/yandex_music/album/track_position.py @@ -40,7 +40,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['TrackPosition']: Returns: :obj:`yandex_music.TrackPosition`: Позиция трека. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(TrackPosition, cls).de_json(data, client) diff --git a/yandex_music/artist/artist.py b/yandex_music/artist/artist.py index 920eddc8..3392a6bd 100644 --- a/yandex_music/artist/artist.py +++ b/yandex_music/artist/artist.py @@ -262,7 +262,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Artist']: Returns: :obj:`yandex_music.Artist`: Исполнитель. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Artist, cls).de_json(data, client) @@ -284,7 +284,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Artist']: return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client') -> List['Artist']: + def de_list(cls, data: list, client: 'Client') -> List['Artist']: """Десериализация списка объектов. Args: @@ -294,7 +294,7 @@ def de_list(cls, data: dict, client: 'Client') -> List['Artist']: Returns: :obj:`list` из :obj:`yandex_music.Artist`: Исполнители. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] artists = list() diff --git a/yandex_music/artist/artist_albums.py b/yandex_music/artist/artist_albums.py index f11f2ec8..91a50d92 100644 --- a/yandex_music/artist/artist_albums.py +++ b/yandex_music/artist/artist_albums.py @@ -44,7 +44,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['ArtistAlbums']: Returns: :obj:`yandex_music.ArtistAlbums`: Список альбомов артиста. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(ArtistAlbums, cls).de_json(data, client) diff --git a/yandex_music/artist/artist_tracks.py b/yandex_music/artist/artist_tracks.py index 494a151c..6b8a08b4 100644 --- a/yandex_music/artist/artist_tracks.py +++ b/yandex_music/artist/artist_tracks.py @@ -44,7 +44,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['ArtistTracks']: Returns: :obj:`yandex_music.ArtistsTracks`: Страница списка треков артиста. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(ArtistTracks, cls).de_json(data, client) diff --git a/yandex_music/artist/brief_info.py b/yandex_music/artist/brief_info.py index d66fe4b4..94f0d9d9 100644 --- a/yandex_music/artist/brief_info.py +++ b/yandex_music/artist/brief_info.py @@ -75,7 +75,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['BriefInfo']: Returns: :obj:`yandex_music.BriefInfo`: Информация об артисте. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(BriefInfo, cls).de_json(data, client) diff --git a/yandex_music/artist/counts.py b/yandex_music/artist/counts.py index b0030cab..a529bcf2 100644 --- a/yandex_music/artist/counts.py +++ b/yandex_music/artist/counts.py @@ -43,7 +43,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Counts']: Returns: :obj:`yandex_music.Counts`: Cчётчик некоторых значений исполнителя. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Counts, cls).de_json(data, client) diff --git a/yandex_music/artist/description.py b/yandex_music/artist/description.py index 412ae50a..5683fde4 100644 --- a/yandex_music/artist/description.py +++ b/yandex_music/artist/description.py @@ -39,7 +39,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Description']: Returns: :obj:`yandex_music.Description`: Описание исполнителя из другого источника. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Description, cls).de_json(data, client) diff --git a/yandex_music/artist/link.py b/yandex_music/artist/link.py index 5d9cbe31..0f3e6ac9 100644 --- a/yandex_music/artist/link.py +++ b/yandex_music/artist/link.py @@ -42,7 +42,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Link']: Returns: :obj:`yandex_music.Link`: Ссылка на официальную страницу исполнителя. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Link, cls).de_json(data, client) @@ -50,7 +50,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Link']: return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client') -> List['Link']: + def de_list(cls, data: list, client: 'Client') -> List['Link']: """Десериализация списка объектов. Args: @@ -60,7 +60,7 @@ def de_list(cls, data: dict, client: 'Client') -> List['Link']: Returns: :obj:`list` из :obj:`yandex_music.Link`: Ссылки на официальные страницы исполнителя. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] links = list() diff --git a/yandex_music/artist/ratings.py b/yandex_music/artist/ratings.py index 151083e2..99561e31 100644 --- a/yandex_music/artist/ratings.py +++ b/yandex_music/artist/ratings.py @@ -37,7 +37,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Ratings']: Returns: :obj:`yandex_music.Ratings`: Рейтинг исполнителя. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Ratings, cls).de_json(data, client) diff --git a/yandex_music/artist/vinyl.py b/yandex_music/artist/vinyl.py index 06c45ced..05a12aa8 100644 --- a/yandex_music/artist/vinyl.py +++ b/yandex_music/artist/vinyl.py @@ -57,7 +57,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Vinyl']: Returns: :obj:`yandex_music.Vinyl`: Ваниловая пластинка. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Vinyl, cls).de_json(data, client) @@ -65,7 +65,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Vinyl']: return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client') -> List['Vinyl']: + def de_list(cls, data: list, client: 'Client') -> List['Vinyl']: """Десериализация списка объектов. Args: @@ -75,7 +75,7 @@ def de_list(cls, data: dict, client: 'Client') -> List['Vinyl']: Returns: :obj:`list` из :obj:`yandex_music.Vinyl`: Ваниловые пластинки. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] vinyls = list() diff --git a/yandex_music/base.py b/yandex_music/base.py index 8f95e98a..459fe21b 100644 --- a/yandex_music/base.py +++ b/yandex_music/base.py @@ -2,7 +2,7 @@ import logging import keyword from abc import ABCMeta -from typing import TYPE_CHECKING, Optional +from typing import TYPE_CHECKING, Optional, Any if TYPE_CHECKING: from yandex_music import Client @@ -42,6 +42,13 @@ def report_unknown_fields_callback(cls, unknown_fields): ) logger.warning(f'Type: {cls.__module__}.{cls.__name__}; fields: {unknown_fields}') + @staticmethod + def is_valid_model_data(data: Any, *, array: bool = False) -> bool: + if array: + return data and isinstance(data, list) and all(isinstance(item, dict) for item in data) + + return data and isinstance(data, dict) + @classmethod def de_json(cls, data: dict, client: Optional['Client']) -> Optional[dict]: """Десериализация объекта. @@ -53,7 +60,7 @@ def de_json(cls, data: dict, client: Optional['Client']) -> Optional[dict]: Returns: :obj:`yandex_music.YandexMusicObject` | :obj:`None`: :obj:`yandex_music.YandexMusicObject` или :obj:`None`. """ - if not data: + if not cls.is_valid_model_data(data): return None data = data.copy() diff --git a/yandex_music/cover.py b/yandex_music/cover.py index fb6c6d8d..91204b3b 100644 --- a/yandex_music/cover.py +++ b/yandex_music/cover.py @@ -111,7 +111,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Cover']: Returns: :obj:`yandex_music.Cover`: Обложка. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Cover, cls).de_json(data, client) @@ -119,7 +119,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Cover']: return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client') -> List['Cover']: + def de_list(cls, data: list, client: 'Client') -> List['Cover']: """Десериализация списка объектов. Args: @@ -129,7 +129,7 @@ def de_list(cls, data: dict, client: 'Client') -> List['Cover']: Returns: :obj:`list` из :obj:`yandex_music.Cover`: Обложки. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] covers = list() diff --git a/yandex_music/download_info.py b/yandex_music/download_info.py index 17c8e5cf..8217591c 100644 --- a/yandex_music/download_info.py +++ b/yandex_music/download_info.py @@ -143,7 +143,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['DownloadInfo']: Returns: :obj:`yandex_music.DownloadInfo`: Варианты загрузки треков. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(DownloadInfo, cls).de_json(data, client) @@ -151,7 +151,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['DownloadInfo']: return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client', get_direct_links: bool = False) -> List['DownloadInfo']: + def de_list(cls, data: list, client: 'Client', get_direct_links: bool = False) -> List['DownloadInfo']: """Десериализация списка объектов. Args: @@ -162,7 +162,7 @@ def de_list(cls, data: dict, client: 'Client', get_direct_links: bool = False) - Returns: :obj:`list` из :obj:`yandex_music.DownloadInfo`: Варианты загрузки треков. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] downloads_info = list() @@ -187,7 +187,7 @@ async def de_list_async(cls, data: dict, client: 'Client', get_direct_links: boo Returns: :obj:`list` из :obj:`yandex_music.DownloadInfo`: Варианты загрузки треков. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] downloads_info = list() diff --git a/yandex_music/experiments.py b/yandex_music/experiments.py index c2b55b6e..5ea3f987 100644 --- a/yandex_music/experiments.py +++ b/yandex_music/experiments.py @@ -37,7 +37,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Experiments']: Returns: :obj:`yandex_music.Experiments`: Какие-то свистелки и перделки, флажки, режимы экспериментальных функций. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Experiments, cls).de_json(data, client) diff --git a/yandex_music/feed/album_event.py b/yandex_music/feed/album_event.py index 4c3a7df8..e72a1011 100644 --- a/yandex_music/feed/album_event.py +++ b/yandex_music/feed/album_event.py @@ -35,7 +35,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['AlbumEvent']: Returns: :obj:`yandex_music.AlbumEvent`: Альбом в событии фида. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(AlbumEvent, cls).de_json(data, client) @@ -47,7 +47,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['AlbumEvent']: return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client') -> List['AlbumEvent']: + def de_list(cls, data: list, client: 'Client') -> List['AlbumEvent']: """Десериализация списка объектов. Args: @@ -57,7 +57,7 @@ def de_list(cls, data: dict, client: 'Client') -> List['AlbumEvent']: Returns: :obj:`list` из :obj:`yandex_music.AlbumEvent`: Альбомы в событии фида. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] album_events = list() diff --git a/yandex_music/feed/artist_event.py b/yandex_music/feed/artist_event.py index 71b607ef..3da1cf94 100644 --- a/yandex_music/feed/artist_event.py +++ b/yandex_music/feed/artist_event.py @@ -39,7 +39,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['ArtistEvent']: Returns: :obj:`yandex_music.ArtistEvent`: Артист из события фида. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(ArtistEvent, cls).de_json(data, client) @@ -52,7 +52,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['ArtistEvent']: return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client') -> List['ArtistEvent']: + def de_list(cls, data: list, client: 'Client') -> List['ArtistEvent']: """Десериализация списка объектов. Args: @@ -62,7 +62,7 @@ def de_list(cls, data: dict, client: 'Client') -> List['ArtistEvent']: Returns: :obj:`list` из :obj:`yandex_music.ArtistEvent`: Артисты из события фида. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] artist_events = list() diff --git a/yandex_music/feed/day.py b/yandex_music/feed/day.py index 53da5f04..52a6f7f2 100644 --- a/yandex_music/feed/day.py +++ b/yandex_music/feed/day.py @@ -39,7 +39,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Day']: Returns: :obj:`yandex_music.Day`: День в фиде. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Day, cls).de_json(data, client) @@ -52,7 +52,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Day']: return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client') -> List['Day']: + def de_list(cls, data: list, client: 'Client') -> List['Day']: """Десериализация списка объектов. Args: @@ -62,7 +62,7 @@ def de_list(cls, data: dict, client: 'Client') -> List['Day']: Returns: :obj:`list` из :obj:`yandex_music.Day`: Дни в фиде. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] days = list() diff --git a/yandex_music/feed/event.py b/yandex_music/feed/event.py index fe7e890f..f5954196 100644 --- a/yandex_music/feed/event.py +++ b/yandex_music/feed/event.py @@ -63,7 +63,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Event']: Returns: :obj:`yandex_music.Event`: Событие фида. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Event, cls).de_json(data, client) @@ -76,7 +76,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Event']: return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client') -> List['Event']: + def de_list(cls, data: list, client: 'Client') -> List['Event']: """Десериализация списка объектов. Args: @@ -86,7 +86,7 @@ def de_list(cls, data: dict, client: 'Client') -> List['Event']: Returns: :obj:`list` из :obj:`yandex_music.Event`: События фида. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] events = list() diff --git a/yandex_music/feed/feed.py b/yandex_music/feed/feed.py index c27a8b57..bf2cb26b 100644 --- a/yandex_music/feed/feed.py +++ b/yandex_music/feed/feed.py @@ -50,7 +50,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Feed']: Returns: :obj:`yandex_music.Feed`: Фид. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Feed, cls).de_json(data, client) diff --git a/yandex_music/feed/generated_playlist.py b/yandex_music/feed/generated_playlist.py index 4df42957..76bf915d 100644 --- a/yandex_music/feed/generated_playlist.py +++ b/yandex_music/feed/generated_playlist.py @@ -47,7 +47,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['GeneratedPlaylist']: Returns: :obj:`yandex_music.GeneratedPlaylist`: Автоматически сгенерированный плейлист. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(GeneratedPlaylist, cls).de_json(data, client) @@ -58,7 +58,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['GeneratedPlaylist']: return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client') -> List['GeneratedPlaylist']: + def de_list(cls, data: list, client: 'Client') -> List['GeneratedPlaylist']: """Десериализация списка объектов. Args: @@ -68,7 +68,7 @@ def de_list(cls, data: dict, client: 'Client') -> List['GeneratedPlaylist']: Returns: :obj:`list` из :obj:`yandex_music.GeneratedPlaylist`: Автоматически сгенерированные плейлисты. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] return [cls.de_json(generated_playlist, client) for generated_playlist in data] diff --git a/yandex_music/feed/track_with_ads.py b/yandex_music/feed/track_with_ads.py index 2843a372..4825e955 100644 --- a/yandex_music/feed/track_with_ads.py +++ b/yandex_music/feed/track_with_ads.py @@ -38,7 +38,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['TrackWithAds']: Returns: :obj:`yandex_music.TrackWithAds`: Трек с рекламой. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(TrackWithAds, cls).de_json(data, client) @@ -49,7 +49,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['TrackWithAds']: return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client') -> List['TrackWithAds']: + def de_list(cls, data: list, client: 'Client') -> List['TrackWithAds']: """Десериализация списка объектов. Args: @@ -59,7 +59,7 @@ def de_list(cls, data: dict, client: 'Client') -> List['TrackWithAds']: Returns: :obj:`list` из :obj:`yandex_music.TrackWithAds`: Треки с рекламой. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] tracks_with_ads = list() diff --git a/yandex_music/genre/genre.py b/yandex_music/genre/genre.py index e2c94f7e..e0a75086 100644 --- a/yandex_music/genre/genre.py +++ b/yandex_music/genre/genre.py @@ -59,7 +59,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Genre']: Returns: :obj:`yandex_music.Genre`: Жанр музыки. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Genre, cls).de_json(data, client) @@ -73,7 +73,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Genre']: return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client') -> List['Genre']: + def de_list(cls, data: list, client: 'Client') -> List['Genre']: """Десериализация списка объектов. Args: @@ -83,7 +83,7 @@ def de_list(cls, data: dict, client: 'Client') -> List['Genre']: Returns: :obj:`list` из :obj:`yandex_music.Genre`: Жанры музыки. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] return [cls.de_json(genre, client) for genre in data] diff --git a/yandex_music/genre/images.py b/yandex_music/genre/images.py index 4655c0a9..3a34f3f2 100644 --- a/yandex_music/genre/images.py +++ b/yandex_music/genre/images.py @@ -67,7 +67,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Images']: Returns: :obj:`yandex_music.Images`: Изображение жанра. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Images, cls).de_json(data, client) diff --git a/yandex_music/genre/title.py b/yandex_music/genre/title.py index 604803b6..adc56a2c 100644 --- a/yandex_music/genre/title.py +++ b/yandex_music/genre/title.py @@ -35,7 +35,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Title']: Returns: :obj:`yandex_music.Title`: Заголовок жанра. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Title, cls).de_json(data, client) diff --git a/yandex_music/icon.py b/yandex_music/icon.py index 8a36b8b2..f0175e72 100644 --- a/yandex_music/icon.py +++ b/yandex_music/icon.py @@ -83,7 +83,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Icon']: Returns: :obj:`yandex_music.Icon`: Иконка. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Icon, cls).de_json(data, client) diff --git a/yandex_music/invocation_info.py b/yandex_music/invocation_info.py index aa1f8e59..7b745745 100644 --- a/yandex_music/invocation_info.py +++ b/yandex_music/invocation_info.py @@ -37,7 +37,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['InvocationInfo']: Returns: :obj:`yandex_music.InvocationInfo`: Информация о запросе. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(InvocationInfo, cls).de_json(data, client) diff --git a/yandex_music/landing/block.py b/yandex_music/landing/block.py index 5a96059d..090f9f2e 100644 --- a/yandex_music/landing/block.py +++ b/yandex_music/landing/block.py @@ -52,7 +52,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Block']: Returns: :obj:`yandex_music.Block`: Блок лендинга. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Block, cls).de_json(data, client) @@ -69,7 +69,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Block']: return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client') -> List['Block']: + def de_list(cls, data: list, client: 'Client') -> List['Block']: """Десериализация списка объектов. Args: @@ -79,7 +79,7 @@ def de_list(cls, data: dict, client: 'Client') -> List['Block']: Returns: :obj:`list` из :obj:`yandex_music.Block`: Блоки лендинга. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] blocks = list() diff --git a/yandex_music/landing/block_entity.py b/yandex_music/landing/block_entity.py index f0a6b078..c26b733e 100644 --- a/yandex_music/landing/block_entity.py +++ b/yandex_music/landing/block_entity.py @@ -64,7 +64,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['BlockEntity']: Returns: :obj:`yandex_music.BlockEntity`: Сущность (объект) блока. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(BlockEntity, cls).de_json(data, client) @@ -73,7 +73,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['BlockEntity']: return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client') -> List['BlockEntity']: + def de_list(cls, data: list, client: 'Client') -> List['BlockEntity']: """Десериализация списка объектов. Args: @@ -83,7 +83,7 @@ def de_list(cls, data: dict, client: 'Client') -> List['BlockEntity']: Returns: :obj:`list` из :obj:`yandex_music.BlockEntity`: Содержимое блока. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] entities = list() diff --git a/yandex_music/landing/chart.py b/yandex_music/landing/chart.py index 0aae5894..6d671da1 100644 --- a/yandex_music/landing/chart.py +++ b/yandex_music/landing/chart.py @@ -46,7 +46,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Chart']: Returns: :obj:`yandex_music.Chart`: Элемент чарта. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Chart, cls).de_json(data, client) @@ -57,7 +57,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Chart']: return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client') -> List['Chart']: + def de_list(cls, data: list, client: 'Client') -> List['Chart']: """Десериализация списка объектов. Args: @@ -67,7 +67,7 @@ def de_list(cls, data: dict, client: 'Client') -> List['Chart']: Returns: :obj:`list` из :obj:`yandex_music.Chart`: Чарт. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] return [cls.de_json(chart, client) for chart in data] diff --git a/yandex_music/landing/chart_info.py b/yandex_music/landing/chart_info.py index 956dc21b..e0f47e0b 100644 --- a/yandex_music/landing/chart_info.py +++ b/yandex_music/landing/chart_info.py @@ -45,7 +45,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['ChartInfo']: Returns: :obj:`yandex_music.ChartInfo`: Чарт. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(ChartInfo, cls).de_json(data, client) diff --git a/yandex_music/landing/chart_info_menu.py b/yandex_music/landing/chart_info_menu.py index 52e9639a..fafaf3ce 100644 --- a/yandex_music/landing/chart_info_menu.py +++ b/yandex_music/landing/chart_info_menu.py @@ -33,7 +33,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['ChartInfoMenu']: Returns: :obj:`yandex_music.ChartInfoMenu`: Меню чарта. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(ChartInfoMenu, cls).de_json(data, client) diff --git a/yandex_music/landing/chart_info_menu_item.py b/yandex_music/landing/chart_info_menu_item.py index b4cfeb31..b75768f0 100644 --- a/yandex_music/landing/chart_info_menu_item.py +++ b/yandex_music/landing/chart_info_menu_item.py @@ -37,7 +37,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['ChartInfoMenuItem']: Returns: :obj:`yandex_music.ChartInfoMenuItem`: Элемент меню. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(ChartInfoMenuItem, cls).de_json(data, client) @@ -55,7 +55,7 @@ def de_list(cls, data: list, client: 'Client') -> List['ChartInfoMenuItem']: Returns: :obj:`list` из :obj:`yandex_music.ChartInfoMenuItem`: Список элементов меню чарта. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] return [cls.de_json(item, client) for item in data] diff --git a/yandex_music/landing/chart_item.py b/yandex_music/landing/chart_item.py index 5b786883..33945b17 100644 --- a/yandex_music/landing/chart_item.py +++ b/yandex_music/landing/chart_item.py @@ -35,7 +35,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['ChartItem']: Returns: :obj:`yandex_music.ChartItem`: Трек в чарте. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(ChartItem, cls).de_json(data, client) @@ -47,7 +47,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['ChartItem']: return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client') -> List['ChartItem']: + def de_list(cls, data: list, client: 'Client') -> List['ChartItem']: """Десериализация списка объектов. Args: @@ -57,7 +57,7 @@ def de_list(cls, data: dict, client: 'Client') -> List['ChartItem']: Returns: :obj:`list` из :obj:`yandex_music.ChartItem`: Треки в чартах. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] tracks = list() diff --git a/yandex_music/landing/landing.py b/yandex_music/landing/landing.py index b7839e15..3a6f8445 100644 --- a/yandex_music/landing/landing.py +++ b/yandex_music/landing/landing.py @@ -40,7 +40,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Landing']: Returns: :obj:`yandex_music.Landing`: Лендинг. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Landing, cls).de_json(data, client) diff --git a/yandex_music/landing/landing_list.py b/yandex_music/landing/landing_list.py index 4c3b27ed..68d87be0 100644 --- a/yandex_music/landing/landing_list.py +++ b/yandex_music/landing/landing_list.py @@ -50,7 +50,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Chart']: Returns: :obj:`yandex_music.LandingList`: Список объектов лендинга. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(LandingList, cls).de_json(data, client) diff --git a/yandex_music/landing/mix_link.py b/yandex_music/landing/mix_link.py index a86e3a02..488ebd14 100644 --- a/yandex_music/landing/mix_link.py +++ b/yandex_music/landing/mix_link.py @@ -217,7 +217,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['MixLink']: Returns: :obj:`yandex_music.MixLink`: Блок-ссылка на подборку. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(MixLink, cls).de_json(data, client) @@ -225,7 +225,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['MixLink']: return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client') -> List['MixLink']: + def de_list(cls, data: list, client: 'Client') -> List['MixLink']: """Десериализация списка объектов. Args: @@ -235,7 +235,7 @@ def de_list(cls, data: dict, client: 'Client') -> List['MixLink']: Returns: :obj:`list` из :obj:`yandex_music.MixLink`: Блоки-ссылки на подборки. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] mix_links = list() diff --git a/yandex_music/landing/personal_playlists_data.py b/yandex_music/landing/personal_playlists_data.py index 48b9509f..36f0f2f8 100644 --- a/yandex_music/landing/personal_playlists_data.py +++ b/yandex_music/landing/personal_playlists_data.py @@ -33,7 +33,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['PersonalPlaylistsDat Returns: :obj:`yandex_music.PersonalPlaylistsData`: Дополнительная информация о персональном плейлисте. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(PersonalPlaylistsData, cls).de_json(data, client) diff --git a/yandex_music/landing/play_context.py b/yandex_music/landing/play_context.py index 43f9507b..97a72676 100644 --- a/yandex_music/landing/play_context.py +++ b/yandex_music/landing/play_context.py @@ -46,7 +46,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['PlayContext']: Returns: :obj:`yandex_music.PlayContext`: Проигрываемый контекст. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(PlayContext, cls).de_json(data, client) diff --git a/yandex_music/landing/play_contexts_data.py b/yandex_music/landing/play_contexts_data.py index bd2bb762..8cb9b7d1 100644 --- a/yandex_music/landing/play_contexts_data.py +++ b/yandex_music/landing/play_contexts_data.py @@ -33,7 +33,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['PlayContextsData']: Returns: :obj:`yandex_music.PlayContextsData`: Данные проигрываемого контекста. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(PlayContextsData, cls).de_json(data, client) diff --git a/yandex_music/landing/promotion.py b/yandex_music/landing/promotion.py index 828707aa..fb5e09d4 100644 --- a/yandex_music/landing/promotion.py +++ b/yandex_music/landing/promotion.py @@ -115,7 +115,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Promotion']: Returns: :obj:`yandex_music.Promotion`: Продвижение (реклама). """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Promotion, cls).de_json(data, client) @@ -123,7 +123,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Promotion']: return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client') -> List['Promotion']: + def de_list(cls, data: list, client: 'Client') -> List['Promotion']: """Десериализация списка объектов. Args: @@ -133,7 +133,7 @@ def de_list(cls, data: dict, client: 'Client') -> List['Promotion']: Returns: :obj:`list` из :obj:`yandex_music.Promotion`: Продвижения (реклама). """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] promotions = list() diff --git a/yandex_music/landing/track_id.py b/yandex_music/landing/track_id.py index 8d5171e3..f37a4d1d 100644 --- a/yandex_music/landing/track_id.py +++ b/yandex_music/landing/track_id.py @@ -70,7 +70,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['TrackId']: Returns: :obj:`yandex_music.TrackId`: Уникальный идентификатор трека. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(TrackId, cls).de_json(data, client) @@ -78,7 +78,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['TrackId']: return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client') -> List['TrackId']: + def de_list(cls, data: list, client: 'Client') -> List['TrackId']: """Десериализация списка объектов. Args: @@ -88,7 +88,7 @@ def de_list(cls, data: dict, client: 'Client') -> List['TrackId']: Returns: :obj:`list` из :obj:`yandex_music.TrackId`: Уникальные идентификаторы треков. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] return [cls.de_json(track_id, client) for track_id in data] diff --git a/yandex_music/landing/track_short_old.py b/yandex_music/landing/track_short_old.py index 438c6a20..01460d08 100644 --- a/yandex_music/landing/track_short_old.py +++ b/yandex_music/landing/track_short_old.py @@ -40,7 +40,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['TrackShortOld']: Returns: :obj:`yandex_music.TrackShortOld`: Сокращённая версия трека или :obj:`None`. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(TrackShortOld, cls).de_json(data, client) @@ -51,7 +51,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['TrackShortOld']: return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client') -> List['TrackShortOld']: + def de_list(cls, data: list, client: 'Client') -> List['TrackShortOld']: """Десериализация списка объектов. Args: @@ -61,7 +61,7 @@ def de_list(cls, data: dict, client: 'Client') -> List['TrackShortOld']: Returns: :obj:`list` из :obj:`yandex_music.TrackShortOld`: Сокращённые версии треков. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] tracks = list() diff --git a/yandex_music/like.py b/yandex_music/like.py index f9767b1a..1e70abb6 100644 --- a/yandex_music/like.py +++ b/yandex_music/like.py @@ -61,7 +61,7 @@ def de_json(cls, data: dict, client: 'Client', type_: str = None) -> Optional['L Returns: :obj:`yandex_music.Like`: Объект с отметкой "мне нравится". """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Like, cls).de_json(data, client) @@ -81,7 +81,7 @@ def de_json(cls, data: dict, client: 'Client', type_: str = None) -> Optional['L return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client', type_: str = None) -> List['Like']: + def de_list(cls, data: list, client: 'Client', type_: str = None) -> List['Like']: """Десериализация списка объектов. Args: @@ -92,7 +92,7 @@ def de_list(cls, data: dict, client: 'Client', type_: str = None) -> List['Like' Returns: :obj:`list` из :obj:`yandex_music.Like`: Объекты с отметкой "мне нравится". """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] likes = list() diff --git a/yandex_music/pager.py b/yandex_music/pager.py index c5d488aa..f5f500ae 100644 --- a/yandex_music/pager.py +++ b/yandex_music/pager.py @@ -37,7 +37,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Pager']: Returns: :obj:`yandex_music.Pager`: Пагинация. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Pager, cls).de_json(data, client) diff --git a/yandex_music/permission_alerts.py b/yandex_music/permission_alerts.py index cfdab6fe..46ffa4b9 100644 --- a/yandex_music/permission_alerts.py +++ b/yandex_music/permission_alerts.py @@ -30,7 +30,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['PermissionAlerts']: Returns: :obj:`yandex_music.PermissionAlerts`: Оповещение. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(PermissionAlerts, cls).de_json(data, client) diff --git a/yandex_music/playlist/brand.py b/yandex_music/playlist/brand.py index 935aba46..022453e6 100644 --- a/yandex_music/playlist/brand.py +++ b/yandex_music/playlist/brand.py @@ -48,7 +48,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Brand']: Returns: :obj:`yandex_music.Brand`: Бренд плейлиста. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Brand, cls).de_json(data, client) diff --git a/yandex_music/playlist/case_forms.py b/yandex_music/playlist/case_forms.py index 21a658ae..5130ee8a 100644 --- a/yandex_music/playlist/case_forms.py +++ b/yandex_music/playlist/case_forms.py @@ -50,7 +50,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['CaseForms']: Returns: :obj:`yandex_music.CaseForms`: Склонение имени. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(CaseForms, cls).de_json(data, client) diff --git a/yandex_music/playlist/contest.py b/yandex_music/playlist/contest.py index 9cb53297..6b450cbd 100644 --- a/yandex_music/playlist/contest.py +++ b/yandex_music/playlist/contest.py @@ -44,7 +44,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Contest']: Returns: :obj:`yandex_music.Contest`: Контест. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Contest, cls).de_json(data, client) diff --git a/yandex_music/playlist/custom_wave.py b/yandex_music/playlist/custom_wave.py index 41886d3b..3c745bf4 100644 --- a/yandex_music/playlist/custom_wave.py +++ b/yandex_music/playlist/custom_wave.py @@ -40,7 +40,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['CustomWave']: Returns: :obj:`yandex_music.CustomWave`: Описание плейлиста. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(CustomWave, cls).de_json(data, client) diff --git a/yandex_music/playlist/made_for.py b/yandex_music/playlist/made_for.py index c803833b..d639d3d6 100644 --- a/yandex_music/playlist/made_for.py +++ b/yandex_music/playlist/made_for.py @@ -35,7 +35,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['MadeFor']: Returns: :obj:`yandex_music.MadeFor`: Пользователь, для которого был сделан плейлист. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(MadeFor, cls).de_json(data, client) diff --git a/yandex_music/playlist/open_graph_data.py b/yandex_music/playlist/open_graph_data.py index 5ba68715..b85d494a 100644 --- a/yandex_music/playlist/open_graph_data.py +++ b/yandex_music/playlist/open_graph_data.py @@ -37,7 +37,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['OpenGraphData']: Returns: :obj:`yandex_music.OpenGraphData`: Данные для Open Graph. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(OpenGraphData, cls).de_json(data, client) diff --git a/yandex_music/playlist/play_counter.py b/yandex_music/playlist/play_counter.py index 1d783244..dc598e04 100644 --- a/yandex_music/playlist/play_counter.py +++ b/yandex_music/playlist/play_counter.py @@ -41,7 +41,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['PlayCounter']: Returns: :obj:`yandex_music.PlayCounter`: Счетчик дней. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(PlayCounter, cls).de_json(data, client) diff --git a/yandex_music/playlist/playlist.py b/yandex_music/playlist/playlist.py index 8cbc43f4..5b7bdf2c 100644 --- a/yandex_music/playlist/playlist.py +++ b/yandex_music/playlist/playlist.py @@ -416,7 +416,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Playlist']: Returns: :obj:`yandex_music.Playlist`: Плейлист. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Playlist, cls).de_json(data, client) @@ -464,7 +464,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Playlist']: return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client') -> List['Playlist']: + def de_list(cls, data: list, client: 'Client') -> List['Playlist']: """Десериализация списка объектов. Args: @@ -474,7 +474,7 @@ def de_list(cls, data: dict, client: 'Client') -> List['Playlist']: Returns: :obj:`list` из :obj:`yandex_music.Playlist`: Плейлисты. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] return [cls.de_json(playlist, client) for playlist in data] diff --git a/yandex_music/playlist/playlist_absence.py b/yandex_music/playlist/playlist_absence.py index 90839acd..287217c6 100644 --- a/yandex_music/playlist/playlist_absence.py +++ b/yandex_music/playlist/playlist_absence.py @@ -35,7 +35,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['PlaylistAbsence']: Returns: :obj:`yandex_music.PlaylistAbsence`: Причина отсутствия плейлиста. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(PlaylistAbsence, cls).de_json(data, client) diff --git a/yandex_music/playlist/playlist_id.py b/yandex_music/playlist/playlist_id.py index 9cdaf00b..fcb6070e 100644 --- a/yandex_music/playlist/playlist_id.py +++ b/yandex_music/playlist/playlist_id.py @@ -53,7 +53,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['PlaylistId']: Returns: :obj:`yandex_music.PlaylistId`: Уникальный идентификатор плейлиста. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(PlaylistId, cls).de_json(data, client) @@ -61,7 +61,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['PlaylistId']: return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client') -> List['PlaylistId']: + def de_list(cls, data: list, client: 'Client') -> List['PlaylistId']: """Десериализация списка объектов. Args: @@ -71,7 +71,7 @@ def de_list(cls, data: dict, client: 'Client') -> List['PlaylistId']: Returns: :obj:`list` из :obj:`yandex_music.PlaylistId`: Уникальные идентификаторы плейлистов. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] playlist_ids = list() diff --git a/yandex_music/playlist/playlist_recommendation.py b/yandex_music/playlist/playlist_recommendation.py index c24380d0..67cd02ca 100644 --- a/yandex_music/playlist/playlist_recommendation.py +++ b/yandex_music/playlist/playlist_recommendation.py @@ -35,7 +35,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['PlaylistRecommendati Returns: :obj:`yandex_music.PlaylistRecommendations`: Рекомендации для плейлиста. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(PlaylistRecommendations, cls).de_json(data, client) diff --git a/yandex_music/playlist/tag.py b/yandex_music/playlist/tag.py index fd88b1e7..c6894857 100644 --- a/yandex_music/playlist/tag.py +++ b/yandex_music/playlist/tag.py @@ -41,7 +41,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Tag']: Returns: :obj:`yandex_music.Tag`: Тег. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Tag, cls).de_json(data, client) diff --git a/yandex_music/playlist/tag_result.py b/yandex_music/playlist/tag_result.py index 8579c58a..213abc1d 100644 --- a/yandex_music/playlist/tag_result.py +++ b/yandex_music/playlist/tag_result.py @@ -35,7 +35,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['TagResult']: Returns: :obj:`yandex_music.TagResult`: Тег и его плейлисты. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(TagResult, cls).de_json(data, client) diff --git a/yandex_music/playlist/user.py b/yandex_music/playlist/user.py index b78ab515..b0a55ad9 100644 --- a/yandex_music/playlist/user.py +++ b/yandex_music/playlist/user.py @@ -56,7 +56,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['User']: Returns: :obj:`yandex_music.User`: Пользователь. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(User, cls).de_json(data, client) @@ -64,7 +64,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['User']: return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client') -> List['User']: + def de_list(cls, data: list, client: 'Client') -> List['User']: """Десериализация списка объектов. Args: @@ -74,7 +74,7 @@ def de_list(cls, data: dict, client: 'Client') -> List['User']: Returns: :obj:`list` из :obj:`yandex_music.User`: Пользователи. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] return [cls.de_json(user, client) for user in data] diff --git a/yandex_music/promo_code_status.py b/yandex_music/promo_code_status.py index 40933af8..6ad02ce8 100644 --- a/yandex_music/promo_code_status.py +++ b/yandex_music/promo_code_status.py @@ -37,7 +37,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['PromoCodeStatus']: Returns: :obj:`yandex_music.PromoCodeStatus`: Статус активации промо-кода. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(PromoCodeStatus, cls).de_json(data, client) diff --git a/yandex_music/queue/context.py b/yandex_music/queue/context.py index 052033e3..6139f7f0 100644 --- a/yandex_music/queue/context.py +++ b/yandex_music/queue/context.py @@ -46,7 +46,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Context']: Returns: :obj:`yandex_music.Context`: Содержимое очереди. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Context, cls).de_json(data, client) diff --git a/yandex_music/queue/queue.py b/yandex_music/queue/queue.py index 5b4686a3..15405ff7 100644 --- a/yandex_music/queue/queue.py +++ b/yandex_music/queue/queue.py @@ -47,7 +47,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Queue']: Returns: :obj:`yandex_music.Queue`: Очередь. """ - if not data: + if not cls.is_valid_model_data(data): return None from yandex_music import TrackId, Context diff --git a/yandex_music/queue/queue_item.py b/yandex_music/queue/queue_item.py index 6715e5ef..6fd8b5f3 100644 --- a/yandex_music/queue/queue_item.py +++ b/yandex_music/queue/queue_item.py @@ -51,7 +51,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['QueueItem']: Returns: :obj:`yandex_music.QueueItem`: Очередь в списке. """ - if not data: + if not cls.is_valid_model_data(data): return None from yandex_music import Context @@ -62,7 +62,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['QueueItem']: return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client') -> List['QueueItem']: + def de_list(cls, data: list, client: 'Client') -> List['QueueItem']: """Десериализация списка объектов. Args: @@ -72,7 +72,7 @@ def de_list(cls, data: dict, client: 'Client') -> List['QueueItem']: Returns: :obj:`list` из :obj:`yandex_music.QueueItem`: Список очередей всех устройств. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] return [cls.de_json(queue, client) for queue in data] diff --git a/yandex_music/rotor/ad_params.py b/yandex_music/rotor/ad_params.py index 2b9a0ab8..1cf2d19a 100644 --- a/yandex_music/rotor/ad_params.py +++ b/yandex_music/rotor/ad_params.py @@ -57,7 +57,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['AdParams']: Returns: :obj:`yandex_music.AdParams`: Параметры рекламного объявления. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(AdParams, cls).de_json(data, client) diff --git a/yandex_music/rotor/dashboard.py b/yandex_music/rotor/dashboard.py index 0c239448..5316b68b 100644 --- a/yandex_music/rotor/dashboard.py +++ b/yandex_music/rotor/dashboard.py @@ -38,7 +38,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Dashboard']: Returns: :obj:`yandex_music.Dashboard`: Рекомендованные станций пользователя. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Dashboard, cls).de_json(data, client) diff --git a/yandex_music/rotor/discrete_scale.py b/yandex_music/rotor/discrete_scale.py index 13881c32..b8c9efa2 100644 --- a/yandex_music/rotor/discrete_scale.py +++ b/yandex_music/rotor/discrete_scale.py @@ -42,7 +42,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['DiscreteScale']: Returns: :obj:`yandex_music.DiscreteScale`: Дискретное значение. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(DiscreteScale, cls).de_json(data, client) diff --git a/yandex_music/rotor/enum.py b/yandex_music/rotor/enum.py index 6ac19c91..a87889a1 100644 --- a/yandex_music/rotor/enum.py +++ b/yandex_music/rotor/enum.py @@ -38,7 +38,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Enum']: Returns: :obj:`yandex_music.Enum`: Перечисление. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Enum, cls).de_json(data, client) diff --git a/yandex_music/rotor/id.py b/yandex_music/rotor/id.py index 42f05896..dc87a207 100644 --- a/yandex_music/rotor/id.py +++ b/yandex_music/rotor/id.py @@ -39,7 +39,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Id']: Returns: :obj:`yandex_music.Id`: Уникальный идентификатор станции. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Id, cls).de_json(data, client) diff --git a/yandex_music/rotor/restrictions.py b/yandex_music/rotor/restrictions.py index 30f02271..1ea3c4e6 100644 --- a/yandex_music/rotor/restrictions.py +++ b/yandex_music/rotor/restrictions.py @@ -43,7 +43,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Restrictions']: Returns: :obj:`yandex_music.Restrictions`: Ограничения для настроек станции. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Restrictions, cls).de_json(data, client) diff --git a/yandex_music/rotor/rotor_settings.py b/yandex_music/rotor/rotor_settings.py index c0c3e785..a902d2c2 100644 --- a/yandex_music/rotor/rotor_settings.py +++ b/yandex_music/rotor/rotor_settings.py @@ -50,7 +50,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['RotorSettings']: Returns: :obj:`yandex_music.RotorSettings`: Настройки станции. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(RotorSettings, cls).de_json(data, client) diff --git a/yandex_music/rotor/sequence.py b/yandex_music/rotor/sequence.py index 40010370..e9f590b5 100644 --- a/yandex_music/rotor/sequence.py +++ b/yandex_music/rotor/sequence.py @@ -40,7 +40,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Sequence']: Returns: :obj:`yandex_music.Sequence`: Звено последовательности. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Sequence, cls).de_json(data, client) @@ -51,7 +51,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Sequence']: return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client') -> List['Sequence']: + def de_list(cls, data: list, client: 'Client') -> List['Sequence']: """Десериализация списка объектов. Args: @@ -61,7 +61,7 @@ def de_list(cls, data: dict, client: 'Client') -> List['Sequence']: Returns: :obj:`list` из :obj:`yandex_music.Sequence`: Последовательность треков. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] sequences = list() diff --git a/yandex_music/rotor/station.py b/yandex_music/rotor/station.py index 9cb21c8b..f5e4fc29 100644 --- a/yandex_music/rotor/station.py +++ b/yandex_music/rotor/station.py @@ -66,7 +66,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Station']: Returns: :obj:`yandex_music.Station`: Станция. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Station, cls).de_json(data, client) diff --git a/yandex_music/rotor/station_data.py b/yandex_music/rotor/station_data.py index 704433b1..53dd80bb 100644 --- a/yandex_music/rotor/station_data.py +++ b/yandex_music/rotor/station_data.py @@ -33,7 +33,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['StationData']: Returns: :obj:`yandex_music.StationData`: Информация о личной станции. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(StationData, cls).de_json(data, client) diff --git a/yandex_music/rotor/station_result.py b/yandex_music/rotor/station_result.py index 74c8b338..ef752810 100644 --- a/yandex_music/rotor/station_result.py +++ b/yandex_music/rotor/station_result.py @@ -52,7 +52,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['StationResult']: Returns: :obj:`yandex_music.StationResult`: Радиостанция с настройками. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(StationResult, cls).de_json(data, client) @@ -66,7 +66,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['StationResult']: return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client') -> List['StationResult']: + def de_list(cls, data: list, client: 'Client') -> List['StationResult']: """Десериализация списка объектов. Args: @@ -76,7 +76,7 @@ def de_list(cls, data: dict, client: 'Client') -> List['StationResult']: Returns: :obj:`list` из :obj:`yandex_music.StationResult`: Радиостанции с настройками. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] station_results = list() diff --git a/yandex_music/rotor/station_tracks_result.py b/yandex_music/rotor/station_tracks_result.py index c54f905d..5c91c096 100644 --- a/yandex_music/rotor/station_tracks_result.py +++ b/yandex_music/rotor/station_tracks_result.py @@ -39,7 +39,7 @@ def de_json(cls, data, client) -> Optional['StationTracksResult']: Returns: :obj:`yandex_music.StationTracksResult`: Последовательность треков станции. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(StationTracksResult, cls).de_json(data, client) diff --git a/yandex_music/rotor/value.py b/yandex_music/rotor/value.py index 778658f9..367d00fe 100644 --- a/yandex_music/rotor/value.py +++ b/yandex_music/rotor/value.py @@ -35,7 +35,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Value']: Returns: :obj:`yandex_music.Value`: Значение. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Value, cls).de_json(data, client) @@ -43,7 +43,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Value']: return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client') -> List['Value']: + def de_list(cls, data: list, client: 'Client') -> List['Value']: """Десериализация списка объектов. Args: @@ -53,7 +53,7 @@ def de_list(cls, data: dict, client: 'Client') -> List['Value']: Returns: :obj:`list` из :obj:`yandex_music.Value`: Значения. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] values = list() diff --git a/yandex_music/search/best.py b/yandex_music/search/best.py index 0f427b41..a9e2a9a1 100644 --- a/yandex_music/search/best.py +++ b/yandex_music/search/best.py @@ -50,7 +50,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Best']: Returns: :obj:`yandex_music.Best`: Лучший результат. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Best, cls).de_json(data, client) diff --git a/yandex_music/search/search.py b/yandex_music/search/search.py index cceeb17c..b5fad21a 100644 --- a/yandex_music/search/search.py +++ b/yandex_music/search/search.py @@ -133,7 +133,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Search']: Returns: :obj:`yandex_music.Search`: Результаты поиска. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Search, cls).de_json(data, client) diff --git a/yandex_music/search/search_result.py b/yandex_music/search/search_result.py index 03c7b8cf..76a55553 100644 --- a/yandex_music/search/search_result.py +++ b/yandex_music/search/search_result.py @@ -60,7 +60,7 @@ def de_json(cls, data: Dict[str, Dict], client: 'Client', type_: str = None) -> Returns: :obj:`yandex_music.SearchResult`: Результаты поиска. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(SearchResult, cls).de_json(data, client) diff --git a/yandex_music/search/suggestions.py b/yandex_music/search/suggestions.py index c21d63d4..add90d23 100644 --- a/yandex_music/search/suggestions.py +++ b/yandex_music/search/suggestions.py @@ -41,7 +41,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Suggestions']: Returns: :obj:`yandex_music.Suggestions`: Подсказки при поиске. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Suggestions, cls).de_json(data, client) diff --git a/yandex_music/settings.py b/yandex_music/settings.py index 0b4bf5b5..533557ee 100644 --- a/yandex_music/settings.py +++ b/yandex_music/settings.py @@ -41,7 +41,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Settings']: Returns: :obj:`yandex_music.Settings`: Предложение по покупке. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Settings, cls).de_json(data, client) diff --git a/yandex_music/shot/shot.py b/yandex_music/shot/shot.py index 43caa55d..e6e540e5 100644 --- a/yandex_music/shot/shot.py +++ b/yandex_music/shot/shot.py @@ -44,7 +44,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Shot']: Returns: :obj:`yandex_music.Shot`: Шот от Алисы. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Shot, cls).de_json(data, client) @@ -55,7 +55,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Shot']: return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client') -> List['Shot']: + def de_list(cls, data: list, client: 'Client') -> List['Shot']: """Десериализация списка объектов. Args: @@ -65,7 +65,7 @@ def de_list(cls, data: dict, client: 'Client') -> List['Shot']: Returns: :obj:`list` из :obj:`yandex_music.Shot`: Шоты от Алисы. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] shots = list() diff --git a/yandex_music/shot/shot_data.py b/yandex_music/shot/shot_data.py index 5aaf61c0..4a8e6b91 100644 --- a/yandex_music/shot/shot_data.py +++ b/yandex_music/shot/shot_data.py @@ -122,7 +122,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['ShotData']: Returns: :obj:`yandex_music.ShotData`: Основная информация о шоте. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(ShotData, cls).de_json(data, client) diff --git a/yandex_music/shot/shot_event.py b/yandex_music/shot/shot_event.py index 49f3d9bd..7b3a1e50 100644 --- a/yandex_music/shot/shot_event.py +++ b/yandex_music/shot/shot_event.py @@ -35,7 +35,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['ShotEvent']: Returns: :obj:`yandex_music.ShotEvent`: Событие-шот перед началом следующего трека. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(ShotEvent, cls).de_json(data, client) diff --git a/yandex_music/shot/shot_type.py b/yandex_music/shot/shot_type.py index 64da2ecb..a9285916 100644 --- a/yandex_music/shot/shot_type.py +++ b/yandex_music/shot/shot_type.py @@ -35,7 +35,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['ShotType']: Returns: :obj:`yandex_music.ShotType`: Тип шота от Алисы. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(ShotType, cls).de_json(data, client) diff --git a/yandex_music/supplement/lyrics.py b/yandex_music/supplement/lyrics.py index 4f72a41f..d8f72b62 100644 --- a/yandex_music/supplement/lyrics.py +++ b/yandex_music/supplement/lyrics.py @@ -57,7 +57,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Lyrics']: Returns: :obj:`yandex_music.Lyrics`: Текст трека. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Lyrics, cls).de_json(data, client) diff --git a/yandex_music/supplement/supplement.py b/yandex_music/supplement/supplement.py index 33e5edb0..e84b1630 100644 --- a/yandex_music/supplement/supplement.py +++ b/yandex_music/supplement/supplement.py @@ -45,7 +45,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Supplement']: Returns: :obj:`yandex_music.Supplement`: Дополнительная информация о треке. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Supplement, cls).de_json(data, client) diff --git a/yandex_music/supplement/video_supplement.py b/yandex_music/supplement/video_supplement.py index 56b6e748..c73c880a 100644 --- a/yandex_music/supplement/video_supplement.py +++ b/yandex_music/supplement/video_supplement.py @@ -45,7 +45,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['VideoSupplement']: Returns: :obj:`yandex_music.VideoSupplement`: Видеоклип. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(VideoSupplement, cls).de_json(data, client) @@ -53,7 +53,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['VideoSupplement']: return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client') -> List['VideoSupplement']: + def de_list(cls, data: list, client: 'Client') -> List['VideoSupplement']: """Десериализация списка объектов. Args: @@ -63,7 +63,7 @@ def de_list(cls, data: dict, client: 'Client') -> List['VideoSupplement']: Returns: :obj:`list` из :obj:`yandex_music.VideoSupplement`: Видеоклипы. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] videos = list() diff --git a/yandex_music/track/licence_text_part.py b/yandex_music/track/licence_text_part.py index 0ed45207..97b06644 100644 --- a/yandex_music/track/licence_text_part.py +++ b/yandex_music/track/licence_text_part.py @@ -35,7 +35,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['PassportPhone']: Returns: :obj:`yandex_music.LicenceTextPart`: Строка лицензионного соглашения. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(LicenceTextPart, cls).de_json(data, client) @@ -43,7 +43,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['PassportPhone']: return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client') -> List['LicenceTextPart']: + def de_list(cls, data: list, client: 'Client') -> List['LicenceTextPart']: """Десериализация списка объектов. Args: @@ -53,7 +53,7 @@ def de_list(cls, data: dict, client: 'Client') -> List['LicenceTextPart']: Returns: :obj:`list` из :obj:`yandex_music.LicenceTextPart`: Строки текста с ссылкой на лицензионное соглашение. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] return [cls.de_json(row, client) for row in data] diff --git a/yandex_music/track/lyrics_info.py b/yandex_music/track/lyrics_info.py index 79b5257e..24f64afa 100644 --- a/yandex_music/track/lyrics_info.py +++ b/yandex_music/track/lyrics_info.py @@ -35,7 +35,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['LyricsInfo']: Returns: :obj:`yandex_music.LyricsInfo`: Типы доступных текстов трека. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(LyricsInfo, cls).de_json(data, client) diff --git a/yandex_music/track/lyrics_major.py b/yandex_music/track/lyrics_major.py index d1445fe4..bcad7307 100644 --- a/yandex_music/track/lyrics_major.py +++ b/yandex_music/track/lyrics_major.py @@ -38,7 +38,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['LyricsMajor']: Returns: :obj:`yandex_music.LyricsMajor`: Сервис-источник текстов к трекам. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(LyricsMajor, cls).de_json(data, client) diff --git a/yandex_music/track/major.py b/yandex_music/track/major.py index b8c4ec50..1aa28b30 100644 --- a/yandex_music/track/major.py +++ b/yandex_music/track/major.py @@ -35,7 +35,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Major']: Returns: :obj:`yandex_music.Major`: Мейджор-лейбл звукозаписи. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Major, cls).de_json(data, client) diff --git a/yandex_music/track/meta_data.py b/yandex_music/track/meta_data.py index c80b379c..fa1fa80e 100644 --- a/yandex_music/track/meta_data.py +++ b/yandex_music/track/meta_data.py @@ -47,7 +47,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['MetaData']: Returns: :obj:`yandex_music.MetaData`: Метаданные трека """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(MetaData, cls).de_json(data, client) diff --git a/yandex_music/track/normalization.py b/yandex_music/track/normalization.py index a0a60bea..b07aa000 100644 --- a/yandex_music/track/normalization.py +++ b/yandex_music/track/normalization.py @@ -35,7 +35,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Normalization']: Returns: :obj:`yandex_music.Normalization`: Значения для нормализации трека. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Normalization, cls).de_json(data, client) diff --git a/yandex_music/track/poetry_lover_match.py b/yandex_music/track/poetry_lover_match.py index 3aa1fe54..8d36ec8b 100644 --- a/yandex_music/track/poetry_lover_match.py +++ b/yandex_music/track/poetry_lover_match.py @@ -40,7 +40,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['PoetryLoverMatch']: Returns: :obj:`yandex_music.PoetryLoverMatch`: Позиция слова. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(PoetryLoverMatch, cls).de_json(data, client) @@ -48,7 +48,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['PoetryLoverMatch']: return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client') -> List['PoetryLoverMatch']: + def de_list(cls, data: list, client: 'Client') -> List['PoetryLoverMatch']: """Десериализация списка объектов. Args: @@ -58,7 +58,7 @@ def de_list(cls, data: dict, client: 'Client') -> List['PoetryLoverMatch']: Returns: :obj:`list` из :obj:`yandex_music.PoetryLoverMatch`: Список с позициями слов. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] return [cls.de_json(match, client) for match in data] diff --git a/yandex_music/track/r128.py b/yandex_music/track/r128.py index 7b489fed..9f0bdae6 100644 --- a/yandex_music/track/r128.py +++ b/yandex_music/track/r128.py @@ -37,7 +37,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['R128']: Returns: :obj:`yandex_music.R128`: Параметры нормализации громкости трека в соответствии с рекомендацией EBU R 128. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(R128, cls).de_json(data, client) diff --git a/yandex_music/track/track.py b/yandex_music/track/track.py index 1725b2ac..36b39f9a 100644 --- a/yandex_music/track/track.py +++ b/yandex_music/track/track.py @@ -481,7 +481,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Track']: Returns: :obj:`yandex_music.Track`: Трек. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Track, cls).de_json(data, client) @@ -502,7 +502,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Track']: return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client') -> List['Track']: + def de_list(cls, data: list, client: 'Client') -> List['Track']: """Десериализация списка объектов. Args: @@ -512,7 +512,7 @@ def de_list(cls, data: dict, client: 'Client') -> List['Track']: Returns: :obj:`list` из :obj:`yandex_music.Track`: Треки. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] return [cls.de_json(track, client) for track in data] diff --git a/yandex_music/track/track_lyrics.py b/yandex_music/track/track_lyrics.py index 642d7b1c..df0d6109 100644 --- a/yandex_music/track/track_lyrics.py +++ b/yandex_music/track/track_lyrics.py @@ -61,7 +61,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['TrackLyrics']: Returns: :obj:`yandex_music.TrackLyrics`: Текст трека. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(TrackLyrics, cls).de_json(data, client) diff --git a/yandex_music/track/tracks_similar.py b/yandex_music/track/tracks_similar.py index 43c4b1cf..1d946145 100644 --- a/yandex_music/track/tracks_similar.py +++ b/yandex_music/track/tracks_similar.py @@ -44,7 +44,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['SimilarTracks']: Returns: :obj:`yandex_music.SimilarTracks`: Список похожих треков на другой трек. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(SimilarTracks, cls).de_json(data, client) diff --git a/yandex_music/track_short.py b/yandex_music/track_short.py index cc2313ca..0736223f 100644 --- a/yandex_music/track_short.py +++ b/yandex_music/track_short.py @@ -74,7 +74,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['TrackShort']: Returns: :obj:`yandex_music.TrackShort`: Укороченная версия трека с неполными данными. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(TrackShort, cls).de_json(data, client) @@ -86,7 +86,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['TrackShort']: return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client') -> List['TrackShort']: + def de_list(cls, data: list, client: 'Client') -> List['TrackShort']: """Десериализация списка объектов. Args: @@ -96,7 +96,7 @@ def de_list(cls, data: dict, client: 'Client') -> List['TrackShort']: Returns: :obj:`list` из :obj:`yandex_music.TrackShort`: Укороченные версии треков с неполными данными. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] return [cls.de_json(track, client) for track in data] diff --git a/yandex_music/tracks_list.py b/yandex_music/tracks_list.py index 8e6135fd..3e8628ce 100644 --- a/yandex_music/tracks_list.py +++ b/yandex_music/tracks_list.py @@ -67,7 +67,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['TracksList']: Returns: :obj:`yandex_music.TracksList`: Список треков. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(TracksList, cls).de_json(data, client) diff --git a/yandex_music/utils/response.py b/yandex_music/utils/response.py index 5eedf837..22a93240 100644 --- a/yandex_music/utils/response.py +++ b/yandex_music/utils/response.py @@ -52,7 +52,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Response']: Returns: :obj:`yandex_music.utils.response.Response`: Ответ API. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Response, cls).de_json(data, client) diff --git a/yandex_music/video.py b/yandex_music/video.py index cb8f72f0..d88df952 100644 --- a/yandex_music/video.py +++ b/yandex_music/video.py @@ -53,7 +53,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Video']: Returns: :obj:`yandex_music.Video`: Видео. """ - if not data: + if not cls.is_valid_model_data(data): return None data = super(Video, cls).de_json(data, client) @@ -61,7 +61,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Video']: return cls(client=client, **data) @classmethod - def de_list(cls, data: dict, client: 'Client') -> List['Video']: + def de_list(cls, data: list, client: 'Client') -> List['Video']: """Десериализация списка объектов. Args: @@ -71,7 +71,7 @@ def de_list(cls, data: dict, client: 'Client') -> List['Video']: Returns: :obj:`list` из :obj:`yandex_music.Video`: Видео. """ - if not data: + if not cls.is_valid_model_data(data, array=True): return [] videos = list()