Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion radicli/tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from uuid import UUID
import pytest
import shutil
from radicli.util import stringify_type, get_list_converter
from radicli.util import stringify_type, get_list_converter, get_arg, Arg

_KindT = TypeVar("_KindT", bound=Union[str, int, float, Path])

Expand Down Expand Up @@ -61,3 +61,13 @@ def test_stringify_type(arg_type, expected):
def test_get_list_converter(item_type, value, expected):
converter = get_list_converter(item_type)
assert converter(value) == expected

def test_get_arg_string_type():
arg_info = Arg()
result = get_arg("test_param", arg_info, "str")
assert result.type is str

def test_get_arg_regular_type():
arg_info = Arg()
result = get_arg("test_param", arg_info, int)
assert result.type is int
3 changes: 3 additions & 0 deletions radicli/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,9 @@ def get_arg(
skip_resolve: bool = False,
) -> ArgparseArg:
"""Generate an argument to add to argparse and interpret types if possible."""
if isinstance(param_type, str):
# Windows may pass param_types as str
param_type = BASE_TYPES_MAP.get(param_type, None)
arg = ArgparseArg(
id=param,
arg=orig_arg,
Expand Down
Loading