Skip to content

Commit 45215fc

Browse files
⬆️ Add support for Python 3.14 (#1578)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 0cbf2e6 commit 45215fc

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

.github/workflows/test.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ jobs:
2626
strategy:
2727
matrix:
2828
os: [ ubuntu-latest, windows-latest, macos-latest ]
29-
python-version: [ "3.13" ]
29+
python-version: [ "3.14" ]
3030
pydantic-version:
31-
- pydantic-v1
3231
- pydantic-v2
3332
include:
3433
- os: macos-latest
@@ -47,7 +46,10 @@ jobs:
4746
python-version: "3.12"
4847
pydantic-version: pydantic-v1
4948
- os: ubuntu-latest
50-
python-version: "3.12"
49+
python-version: "3.13"
50+
pydantic-version: pydantic-v1
51+
- os: macos-latest
52+
python-version: "3.13"
5153
pydantic-version: pydantic-v2
5254
fail-fast: false
5355
runs-on: ${{ matrix.os }}

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ classifiers = [
2626
"Programming Language :: Python :: 3.11",
2727
"Programming Language :: Python :: 3.12",
2828
"Programming Language :: Python :: 3.13",
29+
"Programming Language :: Python :: 3.14",
2930
"Topic :: Database",
3031
"Topic :: Database :: Database Engines/Servers",
3132
"Topic :: Internet",

sqlmodel/_compat.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
import types
23
from contextlib import contextmanager
34
from contextvars import ContextVar
@@ -123,7 +124,20 @@ def init_pydantic_private_attrs(new_object: InstanceOrType["SQLModel"]) -> None:
123124
object.__setattr__(new_object, "__pydantic_private__", None)
124125

125126
def get_annotations(class_dict: Dict[str, Any]) -> Dict[str, Any]:
126-
return class_dict.get("__annotations__", {}) # type: ignore[no-any-return]
127+
raw_annotations: Dict[str, Any] = class_dict.get("__annotations__", {})
128+
if sys.version_info >= (3, 14) and "__annotations__" not in class_dict:
129+
# See https://github.com/pydantic/pydantic/pull/11991
130+
from annotationlib import (
131+
Format,
132+
call_annotate_function,
133+
get_annotate_from_class_namespace,
134+
)
135+
136+
if annotate := get_annotate_from_class_namespace(class_dict):
137+
raw_annotations = call_annotate_function(
138+
annotate, format=Format.FORWARDREF
139+
)
140+
return raw_annotations
127141

128142
def is_table_model_class(cls: Type[Any]) -> bool:
129143
config = getattr(cls, "model_config", {})

0 commit comments

Comments
 (0)