mirror of https://github.com/tiangolo/fastapi.git
coditional import of Color to avoid deprecation warning
This commit is contained in:
parent
12f3db56e5
commit
bbf15294eb
|
|
@ -19,6 +19,7 @@ from .shared import (
|
|||
from .shared import lenient_issubclass as lenient_issubclass
|
||||
from .shared import sequence_types as sequence_types
|
||||
from .shared import value_is_sequence as value_is_sequence
|
||||
from .v2 import Color as Color
|
||||
from .v2 import ModelField as ModelField
|
||||
from .v2 import PydanticSchemaGenerationError as PydanticSchemaGenerationError
|
||||
from .v2 import RequiredParam as RequiredParam
|
||||
|
|
|
|||
|
|
@ -39,6 +39,12 @@ from pydantic_core.core_schema import (
|
|||
RequiredParam = PydanticUndefined
|
||||
Undefined = PydanticUndefined
|
||||
|
||||
# pydantic.color.Color is deprecated since v2.0b3
|
||||
try:
|
||||
from pydantic_extra_types import Color
|
||||
except ImportError:
|
||||
from pydantic.color import Color # noqa: F401
|
||||
|
||||
|
||||
def define_forwardref() -> Callable[..., Any]:
|
||||
# eval_type_lenient has been deprecated since Pydantic v2.10.0b1 (PR #10530)
|
||||
|
|
|
|||
|
|
@ -22,12 +22,12 @@ from annotated_doc import Doc
|
|||
from fastapi.exceptions import PydanticV1NotSupportedError
|
||||
from fastapi.types import IncEx
|
||||
from pydantic import BaseModel
|
||||
from pydantic.color import Color
|
||||
from pydantic.networks import AnyUrl, NameEmail
|
||||
from pydantic.types import SecretBytes, SecretStr
|
||||
from pydantic_core import PydanticUndefinedType
|
||||
|
||||
from ._compat import (
|
||||
Color,
|
||||
Url,
|
||||
is_pydantic_v1_model_instance,
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue