Skip to content

Commit

Permalink
handle optional values correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Anas Husseini committed Feb 12, 2024
1 parent 5250d05 commit add3991
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/image/utils/schema/triggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ class Config:
extra = pydantic.Extra.forbid

@pydantic.validator("end_of_life")
@classmethod
def ensure_still_supported(cls, v: datetime) -> datetime:
def ensure_still_supported(cls, v: Optional[datetime]) -> Optional[datetime]:
"""ensure that the end of life isn't reached."""
if v < datetime.now(timezone.utc):
if v is None or v < datetime.now(timezone.utc):
raise ImageReachedEol("This track has reached its end of life")
return v

Expand Down Expand Up @@ -72,10 +71,9 @@ def _check_risks(cls, values: List) -> str:
return values

@pydantic.validator("end_of_life")
@classmethod
def ensure_still_supported(cls, v: datetime) -> datetime:
def ensure_still_supported(cls, v: Optional[datetime]) -> Optional[datetime]:
"""ensure that the end of life isn't reached."""
if v < datetime.now(timezone.utc):
if v is None or v < datetime.now(timezone.utc):
raise ImageReachedEol("This track has reached its end of life")
return v

Expand Down

0 comments on commit add3991

Please sign in to comment.