From 542a6851b8743171c31ad5a0f6928395d7db0f71 Mon Sep 17 00:00:00 2001 From: Jan-Lukas Wynen Date: Mon, 9 Oct 2023 15:21:05 +0200 Subject: [PATCH] Deprecate support for pydantic v1 --- docs/release-notes.rst | 2 ++ pyproject.toml | 1 + src/scitacean/_internal/pydantic_compat.py | 17 ++++++++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/docs/release-notes.rst b/docs/release-notes.rst index 3e30ddb2..d427f262 100644 --- a/docs/release-notes.rst +++ b/docs/release-notes.rst @@ -60,6 +60,8 @@ Documentation Deprecations ~~~~~~~~~~~~ +* Deprecated support for Pydantic v1. It is scheduled for full removal in release 23.12.0. + Stability, Maintainability, and Testing ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/pyproject.toml b/pyproject.toml index b787a7f3..4f40c871 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -64,6 +64,7 @@ filterwarnings = [ "ignore:Cannot check if local file:UserWarning", # Internal deprecations. "ignore:SSHFileTransfer is deprecated:scitacean.VisibleDeprecationWarning", + "ignore:Support for Pydantic v1 is deprecated:scitacean.VisibleDeprecationWarning", # From fabric / invoke "ignore:_SixMetaPathImporter:ImportWarning", "ignore:the imp module is deprecated in favour of importlib:DeprecationWarning", diff --git a/src/scitacean/_internal/pydantic_compat.py b/src/scitacean/_internal/pydantic_compat.py index e935b550..b040e431 100644 --- a/src/scitacean/_internal/pydantic_compat.py +++ b/src/scitacean/_internal/pydantic_compat.py @@ -6,7 +6,22 @@ def is_pydantic_v1() -> bool: - return pydantic.__version__.split(".", 1)[0] == "1" + if pydantic.__version__.split(".", 1)[0] == "1": + import warnings + + from ..warning import VisibleDeprecationWarning + + warnings.warn( + "Support for Pydantic v1 is deprecated in Scitacean" + "RELEASE_PLACEHOLDER and will be removed in Scitacean v23.12.0." + "If you cannot update your Pydantic version, please comment in this issue:" + " https://github.com/SciCatProject/scitacean/issues/158", + VisibleDeprecationWarning, + stacklevel=2, + ) + return True + + return False def field_validator(