This commit is contained in:
Taras Terletsky 2024-08-12 22:28:52 +03:00
parent 27319fdf0f
commit 42f5594125
3 changed files with 8 additions and 4 deletions

View file

@ -30,7 +30,7 @@ class BaseUploadContext(RealBaseModel):
model_config = ConfigDict(**RealBaseModel.model_config, strict=True)
caption: str
filename: str
filepath: FilePath
filepath: FilePath | str
duration: float
type: MessageMediaType
is_cached: bool = False
@ -39,7 +39,7 @@ class BaseUploadContext(RealBaseModel):
class VideoUploadContext(BaseUploadContext):
height: int | float
width: int | float
thumb: FilePath | None = None
thumb: FilePath | str | None = None
class AudioUploadContext(BaseUploadContext):

View file

@ -32,7 +32,9 @@ except ImportError:
class BaseHostConfModel(BaseModel):
# TODO: Add validators.
model_config = ConfigDict(strict=True, frozen=True, validate_assignment=True)
model_config = ConfigDict(
strict=True, frozen=True, validate_assignment=True, validate_default=True
)
hostnames: tuple[str, ...]

View file

@ -8,7 +8,9 @@ from yt_shared.enums import RabbitPayloadType
class RealBaseModel(BaseModel, ABC):
"""Base Pydantic model. All non-strict models should inherit from it."""
model_config = ConfigDict(extra='forbid', validate_default=True)
model_config = ConfigDict(
extra='forbid', validate_default=True, validate_assignment=True
)
class StrictRealBaseModel(RealBaseModel, ABC):