-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
575 additions
and
348 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
[tool:pytest] | ||
addopts=--cov spoffy --no-cov-on-fail | ||
asyncio_mode = auto | ||
|
||
[flake8] | ||
max-line-length = 79 | ||
max-line-length = 120 | ||
builtins = | ||
_ | ||
exclude = ./tests/mock/responses/ | ||
# exlucd test/mock/responses and tests/modules/snapshots | ||
exclude = ./tests/mock/responses/, ./tests/modules/snapshots | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,5 @@ | ||
from pydantic import BaseModel, BaseConfig, Extra | ||
from typing_extensions import TypedDict | ||
|
||
|
||
class Cfg(BaseConfig): | ||
extra = Extra.allow | ||
|
||
|
||
class CustomMeta(BaseModel.__class__): # type:ignore | ||
def __new__(mcs, name, bases, namespace): | ||
ret = super().__new__(mcs, name, bases, namespace) | ||
for field in ret.__fields__.values(): | ||
field.required = False | ||
field.prepare() | ||
return ret | ||
|
||
|
||
class SpotifyObject(BaseModel, metaclass=CustomMeta): | ||
Config = Cfg | ||
|
||
def __init__(self, **data) -> None: | ||
super().__init__(**data) | ||
for field in self.__fields_set__: | ||
if field not in self.__fields__: | ||
value = getattr(self, field) | ||
if isinstance(value, dict): | ||
setattr(self, field, SpotifyObject(**value)) | ||
elif ( | ||
value | ||
and isinstance(value, list) | ||
and isinstance(value[0], dict) | ||
): | ||
setattr(self, field, [SpotifyObject(**v) for v in value]) | ||
class SpotifyObject(TypedDict): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
from typing import List | ||
|
||
|
||
from spoffy.models.core import Track, Artist | ||
from spoffy.models.paging import OffsetPaging | ||
|
||
|
||
class TopArtistsPaging(OffsetPaging): | ||
items: List[Artist] | ||
class TopArtistsPaging(OffsetPaging[Artist]): | ||
pass | ||
|
||
|
||
class TopTracksPaging(OffsetPaging): | ||
items: List[Track] | ||
class TopTracksPaging(OffsetPaging[Track]): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.