mirror of https://github.com/tiangolo/fastapi.git
🐛 Fix unformatted `{type_}` in FastAPIError (#14416)
Co-authored-by: Alex Colby <alex.colby@intellisense.io>
This commit is contained in:
parent
10eed3806a
commit
cb3792d39e
|
|
@ -110,7 +110,9 @@ def create_model_field(
|
||||||
try:
|
try:
|
||||||
return v1.ModelField(**v1_kwargs) # type: ignore[no-any-return]
|
return v1.ModelField(**v1_kwargs) # type: ignore[no-any-return]
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
raise fastapi.exceptions.FastAPIError(_invalid_args_message) from None
|
raise fastapi.exceptions.FastAPIError(
|
||||||
|
_invalid_args_message.format(type_=type_)
|
||||||
|
) from None
|
||||||
elif PYDANTIC_V2:
|
elif PYDANTIC_V2:
|
||||||
from ._compat import v2
|
from ._compat import v2
|
||||||
|
|
||||||
|
|
@ -121,7 +123,9 @@ def create_model_field(
|
||||||
try:
|
try:
|
||||||
return v2.ModelField(**kwargs) # type: ignore[return-value,arg-type]
|
return v2.ModelField(**kwargs) # type: ignore[return-value,arg-type]
|
||||||
except PydanticSchemaGenerationError:
|
except PydanticSchemaGenerationError:
|
||||||
raise fastapi.exceptions.FastAPIError(_invalid_args_message) from None
|
raise fastapi.exceptions.FastAPIError(
|
||||||
|
_invalid_args_message.format(type_=type_)
|
||||||
|
) from None
|
||||||
# Pydantic v2 is not installed, but it's not a Pydantic v1 ModelField, it could be
|
# Pydantic v2 is not installed, but it's not a Pydantic v1 ModelField, it could be
|
||||||
# a Pydantic v1 type, like a constrained int
|
# a Pydantic v1 type, like a constrained int
|
||||||
from fastapi._compat import v1
|
from fastapi._compat import v1
|
||||||
|
|
@ -129,7 +133,9 @@ def create_model_field(
|
||||||
try:
|
try:
|
||||||
return v1.ModelField(**v1_kwargs) # type: ignore[no-any-return]
|
return v1.ModelField(**v1_kwargs) # type: ignore[no-any-return]
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
raise fastapi.exceptions.FastAPIError(_invalid_args_message) from None
|
raise fastapi.exceptions.FastAPIError(
|
||||||
|
_invalid_args_message.format(type_=type_)
|
||||||
|
) from None
|
||||||
|
|
||||||
|
|
||||||
def create_cloned_field(
|
def create_cloned_field(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue