Skip to content

Commit ed8045c

Browse files
authored
Test on Python 3.14 (#12978)
1 parent 6c52c92 commit ed8045c

File tree

7 files changed

+27
-4
lines changed

7 files changed

+27
-4
lines changed

.github/workflows/main.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ jobs:
7070
PYTHONWARNINGS: "error" # treat all warnings as errors
7171

7272
deadsnakes:
73-
if: false
7473
runs-on: ubuntu-latest
7574
name: Python ${{ matrix.python }} (Docutils ${{ matrix.docutils }})
7675
strategy:
@@ -95,6 +94,7 @@ jobs:
9594
- name: Install dependencies
9695
run: |
9796
python -m pip install --upgrade pip
97+
sed -i 's/flit_core>=3.7/flit_core @ git+https:\/\/github.com\/pypa\/flit.git#subdirectory=flit_core/' pyproject.toml
9898
python -m pip install .[test]
9999
- name: Install Docutils ${{ matrix.docutils }}
100100
run: python -m pip install --upgrade "docutils~=${{ matrix.docutils }}.0"
@@ -104,7 +104,6 @@ jobs:
104104
PYTHONWARNINGS: "error" # treat all warnings as errors
105105

106106
deadsnakes-free-threraded:
107-
if: false
108107
runs-on: ubuntu-latest
109108
name: Python ${{ matrix.python }} (Docutils ${{ matrix.docutils }}; free-threaded)
110109
strategy:
@@ -130,6 +129,7 @@ jobs:
130129
- name: Install dependencies
131130
run: |
132131
python -m pip install --upgrade pip
132+
sed -i 's/flit_core>=3.7/flit_core @ git+https:\/\/github.com\/pypa\/flit.git#subdirectory=flit_core/' pyproject.toml
133133
python -m pip install .[test]
134134
- name: Install Docutils ${{ matrix.docutils }}
135135
run: python -m pip install --upgrade "docutils~=${{ matrix.docutils }}.0"

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ classifiers = [
3434
"Programming Language :: Python :: 3.11",
3535
"Programming Language :: Python :: 3.12",
3636
"Programming Language :: Python :: 3.13",
37+
"Programming Language :: Python :: 3.14",
3738
"Programming Language :: Python :: Implementation :: CPython",
3839
"Programming Language :: Python :: Implementation :: PyPy",
3940
"Framework :: Sphinx",

sphinx/util/inspect.py

+4
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,10 @@ def _evaluate_forwardref(
727727
localns: dict[str, Any] | None,
728728
) -> Any:
729729
"""Evaluate a forward reference."""
730+
if sys.version_info[:2] >= (3, 14):
731+
# https://docs.python.org/dev/library/annotationlib.html#annotationlib.ForwardRef.evaluate
732+
# https://docs.python.org/dev/library/typing.html#typing.evaluate_forward_ref
733+
return typing.evaluate_forward_ref(ref, globals=globalns, locals=localns)
730734
if sys.version_info >= (3, 12, 4):
731735
# ``type_params`` were added in 3.13 and the signature of _evaluate()
732736
# is not backward-compatible (it was backported to 3.12.4, so anything

sphinx/util/typing.py

+3
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,9 @@ def stringify_annotation(
425425
annotation_module: str = getattr(annotation, '__module__', '')
426426
annotation_name: str = getattr(annotation, '__name__', '')
427427
annotation_module_is_typing = annotation_module == 'typing'
428+
if sys.version_info[:2] >= (3, 14) and isinstance(annotation, ForwardRef):
429+
# ForwardRef moved from `typing` to `annotationlib` in Python 3.14.
430+
annotation_module_is_typing = True
428431

429432
# Extract the annotation's base type by considering formattable cases
430433
if isinstance(annotation, TypeVar) and not _is_unpack_form(annotation):

tests/test_extensions/test_ext_autodoc.py

+8
Original file line numberDiff line numberDiff line change
@@ -1588,6 +1588,14 @@ def _preamble_args(functional_constructor: bool = False):
15881588
* Look an enum member (valid only if the enum has members)
15891589
* Create a new enum class (functional API)
15901590
"""
1591+
if sys.version_info[:2] >= (3, 14):
1592+
if functional_constructor:
1593+
return (
1594+
'(new_class_name, /, names, *, module=None, '
1595+
'qualname=None, type=None, start=1, boundary=None)'
1596+
)
1597+
else:
1598+
return '(*values)'
15911599
if sys.version_info[:2] >= (3, 13) or sys.version_info[:3] >= (3, 12, 3):
15921600
if functional_constructor:
15931601
return (

tests/test_extensions/test_ext_autodoc_configs.py

+7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010

1111
from tests.test_extensions.autodoc_util import do_autodoc
1212

13+
skip_py314_segfault = pytest.mark.skipif(
14+
sys.version_info[:2] >= (3, 14),
15+
reason='Segmentation fault: https://github.com/python/cpython/issues/125017',
16+
)
17+
1318
IS_PYPY = platform.python_implementation() == 'PyPy'
1419

1520

@@ -182,6 +187,7 @@ def test_autodoc_class_signature_separated_init(app):
182187
]
183188

184189

190+
@skip_py314_segfault
185191
@pytest.mark.sphinx('html', testroot='ext-autodoc')
186192
def test_autodoc_class_signature_separated_new(app):
187193
app.config.autodoc_class_signature = 'separated'
@@ -365,6 +371,7 @@ def test_autodoc_inherit_docstrings_for_inherited_members(app):
365371
]
366372

367373

374+
@skip_py314_segfault
368375
@pytest.mark.sphinx('html', testroot='ext-autodoc')
369376
def test_autodoc_docstring_signature(app):
370377
options = {'members': None, 'special-members': '__init__, __new__'}

tox.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tox]
22
minversion = 4.2.0
3-
envlist = py{311,312,313}
3+
envlist = py{311,312,313,314}
44

55
[testenv]
66
usedevelop = True
@@ -19,7 +19,7 @@ passenv =
1919
BUILDER
2020
READTHEDOCS
2121
description =
22-
py{311,312,313}: Run unit tests against {envname}.
22+
py{311,312,313,314}: Run unit tests against {envname}.
2323
extras =
2424
test
2525
setenv =

0 commit comments

Comments
 (0)