diff --git a/src/argilla_server/__init__.py b/src/argilla_server/__init__.py index b837b1c7..03d18e29 100644 --- a/src/argilla_server/__init__.py +++ b/src/argilla_server/__init__.py @@ -12,4 +12,11 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from argilla_server._app import app # noqa +import warnings + +from argilla_server.pydantic_v1 import PYDANTIC_MAJOR_VERSION + +if PYDANTIC_MAJOR_VERSION >= 2: + warnings.warn("The argilla_server package is not compatible with Pydantic 2. " "Please use Pydantic 1.x instead.") +else: + from argilla_server._app import app # noqa diff --git a/src/argilla_server/pydantic_v1/__init__.py b/src/argilla_server/pydantic_v1/__init__.py index 7229fc37..d295b7d3 100644 --- a/src/argilla_server/pydantic_v1/__init__.py +++ b/src/argilla_server/pydantic_v1/__init__.py @@ -11,8 +11,14 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +from importlib import metadata try: from pydantic.v1 import * # noqa: F403 except ImportError: from pydantic import * # noqa: F403 + +try: + PYDANTIC_MAJOR_VERSION: int = int(metadata.version("pydantic").split(".")[0]) +except metadata.PackageNotFoundError: + PYDANTIC_MAJOR_VERSION = 0