Fix -- separator handling and document aliases #341
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