|
|
|
@ -49,7 +49,7 @@ def evaluate_forwardref( |
|
|
|
try_eval_type = getattr(_pydantic_typing_extra, "try_eval_type", None) |
|
|
|
if try_eval_type is not None: |
|
|
|
return try_eval_type(value, globalns, localns)[0] |
|
|
|
return _pydantic_typing_extra.eval_type_lenient( # ty: ignore[deprecated] |
|
|
|
return _pydantic_typing_extra.eval_type_lenient( # type: ignore[deprecated] |
|
|
|
value, globalns, localns |
|
|
|
) |
|
|
|
|
|
|
|
@ -161,7 +161,7 @@ class ModelField: |
|
|
|
Field(**field_dict["attributes"]), |
|
|
|
) |
|
|
|
self._type_adapter: TypeAdapter[Any] = TypeAdapter( |
|
|
|
Annotated[annotated_args], # ty: ignore[invalid-type-form] |
|
|
|
Annotated[annotated_args], # type: ignore[invalid-type-form] |
|
|
|
config=self.config, |
|
|
|
) |
|
|
|
|
|
|
|
@ -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] # 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] |
|
|
|
assert issubclass(origin_type, shared.sequence_types) # type: ignore[arg-type] # type: ignore[invalid-argument-type] |
|
|
|
return shared.sequence_annotation_to_type[origin_type](value) # type: ignore[no-any-return,index] # type: 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] # ty: ignore[invalid-return-type] |
|
|
|
return error # type: ignore[return-value] # type: 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] # ty: ignore[no-matching-overload] |
|
|
|
BodyModel: type[BaseModel] = create_model(model_name, **field_params) # type: ignore[call-overload] # type: ignore[no-matching-overload] |
|
|
|
return BodyModel |
|
|
|
|
|
|
|
|
|
|
|
|