summaryrefslogtreecommitdiff
path: root/coverage/tomlconfig.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2019-11-03 09:59:12 -0500
committerNed Batchelder <ned@nedbatchelder.com>2019-11-03 21:27:42 -0500
commita44e6e48abfdab8f5a7e457ae1e481005f7bdbe5 (patch)
tree56b56b992c9e5bc7f526322ddc0555a97431b226 /coverage/tomlconfig.py
parentf97d0750a91e53bec387528344c1ca3bf86e1d08 (diff)
downloadpython-coveragepy-git-a44e6e48abfdab8f5a7e457ae1e481005f7bdbe5.tar.gz
Cleanups for TOML code
Diffstat (limited to 'coverage/tomlconfig.py')
-rw-r--r--coverage/tomlconfig.py24
1 files changed, 20 insertions, 4 deletions
diff --git a/coverage/tomlconfig.py b/coverage/tomlconfig.py
index 0d084603..b6499ec4 100644
--- a/coverage/tomlconfig.py
+++ b/coverage/tomlconfig.py
@@ -1,3 +1,8 @@
+# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
+# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt
+
+"""TOML configuration support for coverage.py"""
+
import io
import os
import re
@@ -9,9 +14,16 @@ from coverage.misc import CoverageException, substitute_variables
class TomlDecodeError(Exception):
"""An exception class that exists even when toml isn't installed."""
+ pass
class TomlConfigParser:
+ """TOML file reading with the interface of HandyConfigParser."""
+
+ # This class has the same interface as config.HandyConfigParser, no
+ # need for docstrings.
+ # pylint: disable=missing-function-docstring
+
def __init__(self, our_file):
self.getters = [lambda obj: obj['tool']['coverage']]
if our_file:
@@ -101,7 +113,8 @@ class TomlConfigParser:
if not isinstance(value, bool):
raise ValueError(
'Option {!r} in section {!r} is not a boolean: {!r}'
- .format(option, section, value))
+ .format(option, section, value)
+ )
return value
def getlist(self, section, option):
@@ -109,7 +122,8 @@ class TomlConfigParser:
if not isinstance(values, list):
raise ValueError(
'Option {!r} in section {!r} is not a list: {!r}'
- .format(option, section, values))
+ .format(option, section, values)
+ )
for i, value in enumerate(values):
if isinstance(value, string_class):
values[i] = substitute_variables(value, os.environ)
@@ -132,7 +146,8 @@ class TomlConfigParser:
if not isinstance(value, int):
raise ValueError(
'Option {!r} in section {!r} is not an integer: {!r}'
- .format(option, section, value))
+ .format(option, section, value)
+ )
return value
def getfloat(self, section, option):
@@ -142,5 +157,6 @@ class TomlConfigParser:
if not isinstance(value, float):
raise ValueError(
'Option {!r} in section {!r} is not a float: {!r}'
- .format(option, section, value))
+ .format(option, section, value)
+ )
return value