Give source-finder's options to its own parser only - #96
Open
Athanaseus wants to merge 1 commit into
Open
Athanaseus wants to merge 1 commit into
Athanaseus wants to merge 1 commit into
Conversation
argparse classifies every token against the main parser before dispatching, and single-dash options match by prefix there even with allow_abbrev=False. So source-finder -t matched -thresh, -tol, -title and -title-size and failed as ambiguous. parse_args() now hands everything after the subcommand to its parser, over the main parser's defaults.
Athanaseus
added this pull request to stack #92
September 15, 2026 19:31
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.
Problem
Why
argparse classifies every token against the main parser before handing anything to a subcommand.
-tisn't a main-parser option, so it's matched by prefix there — and four main options start with-t.allow_abbrev=Falsedoesn't prevent this: in Python 3.10–3.13 it only disables prefix matching for--options, not single-dash ones. It's the same mechanism behind the-r/-refposclash fixed in the dr-refpos PR, so any future option could trigger it again.Fix
A new
parse_args(argv)hands every token after the subcommand to that subcommand's own parser, laid over the main parser's defaults (the rest ofmain()still reads those).main()uses it.get_argparser().parse_args()directly with the subcommand still hits the argparse behaviour; useparse_args().