Skip to content

Fix argparse crash on Python 3.14 - #6

Open
suhlig wants to merge 2 commits into
Andre0512:mainfrom
suhlig:fix/argparse-python314
Open

suhlig wants to merge 2 commits into
Andre0512:mainfrom
suhlig:fix/argparse-python314

Conversation

@suhlig

@suhlig suhlig commented Oct 7, 2026

Copy link
Copy Markdown

The reconnect, reboot, wps, devices and calls subcommands were registered as positional arguments with action="store_true". Python 3.14's argparse now rejects actions with nargs == 0 on positional arguments, so the CLI raised ValueError: action 'store_true' is not valid for positional arguments at startup for every invocation.

These positionals only existed to capture which subcommand was selected, since the subparsers had no dest. This change captures the command via add_subparsers(dest="command") and drops the bogus positionals, which is the idiomatic argparse approach.

Verified argument parsing and --help output on Python 3.12, 3.13 and 3.14.

suhlig added 2 commits October 7, 2026 12:08
The reconnect, reboot, wps, devices and calls subcommands were registered as positional arguments with action="store_true". Python 3.14 rejects zero-arg actions on positional arguments, raising ValueError at startup, so the CLI failed for every invocation.

Capture the selected subcommand via add_subparsers(dest="command") instead and drop the bogus positionals.

@Wkhanex Wkhanex left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional dispatch regression check on this head: the five no-argument commands and both on/off variants of wifi, guest-wifi and office-wifi parsed correctly (11 combinations), with command identifying the selected subparser and the Wi-Fi values preserved. Extracted check_args also awaited exactly the intended mocked route for wps, reconnect and reboot. This supports replacing the positional store_true flags with the subparser destination. Consider keeping these parser/AsyncMock checks as tests so a future command rename cannot disconnect parsing from dispatch. I ran these checks on Python 3.12; no real router was contacted and Python 3.14/full package tests were not run.

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.

2 participants