mirror of https://github.com/tiangolo/fastapi.git
As pydantic v1 support is dropped, we can "inline" the color encoder
This commit is contained in:
parent
c78d659487
commit
d7a6788230
|
|
@ -33,18 +33,16 @@ from pydantic.networks import AnyUrl, NameEmail
|
|||
from pydantic.types import SecretBytes, SecretStr
|
||||
from pydantic_core import PydanticUndefinedType
|
||||
|
||||
# Dropped support for Pydantic v1 so we can remove the try-except import and the related code
|
||||
from pydantic_extra_types import color as et_color
|
||||
|
||||
from ._compat import (
|
||||
Url,
|
||||
is_pydantic_v1_model_instance,
|
||||
)
|
||||
|
||||
encoders_by_extra_type: dict[type[Any], Callable[[Any], Any]] = {}
|
||||
try:
|
||||
from pydantic_extra_types import color as et_color
|
||||
encoders_by_extra_type: dict[type[Any], Callable[[Any], Any]] = {et_color.Color: str}
|
||||
|
||||
encoders_by_extra_type[et_color.Color] = str
|
||||
except ImportError:
|
||||
pass
|
||||
try:
|
||||
from pydantic_extra_types import coordinate
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue