# Argparse ValueError: action store\_true is not valid for positional arguments

**URL:** <https://discuss.python.org/t/argparse-valueerror-action-store-true-is-not-valid-for-positional-arguments/106355>\
**Category:** Python Help\
**Tags:** argparse\
**Created:** [March 2, 2026, 9:34pm UTC](https://discuss.python.org/t/argparse-valueerror-action-store-true-is-not-valid-for-positional-arguments/106355 "2026-03-02T21:34:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dsilva](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/dsilva/32/34488_2.png) [@dsilva](https://discuss.python.org/u/dsilva)\
**Post date:** [March 2, 2026, 9:34pm UTC](https://discuss.python.org/t/argparse-valueerror-action-store-true-is-not-valid-for-positional-arguments/106355/1 "2026-03-02T21:34:24Z")

</div>

After upgrading to Python 3.14, my _argparse_ code raises the following error:

> ValueError: action ‘store\_true‘ is not valid for positional arguments

```python
$ basketcase -h
Traceback (most recent call last):
  File "/home/dsilva/.local/share/virtualenvs/basketcase--xOC7pu1/bin/basketcase", line 7, in <module>
    sys.exit(main())
             ~~~~ ^^
  File "/home/dsilva/Code/basketcase/src/basketcase/ __main__.py", line 305, in main
    session_list_parser.add_argument(
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
        'list',
        ^^^^^^^
        help='Print a list of available sessions',
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        action='store_true'
        ^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/lib64/python3.14/argparse.py", line 1540, in add_argument
    raise ValueError(f'action {action_name!r} is not valid for positional arguments')
ValueError: action 'store_true' is not valid for positional arguments

```

This is a program called `basketcase`. The complete argparse code is published [here](https://gitlab.com/crimson.king/basketcase/-/blob/df7639714b14c024b67d81ccd472137747858614/src/basketcase/ __main__.py#L222).

It starts by defining a top-level subparser.

```python
    commands = parser.add_subparsers(
        title='commands', required=True
    )

```

Then it adds a sub-command `session`.

```python
    # session subparser
    session_parser = commands.add_parser(
        'session',
        help='Session management command help'
    )

    session_commands = session_parser.add_subparsers(
        title='Commands', required=True
    )

```

And then it adds a sub-command of `session` called `list`. You would run it as `basketcase session list`.

```python
    # session sub-command parsers
    session_list_parser = session_commands.add_parser(
        'list',
        help='Print a list of available sessions'
    )

    session_list_parser.set_defaults(action=_session_list)

    session_list_parser.add_argument(
        'list',
        help='Print a list of available sessions',
        action='store_true'
    )

```

Apparently, it no longer allows using `store_true` for positional arguments, but I couldn’t figure out why.

`list` is not an optional argument; and, as far as I know, we’re not supposed to use “required options” for this. What am I supposed to use, then?

---

<div class="post-metadata">

**Author:** ![bschubert](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/bschubert/32/26920_2.png) [@bschubert](https://discuss.python.org/u/bschubert)\
**Post date:** [March 2, 2026, 9:58pm UTC](https://discuss.python.org/t/argparse-valueerror-action-store-true-is-not-valid-for-positional-arguments/106355/2 "2026-03-02T21:58:58Z")

</div>

> [@dsilva](#):
>
> Apparently, it no longer allows using `store_true` for positional arguments, but I couldn’t figure out why.

This was a deliberate change from [python/cpython#124839](https://github.com/python/cpython/pull/124839) - see [python/cpython#85935](https://github.com/python/cpython/issues/85935) and [python/cpython#97848](https://github.com/python/cpython/issues/97848) for the rational.

> [@dsilva](#):
>
> What am I supposed to use, then?

As mentioned in [this comment](https://github.com/python/cpython/issues/97848#issuecomment-3385711074), you can try passing `dest` to `add_subparsers()` to store the name of the subcommand that was used.

---

<div class="post-metadata">

**Author:** ![dsilva](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/dsilva/32/34488_2.png) [@dsilva](https://discuss.python.org/u/dsilva)\
**Post date:** [March 3, 2026, 3:49am UTC](https://discuss.python.org/t/argparse-valueerror-action-store-true-is-not-valid-for-positional-arguments/106355/3 "2026-03-03T03:49:51Z")

</div>

Thanks for finding that. They totally forgot to add this very important change to the [release notes](https://docs.python.org/3.14/whatsnew/3.14.html).

* * *

It turns out that I don’t need to use `dest`, because I already use `set_defaults` to call a function, depending on the subparser used.

```diff
    # session sub-command parsers
    session_list_parser = session_commands.add_parser(
        'list',
        help='Print a list of available sessions'
    )

    session_list_parser.set_defaults(action=_session_list)

- session_list_parser.add_argument(
- 'list',
- help='Print a list of available sessions',
- action='store_true'
- )

```

In other words, I just had to delete the `add_argument` call. It was redundant anyway and I didn’t realize that until now.
