Repository navigation
Conversation
Python 3.14 deprecates passing prefix_chars to ArgumentParser.add_argument_group() and warns whenever the keyword is present. The group already inherits the parser's prefix_chars when it is omitted, so only forward it when the caller sets it explicitly. Fixes lebrice#368
This branch has not been deployed
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.
Fixes #368
On Python 3.14, every
simple_parsing.ArgumentParseremits:ArgumentParser.add_argument_groupalways forwardedprefix_chars=prefix_chars or self.prefix_chars, and argparse 3.14 warns whenever the keyword is present. Whenprefix_charsis omitted, argparse's_ArgumentGroupalready falls back to the parser'sprefix_chars(this is true on every supported Python version), so the override now forwards it only when the caller passes one explicitly.argument_defaultandconflict_handlerare handled as before.Added
test/test_issue_368.py:DeprecationWarningturned into an error must not raise;prefix_chars/argument_default/conflict_handlerfrom the parser.Testing
pytest test/test_issue_368.pyon 3.14: fails before the change (DeprecationWarning), passes after. Passes on 3.12 both before and after.uv sync --all-extras): same results before and after. The one failure,test_bools.py::test_bool_args_in_help, already fails onmaster.-W error::DeprecationWarning, it goes from 1006 failures to those same 22.pre-commit run --all-filespasses.