Skip to content

Commit 258ce95

Browse files
Add support for Python 3.14 (#3828)
* Run tests on 3.14 * Fix deps * Bump graphql core 3.2 * Fix doc param * Apply suggestion from @greptile-apps[bot] Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> * Fix doc param * Keep 3.9 * Use annotationlib in 3.14 * Fix date error assert * Use get_annotations from typing_extensions * Fix union * Mypy * Type ignore and pydantic version * Fix brokenness * :) * Does it click * Pydantic is all you need * SUPERSANIC * Less dev * Keep dev for now * 🔦🔦🔦🔦🔦🔦🔦🔦🔦🔦🔦 --------- Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
1 parent add26a6 commit 258ce95

File tree

17 files changed

+1173
-880
lines changed

17 files changed

+1173
-880
lines changed

.github/workflows/codeflash.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ jobs:
3838
- name: Run Codeflash to optimize code
3939
run: |
4040
poetry env use python
41-
poetry run codeflash --benchmark
41+
poetry run codeflash --benchmark --benchmarks-root tests/benchmarks

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ jobs:
6262
3.11
6363
3.12
6464
3.13
65+
3.14-dev
6566
6667
- run: pip install poetry nox nox-poetry uv
6768
- run: nox -r -t tests -s "${{ matrix.session.session }}"

RELEASE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Release type: patch
2+
3+
This release adds support for the upcoming Python 3.14

TWEET.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
🆕 Release $version is out! Thanks to $contributor for the PR 👏
2+
3+
This release adds support for Python 3.14!
4+
5+
Get it here 👉 $release_url

noxfile.py

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
nox.options.error_on_external_run = True
99
nox.options.default_venv_backend = "uv"
1010

11-
PYTHON_VERSIONS = ["3.13", "3.12", "3.11", "3.10", "3.9"]
11+
PYTHON_VERSIONS = ["3.14", "3.13", "3.12", "3.11", "3.10", "3.9"]
1212

1313
GQL_CORE_VERSIONS = [
14-
"3.2.3",
14+
"3.2.6",
1515
"3.3.0a9",
1616
]
1717

@@ -129,12 +129,35 @@ def tests_integrations(session: Session, integration: str, gql_core: str) -> Non
129129
session.run("pytest", *COMMON_PYTEST_OPTIONS, "-m", integration)
130130

131131

132+
@session(
133+
python=["3.9", "3.10", "3.11", "3.12", "3.13"],
134+
name="Pydantic V1 tests",
135+
tags=["tests", "pydantic"],
136+
)
137+
@gql_core_parametrize
138+
def test_pydantic(session: Session, gql_core: str) -> None:
139+
session.run_always("poetry", "install", "--without=integrations", external=True)
140+
141+
session._session.install("pydantic~=1.10") # type: ignore
142+
_install_gql_core(session, gql_core)
143+
session.run(
144+
"pytest",
145+
"--cov=.",
146+
"--cov-append",
147+
"--cov-report=xml",
148+
"-m",
149+
"pydantic",
150+
"--ignore=tests/cli",
151+
"--ignore=tests/benchmarks",
152+
)
153+
154+
132155
@session(python=PYTHON_VERSIONS, name="Pydantic tests", tags=["tests", "pydantic"])
133-
@with_gql_core_parametrize("pydantic", ["1.10", "2.9.0", "2.10.0", "2.11.0"])
134-
def test_pydantic(session: Session, pydantic: str, gql_core: str) -> None:
156+
@gql_core_parametrize
157+
def test_pydantic_v2(session: Session, gql_core: str) -> None:
135158
session.run_always("poetry", "install", "--without=integrations", external=True)
136159

137-
session._session.install(f"pydantic~={pydantic}") # type: ignore
160+
session._session.install("pydantic~=2.12") # type: ignore
138161
_install_gql_core(session, gql_core)
139162
session.run(
140163
"pytest",
@@ -166,7 +189,8 @@ def tests_typecheckers(session: Session) -> None:
166189
)
167190

168191

169-
@session(python=PYTHON_VERSIONS, name="CLI tests", tags=["tests"])
192+
# skipping python 3.9 because of some changes in click 8.2.0
193+
@session(python=PYTHON_VERSIONS[:-1], name="CLI tests", tags=["tests"])
170194
def tests_cli(session: Session) -> None:
171195
session.run_always("poetry", "install", "--without=integrations", external=True)
172196

poetry.lock

Lines changed: 1096 additions & 854 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ dev = [
117117
"mypy (>=1.15.0,<2.0.0)",
118118
"pyright (==1.1.401)",
119119
"codeflash (>=0.9.2)",
120-
"pre-commit (>=4.3.0,<5.0.0)",
120+
"pre-commit",
121121
]
122122
integrations = [
123123
"aiohttp (>=3.7.4.post0,<4.0.0)",

strawberry/schema/_graphql_core.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77
from strawberry.types import ExecutionResult
88

99
try:
10-
from graphql import (
11-
ExperimentalIncrementalExecutionResults as GraphQLIncrementalExecutionResults, # type: ignore[attr-defined]
10+
from graphql import ( # type: ignore[attr-defined]
11+
ExperimentalIncrementalExecutionResults as GraphQLIncrementalExecutionResults,
1212
)
13-
from graphql.execution import (
14-
InitialIncrementalExecutionResult, # type: ignore[attr-defined]
15-
experimental_execute_incrementally, # type: ignore[attr-defined]
13+
from graphql.execution import ( # type: ignore[attr-defined]
14+
InitialIncrementalExecutionResult,
15+
experimental_execute_incrementally,
1616
)
17-
from graphql.type.directives import (
18-
GraphQLDeferDirective, # type: ignore[attr-defined]
19-
GraphQLStreamDirective, # type: ignore[attr-defined]
17+
from graphql.type.directives import ( # type: ignore[attr-defined]
18+
GraphQLDeferDirective,
19+
GraphQLStreamDirective,
2020
)
2121

2222
incremental_execution_directives = (

strawberry/types/field.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ def __init__(
9898
if sys.version_info >= (3, 10):
9999
kwargs["kw_only"] = dataclasses.MISSING
100100

101+
# doc was added to python 3.14 and it is required
102+
if sys.version_info >= (3, 14):
103+
kwargs["doc"] = None
104+
101105
super().__init__(
102106
default=default,
103107
default_factory=default_factory, # type: ignore

strawberry/types/object_type.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
Union,
1313
overload,
1414
)
15-
from typing_extensions import dataclass_transform
15+
from typing_extensions import dataclass_transform, get_annotations
1616

1717
from strawberry.exceptions import (
1818
InvalidSuperclassInterfaceError,
@@ -51,7 +51,8 @@ def _check_field_annotations(cls: builtins.type[Any]) -> None:
5151
5252
https://github.com/python/cpython/blob/6fed3c85402c5ca704eb3f3189ca3f5c67a08d19/Lib/dataclasses.py#L881-L884
5353
"""
54-
cls_annotations = cls.__dict__.get("__annotations__", {})
54+
cls_annotations = get_annotations(cls)
55+
# TODO: do we need this?
5556
cls.__annotations__ = cls_annotations
5657

5758
for field_name, field_ in cls.__dict__.items():

0 commit comments

Comments
 (0)