Skip to content

Commit

Permalink
Merge pull request #216 from dixneuf19/fix/pydantic-v2
Browse files Browse the repository at this point in the history
fix: update pydantic to v2
  • Loading branch information
dixneuf19 authored Oct 12, 2023
2 parents afd679b + 19536b7 commit 47cc92b
Show file tree
Hide file tree
Showing 8 changed files with 152 additions and 52 deletions.
182 changes: 140 additions & 42 deletions poetry.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ loguru = "==0.7.2"
requests = "==2.31.0"
python-engineio = "==4.7.1"
ruff = "^0.0.292"
pydantic = ">=2.0.0"

[tool.poetry.group.dev.dependencies]
pytest = "==7.4.2"
Expand Down
2 changes: 1 addition & 1 deletion tests/test_fiftyfifty.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
@pytest.mark.asyncio
async def test_get_current_track_remote():
radio = Radio5050()
assert Track(**radio.get_current_track().dict())
assert Track(**radio.get_current_track().model_dump())
2 changes: 1 addition & 1 deletion tests/test_radio_feelgood_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

@pytest.mark.asyncio
async def test_get_current_song_remote():
assert Track(**RadioFeelGood().get_current_track().dict())
assert Track(**RadioFeelGood().get_current_track().model_dump())


def test_get_current_song_mocked(mocker):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_radio_france_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def test_execute_live_query():
response = execute_live_query("FIP")
except LiveUnavailableException:
return
assert Track(**response.dict())
assert Track(**response.model_dump())


def test_execute_live_query_with_exception(mocker):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_radio_meuh_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

@pytest.mark.asyncio
async def test_get_current_song_remote():
assert Track(**RadioMeuh().get_current_track().dict())
assert Track(**RadioMeuh().get_current_track().model_dump())


def test_get_current_song_mocked(mocker):
Expand Down
12 changes: 6 additions & 6 deletions whats_on_fip/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

class Track(BaseModel):
title: str
album: Optional[str]
album: Optional[str] = None
artist: str
year: Optional[int]
label: Optional[str]
musical_kind: Optional[str]
year: Optional[int] = None
label: Optional[str] = None
musical_kind: Optional[str] = None
external_urls: Dict[str, str] = {}
cover_url: Optional[str]
cover_url: Optional[str] = None

def __str__(self) -> str:
return self.title + f" ({self.year})" if self.year else "" + f" - {self.artist}"
Expand All @@ -23,7 +23,7 @@ class Station(BaseModel):

class APIStatus(BaseModel):
code: int
message: Optional[str]
message: Optional[str] = None


class Message(BaseModel):
Expand Down
1 change: 1 addition & 0 deletions whats_on_fip/radio_meuh_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def __init__(self) -> None:

def get_current_track(self) -> Track:
r = requests.get(self.url)
r.raise_for_status()
song = r.json()[0]

song = {
Expand Down

0 comments on commit 47cc92b

Please sign in to comment.