Skip to content

Commit

Permalink
backend: migrate to pydantic v2
Browse files Browse the repository at this point in the history
  • Loading branch information
nikromen committed Aug 8, 2024
1 parent 5b71405 commit b55a32f
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions backend/src/schema.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from typing import Optional

from pydantic import AnyUrl, BaseModel, root_validator
from pydantic import AnyUrl, BaseModel, model_validator

from src.constants import BuildIdTitleEnum


def _check_spec_container_are_exclusively_mutual(_, values):
def _check_spec_container_are_exclusively_mutual(values):
spec_file = values.get("spec_file")
container_file = values.get("container_file")
if spec_file and container_file:
Expand Down Expand Up @@ -35,10 +35,10 @@ class ContributeResponseSchema(BaseModel):
spec_file: Optional[NameContentSchema] = None
container_file: Optional[NameContentSchema] = None

# validators
_normalize_spec_and_container_file = root_validator(pre=True, allow_reuse=True)(
_check_spec_container_are_exclusively_mutual
)
@model_validator(mode="before")
@classmethod
def _verify_spec_and_container_file(cls, values):
return _check_spec_container_are_exclusively_mutual(values)


class SnippetSchema(BaseModel):
Expand Down Expand Up @@ -82,10 +82,10 @@ class _WithoutLogsSchema(BaseModel):
spec_file: Optional[NameContentSchema] = None
container_file: Optional[NameContentSchema] = None

# validators
_normalize_spec_and_container_file = root_validator(pre=True, allow_reuse=True)(
_check_spec_container_are_exclusively_mutual
)
@model_validator(mode="before")
@classmethod
def _verify_spec_and_container_file(cls, values):
return _check_spec_container_are_exclusively_mutual(values)


class FeedbackInputSchema(_WithoutLogsSchema):
Expand Down

0 comments on commit b55a32f

Please sign in to comment.