Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ jobs:
toxenv: py
tox_extra_args: "-n 4"
test_mypyc: true
- name: Test suite with py314t-ubuntu, mypyc-compiled
python: '3.14t'
os: ubuntu-24.04-arm
toxenv: py
tox_extra_args: "-n 4"
test_mypyc: true
- name: Test suite with py314-windows-64
python: '3.14'
os: windows-latest
Expand Down
8 changes: 6 additions & 2 deletions mypy/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@
from mypy.version import __version__

try:
from lxml import etree # type: ignore[import-untyped]
if sys.version_info >= (3, 14) and not sys._is_gil_enabled():

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The GIL can be re-enabled on the free-threaded build by importing an extension that doesn't declare support for running without the GIL.

What matters here is the ABI, not whether the GIL is enabled at runtime.

Instead of sys._is_gil_enabled(), I'd use not bool(sysconfig.get_config_var("Py_GIL_DISABLED)). Future Python versions will have sys.abi_flags to get information like this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻 Pushed a new commit.

Ideally I'd prefer to just not install lxml at all for free-threading builds but that's not supported yet. There was some progress on the packaging PEP but it might have stalled out again unfortunately.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm working with @zklaus on the packaging PEP! It's hard to make packaging changes but he's working on it still.

# lxml doesn't support free-threading yet
LXML_INSTALLED = False
else:
from lxml import etree # type: ignore[import-untyped]

LXML_INSTALLED = True
LXML_INSTALLED = True
except ImportError:
LXML_INSTALLED = False

Expand Down
6 changes: 5 additions & 1 deletion mypy/test/testcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@
from mypy.test.update_data import update_testcase_output

try:
import lxml # type: ignore[import-untyped]
if sys.version_info >= (3, 14) and not sys._is_gil_enabled():
# lxml doesn't support free-threading yet
lxml = None
else:
import lxml # type: ignore[import-untyped]
except ImportError:
lxml = None

Expand Down
6 changes: 5 additions & 1 deletion mypy/test/testcmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
)

try:
import lxml # type: ignore[import-untyped]
if sys.version_info >= (3, 14) and not sys._is_gil_enabled():
# lxml doesn't support free-threading yet
lxml = None
else:
import lxml # type: ignore[import-untyped]
except ImportError:
lxml = None

Expand Down
7 changes: 6 additions & 1 deletion mypy/test/testreports.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@

from __future__ import annotations

import sys
import textwrap

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

try:
import lxml # type: ignore[import-untyped]
if sys.version_info >= (3, 14) and not sys._is_gil_enabled():
# lxml doesn't support free-threading yet
lxml = None
else:
import lxml # type: ignore[import-untyped]
except ImportError:
lxml = None

Expand Down