diff options
| author | Eugene Triguba <eugenetriguba@gmail.com> | 2020-06-20 16:32:23 -0500 |
|---|---|---|
| committer | Eugene Triguba <eugenetriguba@gmail.com> | 2020-06-20 16:32:23 -0500 |
| commit | ee78049f1e33bcb9894f43d51e44b079edfab91f (patch) | |
| tree | 816ae8115bae491c20b087429222d4d57203cc74 /config_file/parsers/base_parser.py | |
| parent | Remove linting phase (diff) | |
| download | config-file-ee78049f1e33bcb9894f43d51e44b079edfab91f.zip | |
Add types to base parser and update build badge
Diffstat (limited to 'config_file/parsers/base_parser.py')
| -rw-r--r-- | config_file/parsers/base_parser.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/config_file/parsers/base_parser.py b/config_file/parsers/base_parser.py index bbdfd91..a1d38d4 100644 --- a/config_file/parsers/base_parser.py +++ b/config_file/parsers/base_parser.py @@ -1,4 +1,5 @@ from abc import ABC, abstractmethod +from typing import Any class BaseParser(ABC): @@ -25,7 +26,7 @@ class BaseParser(ABC): self.parsed_content = self.parse(self.content) @abstractmethod - def get(self, key, parse_types=False): + def get(self, key: str, parse_types: bool = False, all: bool = False): """ Retrieve the value of a key in its native type. This means the string 'true' will be parsed back as the @@ -37,12 +38,12 @@ class BaseParser(ABC): raise NotImplementedError @abstractmethod - def set(self, key, value) -> bool: + def set(self, key: str, value: Any) -> bool: """Sets the value of a key.""" raise NotImplementedError @abstractmethod - def delete(self, section_key) -> bool: + def delete(self, section_key: str) -> bool: """Deletes a key/value pair or entire sections.""" raise NotImplementedError @@ -66,10 +67,9 @@ class BaseParser(ABC): raise NotImplementedError @abstractmethod - def parse(self, file_contents: str): + def parse(self, file_contents: str) -> Any: """ Parse the file_contents into an internal representation - the given parser can work with. It should not return anything - if you're going to be using the super() constructor. + the given parser can work with. """ raise NotImplementedError |