Skip to content

Conversation

@bw2
Copy link
Owner

@bw2 bw2 commented Dec 31, 2025

Summary

This PR fixes two medium-term issues:

  1. Issue nargs=argparse.REMAINDER can break config file option parsing #285: nargs=REMAINDER breaking config file parsing
  2. Issue Empty environment variable and empty yaml key behave differently #296: Empty environment variable and empty YAML key behave differently

Changes

Fix for nargs=REMAINDER (#285)

When a positional argument uses nargs=argparse.REMAINDER, it consumes all remaining arguments. The previous logic would append config/env args to the end of the command line when no optional args were present, causing REMAINDER to consume them incorrectly.

Solution: Check if any positional argument uses REMAINDER:

  • If REMAINDER exists and no optional args on command line: prepend config/env args (insert at position 0)
  • Otherwise: append to end (original behavior) to avoid nargs="+" consuming positional args

Fix for empty values (#296)

Empty environment variables and empty YAML keys were behaving inconsistently. YAML returns None for empty values (treated as missing), but env vars and config files were passing empty strings through.

Solution: Skip empty string values for args with nargs in both config file and env var processing. This matches YAML behavior while preserving empty strings for simple args without nargs.

Tests

Related

- Fix issue #285: nargs=REMAINDER breaking config file parsing
  * When no optional args exist on command line, check if any positional
    arg uses REMAINDER
  * If REMAINDER exists, prepend config/env args to avoid consumption
  * Otherwise, append to end (original behavior) to avoid nargs="+"
    consuming positional args
  * Add testRemainderWithConfigFile() regression test

- Fix issue #296: Empty env var and empty YAML key behave differently
  * Skip empty string values for args with nargs in both config files
    and env vars
  * This matches YAML behavior where empty values are treated as None
  * Preserves empty strings for simple args without nargs
  * Add testEmptyValuesIgnored() regression test

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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.

Empty environment variable and empty yaml key behave differently nargs=argparse.REMAINDER can break config file option parsing

2 participants