summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES.rst5
-rw-r--r--coverage/tomlconfig.py9
2 files changed, 9 insertions, 5 deletions
diff --git a/CHANGES.rst b/CHANGES.rst
index 13d3846c..f7258a30 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -20,7 +20,10 @@ development at the same time, such as 4.5.x and 5.0.
Unreleased
----------
-Nothing yet.
+- On Python 3.11, the ``[toml]`` extra no longer installs tomli, instead using
+ tomllib from the standard library. Thanks `Shantanu <pull 1359_>`_.
+
+.. _pull 1359: https://github.com/nedbat/coveragepy/pull/1359
.. _changes_633:
diff --git a/coverage/tomlconfig.py b/coverage/tomlconfig.py
index 82f84ce9..b04d66e2 100644
--- a/coverage/tomlconfig.py
+++ b/coverage/tomlconfig.py
@@ -6,20 +6,21 @@
import configparser
import os
import re
-import sys
+from coverage import env
from coverage.exceptions import ConfigError
from coverage.misc import import_third_party, substitute_variables
-if sys.version_info >= (3, 11):
- import tomllib
+
+if env.PYVERSION >= (3, 11):
+ import tomllib # pylint: disable=import-error
else:
# TOML support on Python 3.10 and below is an install-time extra option.
# (Import typing is here because import_third_party will unload any module
# that wasn't already imported. tomli imports typing, and if we unload it,
# later it's imported again, and on Python 3.6, this causes infinite
# recursion.)
- import typing # pylint: disable=unused-import, wrong-import-order
+ import typing # pylint: disable=unused-import
tomllib = import_third_party("tomli")