|
|
|
@ -23,7 +23,7 @@ from pydantic import PydanticSchemaGenerationError as PydanticSchemaGenerationEr |
|
|
|
from pydantic import PydanticUndefinedAnnotation as PydanticUndefinedAnnotation |
|
|
|
from pydantic import ValidationError as ValidationError |
|
|
|
from pydantic._internal import _typing_extra as _pydantic_typing_extra |
|
|
|
from pydantic._internal._schema_generation_shared import ( # type: ignore[attr-defined] # ty: ignore[unused-ignore-comment] |
|
|
|
from pydantic._internal._schema_generation_shared import ( # type: ignore[attr-defined] |
|
|
|
GetJsonSchemaHandler as GetJsonSchemaHandler, |
|
|
|
) |
|
|
|
from pydantic.fields import FieldInfo as FieldInfo |
|
|
|
@ -372,8 +372,8 @@ def serialize_sequence_value(*, field: ModelField, value: Any) -> Sequence[Any]: |
|
|
|
continue |
|
|
|
origin_type = get_origin(union_arg) or union_arg |
|
|
|
break |
|
|
|
assert issubclass(origin_type, shared.sequence_types) # type: ignore[arg-type] |
|
|
|
return shared.sequence_annotation_to_type[origin_type](value) # type: ignore[no-any-return,index] |
|
|
|
assert issubclass(origin_type, shared.sequence_types) # type: ignore[arg-type] # ty: ignore[invalid-argument-type] |
|
|
|
return shared.sequence_annotation_to_type[origin_type](value) # type: ignore[no-any-return,index] # ty: ignore[invalid-return-type] |
|
|
|
|
|
|
|
|
|
|
|
def get_missing_field_error(loc: tuple[int | str, ...]) -> dict[str, Any]: |
|
|
|
@ -381,14 +381,14 @@ def get_missing_field_error(loc: tuple[int | str, ...]) -> dict[str, Any]: |
|
|
|
"Field required", [{"type": "missing", "loc": loc, "input": {}}] |
|
|
|
).errors(include_url=False)[0] |
|
|
|
error["input"] = None |
|
|
|
return error # type: ignore[return-value] |
|
|
|
return error # type: ignore[return-value] # ty: ignore[invalid-return-type] |
|
|
|
|
|
|
|
|
|
|
|
def create_body_model( |
|
|
|
*, fields: Sequence[ModelField], model_name: str |
|
|
|
) -> type[BaseModel]: |
|
|
|
field_params = {f.name: (f.field_info.annotation, f.field_info) for f in fields} |
|
|
|
BodyModel: type[BaseModel] = create_model(model_name, **field_params) # type: ignore[call-overload] |
|
|
|
BodyModel: type[BaseModel] = create_model(model_name, **field_params) # type: ignore[call-overload] # ty: ignore[no-matching-overload] |
|
|
|
return BodyModel |
|
|
|
|
|
|
|
|
|
|
|
@ -451,7 +451,7 @@ def get_flat_models_from_annotation( |
|
|
|
for arg in get_args(annotation): |
|
|
|
if lenient_issubclass(arg, (BaseModel, Enum)): |
|
|
|
if arg not in known_models: |
|
|
|
known_models.add(arg) # type: ignore[arg-type] # ty: ignore[unused-ignore-comment] |
|
|
|
known_models.add(arg) # type: ignore[arg-type] |
|
|
|
if lenient_issubclass(arg, BaseModel): |
|
|
|
get_flat_models_from_model(arg, known_models=known_models) |
|
|
|
else: |
|
|
|
|