Skip to content

Commit 458cfe1

Browse files
authored
Run CI for Python 3.14 free-threading (#20029)
1 parent 5e2f65b commit 458cfe1

File tree

5 files changed

+32
-5
lines changed

5 files changed

+32
-5
lines changed

.github/workflows/test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ jobs:
5959
toxenv: py
6060
tox_extra_args: "-n 4"
6161
test_mypyc: true
62+
- name: Test suite with py314t-ubuntu, mypyc-compiled
63+
python: '3.14t'
64+
os: ubuntu-24.04-arm
65+
toxenv: py
66+
tox_extra_args: "-n 4"
67+
test_mypyc: true
6268
- name: Test suite with py314-windows-64
6369
python: '3.14'
6470
os: windows-latest

mypy/report.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import os
99
import shutil
1010
import sys
11+
import sysconfig
1112
import time
1213
import tokenize
1314
from abc import ABCMeta, abstractmethod
@@ -25,9 +26,13 @@
2526
from mypy.version import __version__
2627

2728
try:
28-
from lxml import etree # type: ignore[import-untyped]
29+
if sys.version_info >= (3, 14) and bool(sysconfig.get_config_var("Py_GIL_DISABLED")):
30+
# lxml doesn't support free-threading yet
31+
LXML_INSTALLED = False
32+
else:
33+
from lxml import etree # type: ignore[import-untyped]
2934

30-
LXML_INSTALLED = True
35+
LXML_INSTALLED = True
3136
except ImportError:
3237
LXML_INSTALLED = False
3338

mypy/test/testcheck.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import os
66
import re
77
import sys
8+
import sysconfig
89
import tempfile
910
from pathlib import Path
1011

@@ -27,7 +28,11 @@
2728
from mypy.test.update_data import update_testcase_output
2829

2930
try:
30-
import lxml # type: ignore[import-untyped]
31+
if sys.version_info >= (3, 14) and bool(sysconfig.get_config_var("Py_GIL_DISABLED")):
32+
# lxml doesn't support free-threading yet
33+
lxml = None
34+
else:
35+
import lxml # type: ignore[import-untyped]
3136
except ImportError:
3237
lxml = None
3338

mypy/test/testcmdline.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import re
1111
import subprocess
1212
import sys
13+
import sysconfig
1314

1415
from mypy.test.config import PREFIX, test_temp_dir
1516
from mypy.test.data import DataDrivenTestCase, DataSuite
@@ -20,7 +21,11 @@
2021
)
2122

2223
try:
23-
import lxml # type: ignore[import-untyped]
24+
if sys.version_info >= (3, 14) and bool(sysconfig.get_config_var("Py_GIL_DISABLED")):
25+
# lxml doesn't support free-threading yet
26+
lxml = None
27+
else:
28+
import lxml # type: ignore[import-untyped]
2429
except ImportError:
2530
lxml = None
2631

mypy/test/testreports.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,19 @@
22

33
from __future__ import annotations
44

5+
import sys
6+
import sysconfig
57
import textwrap
68

79
from mypy.report import CoberturaPackage, get_line_rate
810
from mypy.test.helpers import Suite, assert_equal
911

1012
try:
11-
import lxml # type: ignore[import-untyped]
13+
if sys.version_info >= (3, 14) and bool(sysconfig.get_config_var("Py_GIL_DISABLED")):
14+
# lxml doesn't support free-threading yet
15+
lxml = None
16+
else:
17+
import lxml # type: ignore[import-untyped]
1218
except ImportError:
1319
lxml = None
1420

0 commit comments

Comments
 (0)