Commit 93406f1
committed
gh-110131: Document argparse's extend action with a non-empty default
The 'append' bullet says that a non-empty list default is kept and that
command-line values land after it. 'extend' works the same way for an
option, but the docs say nothing about it, which is the confusion
reported in gh-110131.
The sentence is scoped to the option deliberately. For a positional with
nargs='*' or '?' and no command-line values, _get_values hands the default
back as the parsed value while the same default is already in the
namespace, so the action applies it twice and extend(default=['X'])
yields ['X', 'X']. The unqualified wording would be wrong there.1 parent 0546b5f commit 93406f1
1 file changed
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
818 | 818 | | |
819 | 819 | | |
820 | 820 | | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
821 | 824 | | |
822 | 825 | | |
823 | 826 | | |
| |||
0 commit comments