From 6744c85b1c6af906ecc66207e6af3927e5fe9370 Mon Sep 17 00:00:00 2001 From: magdaaniol Date: Wed, 3 Sep 2025 17:14:08 +0200 Subject: [PATCH 1/3] handle types as strings --- radicli/tests/test_util.py | 12 +++++++++++- radicli/util.py | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/radicli/tests/test_util.py b/radicli/tests/test_util.py index fb2d61c..580050c 100644 --- a/radicli/tests/test_util.py +++ b/radicli/tests/test_util.py @@ -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]) @@ -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 \ No newline at end of file diff --git a/radicli/util.py b/radicli/util.py index 1e95da2..1e26e87 100644 --- a/radicli/util.py +++ b/radicli/util.py @@ -296,6 +296,8 @@ 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) and param_type in BASE_TYPES_MAP: + param_type = BASE_TYPES_MAP[param_type] arg = ArgparseArg( id=param, arg=orig_arg, From 1423b8998643059058308845ad1ac7c5b4eadc8f Mon Sep 17 00:00:00 2001 From: magdaaniol Date: Fri, 5 Sep 2025 15:55:30 +0200 Subject: [PATCH 2/3] fix type error --- radicli/util.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/radicli/util.py b/radicli/util.py index 9739f58..5b4d9a4 100644 --- a/radicli/util.py +++ b/radicli/util.py @@ -298,6 +298,9 @@ def get_arg( """Generate an argument to add to argparse and interpret types if possible.""" if isinstance(param_type, str) and param_type in BASE_TYPES_MAP: param_type = BASE_TYPES_MAP[param_type] + # Ensure param_type is not a string before passing to ArgparseArg + if isinstance(param_type, str): + param_type = None arg = ArgparseArg( id=param, arg=orig_arg, From 61b9aaad0aa4c46cea73c061e48599249c8552b6 Mon Sep 17 00:00:00 2001 From: magdaaniol Date: Fri, 5 Sep 2025 16:03:29 +0200 Subject: [PATCH 3/3] refactor --- radicli/util.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/radicli/util.py b/radicli/util.py index 5b4d9a4..500338a 100644 --- a/radicli/util.py +++ b/radicli/util.py @@ -296,11 +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) and param_type in BASE_TYPES_MAP: - param_type = BASE_TYPES_MAP[param_type] - # Ensure param_type is not a string before passing to ArgparseArg if isinstance(param_type, str): - param_type = None + # Windows may pass param_types as str + param_type = BASE_TYPES_MAP.get(param_type, None) arg = ArgparseArg( id=param, arg=orig_arg,