From 30c0e3f25656d65ffb82d8313e99f601efb4a74d Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 15 May 2022 18:55:35 -0400 Subject: refactor: clean up tomllib addition --- coverage/tomlconfig.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'coverage') 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") -- cgit v1.2.1