As pydantic v1 support is dropped, we can "inline" the color encoder

This commit is contained in:
Pedro Lobato 2026-02-10 14:13:14 -05:00
parent c78d659487
commit d7a6788230
1 changed files with 4 additions and 6 deletions

View File

@ -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