From 69b872f638bdd44d9d4ff73ac732347e6bd00b60 Mon Sep 17 00:00:00 2001 From: inisis Date: Wed, 27 Nov 2024 05:36:06 +0800 Subject: [PATCH] fix argparse error --- onnxslim/argparser.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/onnxslim/argparser.py b/onnxslim/argparser.py index 95ee4fc..32ac43f 100644 --- a/onnxslim/argparser.py +++ b/onnxslim/argparser.py @@ -136,14 +136,13 @@ def _add_arguments(self): arg_type = _get_inner_type(field_def.type) default_value = field_def.default if field_def.default is not field_def.default_factory else None help_text = field_def.metadata.get("help", "") - nargs = "+" if arg_type == list else None + nargs = "+" if get_origin(arg_type) == list else None choices = field_def.metadata.get("choices", None) - if choices and default_value is not None and default_value not in choices: raise ValueError( f"Invalid default value '{default_value}' for argument '{field_name}'. Must be one of {choices}." ) - + arg_type = get_args(arg_type)[0] if get_args(arg_type) else arg_type if arg_type == bool: self.parser.add_argument( f"--{field_name.replace('_', '-')}",