fix: resolve abbreviated root options in lazy CLI dispatch - #213
Open
galjos wants to merge 1 commit into
Open
Conversation
The lazy command detector only recognised the exact spellings of the root options, while argparse also accepts any unambiguous prefix. With an abbreviated option such as --logging or --log-fi the detector missed the sub-command, so its sub-parser was registered without arguments and the run either aborted with an unrecognized-arguments error or crashed with an AttributeError. The detector now resolves unambiguous long-option prefixes the same way argparse does.
Contributor
|
PYLINT REPORT Your code has been rated at 9.78/10 Full reportRaw metrics
Duplication
Messages by category
% errors / warnings by module
Messages
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #213 +/- ##
=======================================
Coverage 93.94% 93.94%
=======================================
Files 177 177
Lines 9227 9230 +3
=======================================
+ Hits 8668 8671 +3
Misses 559 559
🚀 New features to boost your workflow:
|
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.
_detect_commandmatched only exact spellings of the root options while argparse accepts any unambiguous prefix, so--logging DEBUG rdf ...failed to detect the sub-command, registered zero sub-parser arguments, and either rejected the input file or dispatched on an empty namespace. The detection now resolves unambiguous long-option prefixes the way argparse does, including=valueforms.Tests cover the abbreviated spellings for all root options plus an end-to-end dispatch.
Fixes #212.