Skip to content
This repository has been archived by the owner on Oct 3, 2021. It is now read-only.

Commit

Permalink
Added CLI tests and linted
Browse files Browse the repository at this point in the history
  • Loading branch information
rednafi committed Feb 3, 2021
1 parent ef70030 commit 69e641e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions konfik/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ def _load_config(self):
return self._load_yaml(config_path)

else:
raise NotImplementedError(f"Config type '{self._config_ext}' is not supported.")
raise NotImplementedError(
f"Config type '{self._config_ext}' is not supported."
)

@staticmethod
def _load_env(config_path):
Expand All @@ -183,7 +185,9 @@ def _load_env(config_path):
try:
# Instead of using `load_dotenv()``, this is done to avoid recursively searching for dotenv file.
# There is no element of surprise. If the file is not found in the explicit path, this will raise an error!
dotenv_file = find_dotenv(filename=config_path, raise_error_if_not_found=True, usecwd=True)
dotenv_file = find_dotenv(
filename=config_path, raise_error_if_not_found=True, usecwd=True
)

if dotenv_file:
config = dotenv_values(dotenv_file)
Expand Down Expand Up @@ -229,15 +233,19 @@ def get_by_path(dct, key_list):
try:
return reduce(operator.getitem, key_list, dct)
except KeyError as e:
raise MissingVariableError(f"No such variable '{e.args[0]}' exists.") from None
raise MissingVariableError(
f"No such variable '{e.args[0]}' exists."
) from None


class KonfikCLI:
"""Access and show config variables using the CLI."""

def build_parser(self):
parser = argparse.ArgumentParser(
description=colorize.colorize_title("\nKonfik -- The strangely familiar config parser ⚙️\n")
description=colorize.colorize_title(
"\nKonfik -- The strangely familiar config parser ⚙️\n"
)
)

# Add arguments.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_konfik.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
Konfik,
MissingConfigError,
MissingVariableError,
cli_entrypoint,
__version__,
cli_entrypoint,
)


Expand Down

0 comments on commit 69e641e

Please sign in to comment.