mirror of https://github.com/tiangolo/fastapi.git
Fix mismatch on versions
This commit is contained in:
parent
bb29cf2912
commit
5cdeeccaf9
|
|
@ -33,16 +33,19 @@ from pydantic.networks import AnyUrl, NameEmail
|
|||
from pydantic.types import SecretBytes, SecretStr
|
||||
from pydantic_core import PydanticUndefinedType
|
||||
|
||||
encoders_by_extra_type: dict[type[Any], Callable[[Any], Any]] = {}
|
||||
try:
|
||||
from pydantic_extra_types import color as et_color
|
||||
|
||||
encoders_by_extra_type[et_color.Color] = str
|
||||
except ImportError:
|
||||
pass
|
||||
try:
|
||||
from pydantic_extra_types import coordinate
|
||||
|
||||
encoders_by_extra_type: dict[type[Any], Callable[[Any], Any]] = {
|
||||
coordinate.Coordinate: str,
|
||||
et_color.Color: str,
|
||||
}
|
||||
encoders_by_extra_type[coordinate.Coordinate] = str
|
||||
except ImportError:
|
||||
encoders_by_extra_type = {}
|
||||
pass
|
||||
|
||||
from ._compat import (
|
||||
Url,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import sys
|
||||
import warnings
|
||||
from collections import deque, namedtuple
|
||||
from collections.abc import Sequence
|
||||
|
|
@ -430,20 +429,12 @@ def test_encode_pydantic_extra_types_coordinate():
|
|||
assert jsonable_encoder(coord) == str(coord)
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
sys.version_info >= (3, 10),
|
||||
reason="Tested via pydantic_extra_types on Python >= 3.10",
|
||||
)
|
||||
def test_encode_pydantic_color():
|
||||
pydantic_color = pytest.importorskip("pydantic.color")
|
||||
color = pydantic_color.Color("red")
|
||||
assert jsonable_encoder(color) == str(color)
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
sys.version_info < (3, 10),
|
||||
reason="pydantic_extra_types.color not available on Python < 3.10",
|
||||
)
|
||||
def test_encode_pydantic_extra_types_color():
|
||||
et_color = pytest.importorskip("pydantic_extra_types.color")
|
||||
color = et_color.Color("red")
|
||||
|
|
|
|||
Loading…
Reference in New Issue