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

fix: Pydantic V1 style @validator validators are deprecated #641

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from abc import ABC
from typing import Any

from pydantic import Field, PrivateAttr, validator
from pydantic import Field, PrivateAttr, field_validator

from open_gopro.models.bases import CustomBaseModel
from open_gopro.types import JsonDict
Expand Down Expand Up @@ -143,7 +143,7 @@ class MediaFileSystem(CustomBaseModel):
directory: str = Field(alias="d") # Directory that the files are in
file_system: list[MediaItem] = Field(alias="fs") #: List of files

@validator("file_system", pre=True, each_item=True)
@field_validator("file_system", mode="before", check_fields=True)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is breaking unit testing with:

>       return (GroupedMediaItem if "g" in item else MediaItem)(**item)
E       TypeError: open_gopro.models.media_list.MediaItem() argument after ** must be a mapping, not list

@classmethod
def identify_item(cls, item: JsonDict) -> MediaItem:
"""Extent item into GroupedMediaItem if it such an item
Expand Down
Loading