Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pydantic #124

Merged
merged 3 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,223 changes: 743 additions & 480 deletions poetry.lock

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "shazamio"
version = "0.6.0"
version = "0.7.0"
description = "Is a asynchronous framework from reverse engineered Shazam API written in Python 3.8+ with asyncio and aiohttp."
authors = ["dotX12"]
license = "MIT License"
Expand All @@ -14,17 +14,16 @@ include = [
]

[tool.poetry.dependencies]
python = "^3.8"
numpy = "^1.24.0"
python = "^3.10"
numpy = "2.1.2"
aiohttp = "^3.8.3"
pydub = "^0.25.1"
dataclass-factory = "2.16"
aiofiles = "23.2.1"
anyio = "4.3.0"
pydantic = "^1.10.2"
shazamio-core = "^1.0.7"
aiohttp-retry = "^2.8.3"

pydantic = "2.9.2"
[tool.poetry.dev-dependencies]
black = {version = "^24.2.0", allow-prereleases = true}
pytest = "8.1.2"
Expand Down
45 changes: 29 additions & 16 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
aiofiles~=0.8.0
aiohttp~=3.8.1
attrs==20.3.0
chardet==3.0.4
dataclass-factory==2.16
idna==3.1
multidict==5.1.0
numpy~=1.22.1
pydub==0.25.1
typing-extensions==3.7.4.3
yarl==1.6.3

pytest~=7.1.2
setuptools~=65.5.1
pytest-asyncio~=0.19.0
anyio~=3.6.1
aiofiles==24.1.0
aiohappyeyeballs==2.4.3
aiohttp==3.10.10
aiosignal==1.3.1
annotated-types==0.7.0
anyio==4.6.2.post1
async-timeout==4.0.3
attrs==24.2.0
chardet==5.2.0
dataclass-factory==2.16
exceptiongroup==1.2.2
frozenlist==1.4.1
idna==3.10
iniconfig==2.0.0
multidict==6.1.0
numpy==2.1.2
packaging==24.1
pluggy==1.5.0
propcache==0.2.0
pydantic==2.9.2
pydantic_core==2.23.4
pydub==0.25.1
pytest==8.3.3
pytest-asyncio==0.24.0
shazamio_core==1.0.7
sniffio==1.3.1
tomli==2.0.2
typing_extensions==4.12.2
yarl==1.16.0
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="shazamio",
version="0.5.1",
version="0.7.0",
author="dotX12",
description="Is a FREE asynchronous library from reverse engineered Shazam API written in Python 3.6+ with asyncio and aiohttp. Includes all the methods that Shazam has, including searching for a song by file.",
long_description=long_description,
Expand All @@ -20,5 +20,5 @@
"shazamio_core",
],
packages=setuptools.find_packages(),
python_requires=">=3.8",
python_requires=">=3.10",
)
7 changes: 5 additions & 2 deletions shazamio/schemas/artist/views/top_song.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@

from shazamio.schemas.artist.views.top_music import PlayParams
from shazamio.schemas.attributes import AttributeName
from shazamio.schemas.base import BaseAttributesModel, BaseIdTypeHref
from shazamio.schemas.base import (
BaseAttributesModel,
BaseHrefNext,
)
from shazamio.schemas.photos import ImageModel
from shazamio.schemas.urls import UrlDTO

Expand Down Expand Up @@ -36,6 +39,6 @@ class AttributesTopSong(BaseModel):
content_rating: Optional[str] = Field(None, alias="contentRating")


class TopSong(BaseIdTypeHref):
class TopSong(BaseHrefNext):
attributes: Optional[AttributeName] = None
data: Optional[List[BaseAttributesModel[AttributesTopSong]]] = None
16 changes: 9 additions & 7 deletions shazamio/schemas/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from typing import TypeVar

from pydantic import BaseModel
from pydantic.generics import GenericModel

T = TypeVar("T", bound=BaseModel)

Expand All @@ -17,22 +16,25 @@ class BaseIdTypeHref(BaseHref):
type: str


class BaseIdTypeHrefAttributesModel(GenericModel, BaseIdTypeHref, Generic[T]):
class BaseHrefNext(BaseHref):
next: Optional[str] = None


class BaseIdTypeHrefAttributesModel(BaseIdTypeHref, Generic[T]):
attributes: T


class BaseAttributesModel(GenericModel, BaseModel, Generic[T]):
class BaseAttributesModel(BaseModel, Generic[T]):
attributes: T


class BaseDataModel(GenericModel, BaseModel, Generic[T]):
class BaseDataModel(BaseModel, Generic[T]):
data: T


class BaseHrefNextData(GenericModel, BaseHref, Generic[T]):
next: Optional[str] = None
class BaseHrefNextData(BaseHrefNext, Generic[T]):
data: T


class BaseHrefData(GenericModel, BaseHref, Generic[T]):
class BaseHrefData(BaseHref, Generic[T]):
data: T
2 changes: 1 addition & 1 deletion shazamio/schemas/playlist/playlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class PlayListAttributes(BaseModel):
url: str
play_params: Optional[PlayParams] = Field(None, alias="playParams")
disc_number: int = Field(..., alias="discNumber")
has_credits: bool = Field(..., alias="hasCredits")
has_credits: Optional[bool] = Field(None, alias="hasCredits")
is_apple_digital_master: bool = Field(..., alias="isAppleDigitalMaster")
has_lyrics: bool = Field(..., alias="hasLyrics")
audio_traits: List[str] = Field(..., alias="audioTraits")
Expand Down
8 changes: 4 additions & 4 deletions shazamio/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def track(cls, data):

@classmethod
def playlist(cls, data) -> PlayList:
return PlayList.parse_obj(data)
return PlayList.model_validate(data)

@classmethod
def playlists(cls, data) -> List[PlayList]:
Expand All @@ -33,11 +33,11 @@ def youtube(cls, data):

@classmethod
def artist_v2(cls, data) -> ArtistResponse:
return ArtistResponse.parse_obj(data)
return ArtistResponse.model_validate(data)

@classmethod
def artist_albums(cls, data) -> FullAlbumsModel:
return FullAlbumsModel.parse_obj(data)
return FullAlbumsModel.model_validate(data)

@classmethod
def artist(cls, data):
Expand All @@ -49,4 +49,4 @@ def full_track(cls, data):

@classmethod
def album_info(cls, data) -> BaseDataModel[List[AlbumModel]]:
return BaseDataModel[List[AlbumModel]].parse_obj(data)
return BaseDataModel[List[AlbumModel]].model_validate(data)
Loading