yandex-music-api/yandex_music/artist/ratings.py

42 行
1.2 KiB
Python
Raw 通常表示 履歴

from typing import TYPE_CHECKING, Optional
from yandex_music import YandexMusicObject
if TYPE_CHECKING:
from yandex_music import Client
class Ratings(YandexMusicObject):
def __init__(self,
week: int,
month: int,
day: Optional[int] = None,
client: Optional['Client'] = None,
**kwargs) -> None:
self.week = week
self.month = month
self.day = day
self.client = client
self._id_attrs = (self.week, self.month)
@classmethod
def de_json(cls, data: dict, client: 'Client') -> Optional['Ratings']:
"""Десериализация объекта.
Args:
data (:obj:`dict`): Поля и значения десериализуемого объекта.
client (:obj:`yandex_music.Client`): Объект класса :class:`yandex_music.Client` представляющий клиент Yandex
Music.
Returns:
:obj:`yandex_music.Ratings`: Объект класса :class:`yandex_music.Ratings`.
"""
if not data:
return None
data = super(Ratings, cls).de_json(data, client)
return cls(client=client, **data)