]> git.ipfire.org Git - thirdparty/fastapi/sqlmodel.git/commitdiff
⬆️ Add support for Python 3.14 (#1578)
authorSofie Van Landeghem <svlandeg@users.noreply.github.com>
Wed, 8 Oct 2025 16:26:33 +0000 (18:26 +0200)
committerGitHub <noreply@github.com>
Wed, 8 Oct 2025 16:26:33 +0000 (18:26 +0200)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
.github/workflows/test.yml
pyproject.toml
sqlmodel/_compat.py

index c4fdb911a8a9c9f49582871cd8809a12f65c25d5..fb01245f45b64828d33f8b7081abb4ebc34361e7 100644 (file)
@@ -26,9 +26,8 @@ jobs:
     strategy:
       matrix:
         os: [ ubuntu-latest, windows-latest, macos-latest ]
-        python-version: [ "3.13" ]
+        python-version: [ "3.14" ]
         pydantic-version:
-          - pydantic-v1
           - pydantic-v2
         include:
           - os: macos-latest
@@ -47,7 +46,10 @@ jobs:
             python-version: "3.12"
             pydantic-version: pydantic-v1
           - os: ubuntu-latest
-            python-version: "3.12"
+            python-version: "3.13"
+            pydantic-version: pydantic-v1
+          - os: macos-latest
+            python-version: "3.13"
             pydantic-version: pydantic-v2
       fail-fast: false
     runs-on: ${{ matrix.os }}
index 902fffdc9f5fa160cd2979b8cff21d40ae30d66c..cd47f5ecd983c1551a7a5e6c288cfac3b1f9b7a7 100644 (file)
@@ -26,6 +26,7 @@ classifiers = [
     "Programming Language :: Python :: 3.11",
     "Programming Language :: Python :: 3.12",
     "Programming Language :: Python :: 3.13",
+    "Programming Language :: Python :: 3.14",
     "Topic :: Database",
     "Topic :: Database :: Database Engines/Servers",
     "Topic :: Internet",
index dc806d381b713c5375db0ba17fb41fb947ff98b1..230f8cc36218d0b3af1bde52f9dcf7596b54d180 100644 (file)
@@ -1,3 +1,4 @@
+import sys
 import types
 from contextlib import contextmanager
 from contextvars import ContextVar
@@ -123,7 +124,20 @@ if IS_PYDANTIC_V2:
         object.__setattr__(new_object, "__pydantic_private__", None)
 
     def get_annotations(class_dict: Dict[str, Any]) -> Dict[str, Any]:
-        return class_dict.get("__annotations__", {})  # type: ignore[no-any-return]
+        raw_annotations: Dict[str, Any] = class_dict.get("__annotations__", {})
+        if sys.version_info >= (3, 14) and "__annotations__" not in class_dict:
+            # See https://github.com/pydantic/pydantic/pull/11991
+            from annotationlib import (
+                Format,
+                call_annotate_function,
+                get_annotate_from_class_namespace,
+            )
+
+            if annotate := get_annotate_from_class_namespace(class_dict):
+                raw_annotations = call_annotate_function(
+                    annotate, format=Format.FORWARDREF
+                )
+        return raw_annotations
 
     def is_table_model_class(cls: Type[Any]) -> bool:
         config = getattr(cls, "model_config", {})