Open
Conversation
This commit addresses two issues: 1. Fix -- separator handling with config files and env vars (Issue #298) - Modified parse_known_args() to insert config file and env var args before the first optional argument (starts with -) instead of prepending/appending them - This preserves the -- separator position and ensures positional args after -- are not mixed with config/env var args - Added comprehensive test case testDoubleDashSeparator() to verify the fix works with config files and environment variables 2. Document all available aliases (Issue #297) - Enhanced the Aliases section in README.rst to document all available alias names - Organized aliases into clear categories: Class, Method, Function, and HelpFormatter aliases - Each alias now shows what it maps to for clarity Technical details: - The original code used the 'nargs' flag to decide whether to append or prepend args, which caused config args to be placed after -- when action="append" was used - The new implementation always inserts before the first optional arg, which correctly handles -- separator in all cases 🤖 Generated with Claude Code (https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses two open issues by fixing the
--separator handling bug and documenting all available aliases.Changes
1. Fix
--separator handling (Issue #298)Problem: When using config files or environment variables with the
--separator, config/env args were incorrectly mixed with positional arguments that should come after--.Example of the bug:
Solution:
parse_known_args()in configargparse.py (lines 971-982 and 1067-1078)-)--separator position and prevents args from being mixedtestDoubleDashSeparator()to verify the fixTechnical details:
The original code used the
nargsflag to decide whether to append or prepend args. Whenaction="append"was used, this caused config args to be appended to the end, placing them after--. The new implementation always inserts before the first optional arg, correctly handling the--separator in all cases.2. Document all available aliases (Issue #297)
Problem: ConfigArgParse provides many convenient aliases (like
p.add(),p.parse(),ArgParser, etc.) that were used in examples but not properly documented.Solution:
ArgParser,Parserp.add(),p.add_arg(),p.parse(),p.parse_known()get_parser(),get_arg_parser(), etc.RawFormatter,DefaultsFormatter, etc.Testing
testDoubleDashSeparator()that tests:--separator--separator--separatorCloses
--seperator for positional arguments correctly #298🤖 Generated with Claude Code