aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Triguba <eugenetriguba@gmail.com>2020-06-20 13:47:27 -0500
committerEugene Triguba <eugenetriguba@gmail.com>2020-06-20 13:47:27 -0500
commitd69d842faba3308a71fac31d19af55595d3e23dd (patch)
treefdc55acf86db9abea622db6997e1cc1ff084ba7d
parentRun travis CI on python 3.5 (diff)
downloadconfig-file-d69d842faba3308a71fac31d19af55595d3e23dd.zip
Remove taskipy from tox & add default to parser in __determine_parser
Taskipy uses f-strings which break on 3.5.
-rw-r--r--config_file/config_file.py20
-rw-r--r--tox.ini4
2 files changed, 17 insertions, 7 deletions
diff --git a/config_file/config_file.py b/config_file/config_file.py
index 805fc49..1cddd20 100644
--- a/config_file/config_file.py
+++ b/config_file/config_file.py
@@ -11,7 +11,9 @@ from config_file.exceptions import ParsingError
class ConfigFile:
- def __init__(self, file_path: Type[Union[str, PurePath]], parser: Type[BaseParser] = None) -> None:
+ def __init__(
+ self, file_path: Type[Union[str, PurePath]], parser: Type[BaseParser] = None
+ ) -> None:
"""
Saves the config file path and expands it if needed, reads in
the file contents, and determines what parser should be used for
@@ -28,7 +30,9 @@ class ConfigFile:
self.parser = self.__determine_parser(file_path, parser)
@staticmethod
- def __create_config_path(file_path: Type[Union[str, PurePath]], original: bool = False) -> str:
+ def __create_config_path(
+ file_path: Type[Union[str, PurePath]], original: bool = False
+ ) -> str:
if isinstance(file_path, PurePath):
file_path = str(file_path)
@@ -41,11 +45,15 @@ class ConfigFile:
file_path = ".".join(file_parts)
if Path(file_path).is_dir():
- raise ValueError("The specified config file ({}) is a directory.".format(file_path))
+ raise ValueError(
+ "The specified config file ({}) is a directory.".format(file_path)
+ )
return file_path
- def __determine_parser(self, file_path: Type[Union[str, PurePath]], parser: Type[BaseParser]) -> BaseParser:
+ def __determine_parser(
+ self, file_path: Type[Union[str, PurePath]], parser: Type[BaseParser] = None
+ ) -> BaseParser:
if isinstance(file_path, PurePath):
file_path = str(file_path)
@@ -59,7 +67,9 @@ class ConfigFile:
return JsonParser(self.contents)
else:
raise ValueError(
- "File path contains an unsupported or unrecognized file type: {}".format(file_path)
+ "File path contains an unsupported or unrecognized file type: {}".format(
+ file_path
+ )
)
def __read_config_file(self):
diff --git a/tox.ini b/tox.ini
index 1a1512f..6b849bc 100644
--- a/tox.ini
+++ b/tox.ini
@@ -9,6 +9,6 @@ deps = codecov>=1.4.0
whitelist_externals = poetry
commands =
poetry install -v --no-dev -E toml -E yaml
- pip install pytest pytest-cov requests taskipy
- poetry run task test
+ pip install pytest pytest-cov requests
+ poetry run pytest -v --cov=config_file/ --cov-report term-missing tests/
codecov -e TOXENV