Skip to content

fix: accept lists for custom actions with nargs - #357

Open
lo-0l wants to merge 1 commit into
bw2:masterfrom
lo-0l:354-custom-action-nargs-list
Open

fix: accept lists for custom actions with nargs#357
lo-0l wants to merge 1 commit into
bw2:masterfrom
lo-0l:354-custom-action-nargs-list

Conversation

@lo-0l

@lo-0l lo-0l commented Aug 19, 2026

Copy link
Copy Markdown

The list-value check in convert_item_to_command_line_arg required the action to be a _StoreAction or _AppendAction instance, so an argument declared with a custom argparse.Action subclass and nargs="+" was rejected when its value came from a config file, even though the same argument parsed fine from the command line.

The class check is not what the error message advertises, and it is redundant: actions that cannot consume several values (store_const, count, help, ...) already have nargs == 0 or None, so they still fall through to the error. Keep the nargs test only.

Fixes #354

The list-value check in convert_item_to_command_line_arg required the
action to be a _StoreAction or _AppendAction instance, so an argument
declared with a custom argparse.Action subclass and nargs="+" was
rejected when its value came from a config file, even though the same
argument parsed fine from the command line.

The class check is not what the error message advertises, and it is
redundant: actions that cannot consume several values (store_const,
count, help, ...) already have nargs == 0 or None, so they still fall
through to the error. Keep the nargs test only.

Fixes bw2#354
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

argument with custom list actions fail to parse from a config file

1 participant