Skip to content

Commit

Permalink
Resolve path to lists of pathlib objects (#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hans Kallekleiv authored Nov 19, 2019
1 parent d5069e8 commit d1f34fd
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions webviz_config/_config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pathlib
import inspect
import importlib
import typing

import yaml

Expand Down Expand Up @@ -109,17 +110,25 @@ def _call_signature(

if expected_type == pathlib.Path:
kwargs[arg] = (config_folder / pathlib.Path(kwargs[arg])).resolve()

if not isinstance(kwargs[arg], expected_type):
raise ParserError(
f"{terminal_colors.RED}{terminal_colors.BOLD}"
f"The value provided for argument `{arg}` "
f"given to container `{container_name}` is "
f"of type `{type(kwargs[arg]).__name__}`. "
f"Expected type "
f"`{argspec.annotations[arg].__name__}`."
f"{terminal_colors.END}"
)
elif expected_type == typing.List[pathlib.Path]:
kwargs[arg] = [
(config_folder / pathlib.Path(patharg)).resolve()
for patharg in kwargs[arg]
]
try:
if not isinstance(kwargs[arg], expected_type):
raise ParserError(
f"{terminal_colors.RED}{terminal_colors.BOLD}"
f"The value provided for argument `{arg}` "
f"given to container `{container_name}` is "
f"of type `{type(kwargs[arg]).__name__}`. "
f"Expected type "
f"`{argspec.annotations[arg].__name__}`."
f"{terminal_colors.END}"
)
# Typechecking typing classes does not work in python 3.7
except TypeError:
pass

special_args = ""
if "app" in argspec.args:
Expand Down

0 comments on commit d1f34fd

Please sign in to comment.