Browse Source
🐛 Replace `MultHostUrl` to `AnyUrl` for compatibility with older versions of Pydantic v1 (#9852)
pull/9956/head
Marcelo Trylesinski
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
3 additions and
7 deletions
-
fastapi/_compat.py
-
fastapi/encoders.py
|
|
@ -56,7 +56,6 @@ if PYDANTIC_V2: |
|
|
|
from pydantic.json_schema import GenerateJsonSchema as GenerateJsonSchema |
|
|
|
from pydantic.json_schema import JsonSchemaValue as JsonSchemaValue |
|
|
|
from pydantic_core import CoreSchema as CoreSchema |
|
|
|
from pydantic_core import MultiHostUrl as MultiHostUrl |
|
|
|
from pydantic_core import PydanticUndefined, PydanticUndefinedType |
|
|
|
from pydantic_core import Url as Url |
|
|
|
from pydantic_core.core_schema import ( |
|
|
@ -294,9 +293,6 @@ else: |
|
|
|
from pydantic.fields import ( # type: ignore[no-redef, attr-defined] |
|
|
|
UndefinedType as UndefinedType, # noqa: F401 |
|
|
|
) |
|
|
|
from pydantic.networks import ( # type: ignore[no-redef] |
|
|
|
MultiHostDsn as MultiHostUrl, # noqa: F401 |
|
|
|
) |
|
|
|
from pydantic.schema import ( |
|
|
|
field_schema, |
|
|
|
get_flat_models_from_fields, |
|
|
|
|
|
@ -20,10 +20,10 @@ from uuid import UUID |
|
|
|
from fastapi.types import IncEx |
|
|
|
from pydantic import BaseModel |
|
|
|
from pydantic.color import Color |
|
|
|
from pydantic.networks import NameEmail |
|
|
|
from pydantic.networks import AnyUrl, NameEmail |
|
|
|
from pydantic.types import SecretBytes, SecretStr |
|
|
|
|
|
|
|
from ._compat import PYDANTIC_V2, MultiHostUrl, Url, _model_dump |
|
|
|
from ._compat import PYDANTIC_V2, Url, _model_dump |
|
|
|
|
|
|
|
|
|
|
|
# Taken from Pydantic v1 as is |
|
|
@ -80,7 +80,7 @@ ENCODERS_BY_TYPE: Dict[Type[Any], Callable[[Any], Any]] = { |
|
|
|
set: list, |
|
|
|
UUID: str, |
|
|
|
Url: str, |
|
|
|
MultiHostUrl: str, |
|
|
|
AnyUrl: str, |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|