Skip to content

Commit

Permalink
FIX: NAV-153 - Fix field validators
Browse files Browse the repository at this point in the history
  • Loading branch information
munterfi committed Aug 22, 2024
1 parent e8b4f03 commit 49151d7
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions public_transit_client/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ class Trip(BaseModel):
route: Route
stop_times: list[StopTime] = Field(alias="stopTimes")

@staticmethod
@field_validator("stop_times", mode="before")
def _set_stop_times_not_none(v: list[StopTime] | None) -> list[StopTime]:
def _set_stop_times_not_none(cls, v: list[StopTime] | None) -> list[StopTime]:
print("I AM RUNNING!!! AND FUCK MYPY")
return v or []


Expand Down Expand Up @@ -254,9 +254,8 @@ class Connection(BaseModel):

legs: list[Leg]

@staticmethod
@field_validator("legs")
def _legs_not_empty(v: list[Leg]) -> list[Leg]:
def _legs_not_empty(cls, v: list[Leg]) -> list[Leg]:
if not v:
raise ValueError("legs must not be empty")
return v
Expand Down

0 comments on commit 49151d7

Please sign in to comment.