[BugFix] Revamp the usage of list syntax on routines (#6450)

* using list syntax on routines

* black

* ruff

* simplify

* black
This commit is contained in:
Henrique Joaquim
2024-05-22 12:46:19 +01:00
committed by GitHub
parent 8baf4d74b2
commit f91791dbf9
7 changed files with 30 additions and 21 deletions

View File

@@ -799,11 +799,22 @@ class BaseController(metaclass=ABCMeta):
return None
try:
# If the user uses a comma separated list of arguments, split them
for index, arg in enumerate(other_args):
if "," in arg:
parts = arg.split(",")
other_args[index : index + 1] = parts
# Determine the index of the routine arguments
routine_args_index = next(
(
i + 1
for i, arg in enumerate(other_args)
if arg in ("-i", "--input")
and "routine_args" in [action.dest for action in parser._actions]
),
-1,
)
# Split comma-separated arguments, except for the argument at routine_args_index
other_args = [
part
for index, arg in enumerate(other_args)
for part in (arg.split(",") if index != routine_args_index else [arg])
]
(ns_parser, l_unknown_args) = parser.parse_known_args(other_args)