From 51c7b60862e436a1c53a9ba4822898adfd907576 Mon Sep 17 00:00:00 2001 From: Viicos <65306057+Viicos@users.noreply.github.com> Date: Wed, 15 May 2024 19:29:19 +0200 Subject: [PATCH] Lazy import --- pydantic/config.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pydantic/config.py b/pydantic/config.py index 8d4445b2ac0..6755bd66200 100644 --- a/pydantic/config.py +++ b/pydantic/config.py @@ -5,7 +5,6 @@ from typing_extensions import Literal, TypeAlias, TypedDict -from ._internal._utils import is_model_class from ._migration import getattr_migration from .aliases import AliasGenerator from .errors import PydanticUserError @@ -1023,6 +1022,8 @@ def inner(class_: _TypeT, /) -> _TypeT: # Ideally, we would check for `class_` to either be a `TypedDict` or a stdlib dataclass. # However, the `@with_config` decorator can be applied *after* `@dataclass`. To avoid # common mistakes, we at least check for `class_` to not be a Pydantic model. + from ._internal._utils import is_model_class + if is_model_class(class_): raise PydanticUserError( f'Cannot use `with_config` on {class_.__name__} as it is a Pydantic model',