Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Show subcommand's help info when passing unrecognized arguments #2480

Merged

Conversation

leemars
Copy link
Contributor

@leemars leemars commented Dec 8, 2023

Pull Request Checklist

  • A news fragment is added in news/ describing what is new.
  • Test cases added for changed code.

Describe what you have changed in this PR.

When passing unrecognized arguments to a pdm subcommand, pdm displays its own help info instead of the subcommand's one. It would be more helpful for users if pdm could display the help info of the subcommand.

This issue is caused by a known design of Python's argparse module, and the argparse module is not planning to improve it. (Refs: python/cpython#83287 )

I found a modification on Stackoverflow, which I tried and found to be effective. (Refs: https://stackoverflow.com/a/61724607 )

Copy link

codecov bot commented Dec 8, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (b05d1cb) 84.56% compared to head (2f93472) 84.57%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2480      +/-   ##
==========================================
+ Coverage   84.56%   84.57%   +0.01%     
==========================================
  Files         104      104              
  Lines       10293    10300       +7     
  Branches     2248     2249       +1     
==========================================
+ Hits         8704     8711       +7     
  Misses       1116     1116              
  Partials      473      473              
Flag Coverage Δ
unittests 84.35% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@frostming frostming left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No other side effects were found, accepted.

@frostming frostming merged commit 42ff1e7 into pdm-project:main Dec 11, 2023
21 checks passed
@leemars leemars deleted the feat/subcommand-unknown-args-help-info branch December 18, 2023 05:55
@j178 j178 mentioned this pull request Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants