From d69d842faba3308a71fac31d19af55595d3e23dd Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Sat, 20 Jun 2020 13:47:27 -0500 Subject: Remove taskipy from tox & add default to parser in __determine_parser Taskipy uses f-strings which break on 3.5. --- config_file/config_file.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'config_file') 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): -- cgit v1.2.3