summaryrefslogtreecommitdiff
path: root/coverage/tomlconfig.py
diff options
context:
space:
mode:
authorThomas Grainger <tagrain@gmail.com>2021-07-13 11:23:09 +0100
committerGitHub <noreply@github.com>2021-07-13 03:23:09 -0700
commit80bfea74c10dec30a0fa64e1379b80c897b060a9 (patch)
treec2ee11fb7e506c147c20f48619f3c4cb197ef11f /coverage/tomlconfig.py
parent8cb321599e1c738c1e2af8f009a40e35423bcd9f (diff)
downloadpython-coveragepy-git-80bfea74c10dec30a0fa64e1379b80c897b060a9.tar.gz
Support TOML v1.0.0 syntax in `pyproject.toml` (#1186)
* Support TOML v1.0.0 syntax in `pyproject.toml` fixes #1180 Co-authored-by: Taneli Hukkinen <3275109+hukkin@users.noreply.github.com> * fix toml meta test * use pytest.mark.parametrize to narrow test failure * Update tests/test_config.py Co-authored-by: Taneli Hukkinen <3275109+hukkin@users.noreply.github.com> Co-authored-by: Taneli Hukkinen <3275109+hukkin@users.noreply.github.com>
Diffstat (limited to 'coverage/tomlconfig.py')
-rw-r--r--coverage/tomlconfig.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/coverage/tomlconfig.py b/coverage/tomlconfig.py
index 1e0b1241..aa11a8a9 100644
--- a/coverage/tomlconfig.py
+++ b/coverage/tomlconfig.py
@@ -12,9 +12,9 @@ from coverage.misc import substitute_variables
# TOML support is an install-time extra option.
try:
- import toml
+ import tomli
except ImportError: # pragma: not covered
- toml = None
+ tomli = None
class TomlDecodeError(Exception):
@@ -44,12 +44,12 @@ class TomlConfigParser:
toml_text = fp.read()
except OSError:
return []
- if toml:
+ if tomli is not None:
toml_text = substitute_variables(toml_text, os.environ)
try:
- self.data = toml.loads(toml_text)
- except toml.TomlDecodeError as err:
- raise TomlDecodeError(*err.args)
+ self.data = tomli.loads(toml_text)
+ except tomli.TOMLDecodeError as err:
+ raise TomlDecodeError(str(err))
return [filename]
else:
has_toml = re.search(r"^\[tool\.coverage\.", toml_text, flags=re.MULTILINE)