|
|
@ -1,4 +1,3 @@ |
|
|
from collections.abc import Iterable |
|
|
|
|
|
from typing import ( |
|
|
from typing import ( |
|
|
Annotated, |
|
|
Annotated, |
|
|
Any, |
|
|
Any, |
|
|
@ -135,27 +134,12 @@ class UploadFile(StarletteUploadFile): |
|
|
""" |
|
|
""" |
|
|
return await super().close() |
|
|
return await super().close() |
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
|
|
def __get_validators__(cls: type["UploadFile"]) -> Iterable[Callable[..., Any]]: |
|
|
|
|
|
yield cls.validate |
|
|
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
|
|
def validate(cls: type["UploadFile"], v: Any) -> Any: |
|
|
|
|
|
if not isinstance(v, StarletteUploadFile): |
|
|
|
|
|
raise ValueError(f"Expected UploadFile, received: {type(v)}") |
|
|
|
|
|
return v |
|
|
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
@classmethod |
|
|
def _validate(cls, __input_value: Any, _: Any) -> "UploadFile": |
|
|
def _validate(cls, __input_value: Any, _: Any) -> "UploadFile": |
|
|
if not isinstance(__input_value, StarletteUploadFile): |
|
|
if not isinstance(__input_value, StarletteUploadFile): |
|
|
raise ValueError(f"Expected UploadFile, received: {type(__input_value)}") |
|
|
raise ValueError(f"Expected UploadFile, received: {type(__input_value)}") |
|
|
return cast(UploadFile, __input_value) |
|
|
return cast(UploadFile, __input_value) |
|
|
|
|
|
|
|
|
# TODO: remove when deprecating Pydantic v1 |
|
|
|
|
|
@classmethod |
|
|
|
|
|
def __modify_schema__(cls, field_schema: dict[str, Any]) -> None: |
|
|
|
|
|
field_schema.update({"type": "string", "format": "binary"}) |
|
|
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
@classmethod |
|
|
def __get_pydantic_json_schema__( |
|
|
def __get_pydantic_json_schema__( |
|
|
cls, core_schema: CoreSchema, handler: GetJsonSchemaHandler |
|
|
cls, core_schema: CoreSchema, handler: GetJsonSchemaHandler |
|
|
|