summaryrefslogtreecommitdiff
path: root/coverage/backward.py
diff options
context:
space:
mode:
authorFrazer McLean <frazer@frazermclean.co.uk>2019-09-16 22:24:53 +0200
committerNed Batchelder <ned@nedbatchelder.com>2019-11-03 21:27:42 -0500
commitf97d0750a91e53bec387528344c1ca3bf86e1d08 (patch)
treeb240becda198190abdf545f02ce116ca3eae8808 /coverage/backward.py
parent1c06204a8b1db6cd5f53c553c42f3ef8229d6b20 (diff)
downloadpython-coveragepy-git-f97d0750a91e53bec387528344c1ca3bf86e1d08.tar.gz
TOML support for pyproject.toml and other config files
Squashed and rebased from https://github.com/nedbat/coveragepy/pull/699 Missing getfloat TOMLConfigParser -> TomlConfigParser fix getfloat for int Move TomlConfigParser Add name to contributors Import toml in backward.py fix indentation Don't ignore TomlDecodeError Raise if TomlConfigParser is used without toml installed Add tests for TOML config Fix test on Python 2 Mention toml support in documentation.
Diffstat (limited to 'coverage/backward.py')
-rw-r--r--coverage/backward.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/coverage/backward.py b/coverage/backward.py
index 58759545..e051fa55 100644
--- a/coverage/backward.py
+++ b/coverage/backward.py
@@ -6,6 +6,7 @@
# This file does tricky stuff, so disable a pylint warning.
# pylint: disable=unused-import
+import os
import sys
from coverage import env
@@ -26,6 +27,11 @@ try:
except ImportError:
import configparser
+try:
+ import toml
+except ImportError:
+ toml = None
+
# What's a string called?
try:
string_class = basestring
@@ -55,6 +61,15 @@ try:
except ImportError:
from threading import get_ident as get_thread_id
+try:
+ os.PathLike
+except AttributeError:
+ # This is Python 2 and 3
+ path_types = (bytes, string_class, unicode_class)
+else:
+ # 3.6+
+ path_types = (bytes, str, os.PathLike)
+
# shlex.quote is new, but there's an undocumented implementation in "pipes",
# who knew!?
try: