diff --git a/python_modules/dagster/dagster/_config/pythonic_config/pydantic_compat_layer.py b/python_modules/dagster/dagster/_config/pythonic_config/pydantic_compat_layer.py index 7d9c584256ff3..27c65d357b59e 100644 --- a/python_modules/dagster/dagster/_config/pythonic_config/pydantic_compat_layer.py +++ b/python_modules/dagster/dagster/_config/pythonic_config/pydantic_compat_layer.py @@ -14,19 +14,18 @@ IAttachDifferentObjectToOpContext as IAttachDifferentObjectToOpContext, ) +USING_PYDANTIC_2 = int(pydantic.__version__.split(".")[0]) >= 2 + PydanticUndefined = None -try: +if USING_PYDANTIC_2: from pydantic_core import PydanticUndefined as _PydanticUndefined # type: ignore PydanticUndefined = _PydanticUndefined -except: - pass + if TYPE_CHECKING: from pydantic.fields import ModelField -USING_PYDANTIC_2 = int(pydantic.__version__.split(".")[0]) >= 2 - class ModelFieldCompat: """Wraps a Pydantic model field to provide a consistent interface for accessing