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

Added subparsers action type #338

Merged
merged 5 commits into from Oct 27, 2019
Merged

Added subparsers action type #338

merged 5 commits into from Oct 27, 2019

Conversation

@sukhbeersingh
Copy link
Contributor

sukhbeersingh commented Oct 27, 2019

Fix #325 : Replaced subparser function parameter from Any to argparse._SubParsersAction

@codecov

This comment has been minimized.

Copy link

codecov bot commented Oct 27, 2019

Codecov Report

Merging #338 into master will decrease coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #338      +/-   ##
==========================================
- Coverage    83.2%   83.19%   -0.02%     
==========================================
  Files          10       10              
  Lines        1072     1071       -1     
  Branches      158      158              
==========================================
- Hits          892      891       -1     
  Misses        146      146              
  Partials       34       34
Impacted Files Coverage Δ
src/bandersnatch/main.py 72.72% <100%> (-0.35%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c52c606...7d8b1ba. Read the comment docs.

Copy link
Contributor

cooperlees left a comment

Hi! Many thanks for looking into this. _Object normally means private to the module. Does _SubParsersAction have a parent “public” (i.e. no leading _) that we could potentially use?

If not just say do so and I’ll merge, better than using any.

@sukhbeersingh

This comment has been minimized.

Copy link
Contributor Author

sukhbeersingh commented Oct 27, 2019

The official documentation only says that this is a special object type which is the only one that has access to add_parser() function.

The add_subparsers() method is normally called with no arguments and returns a special action object. This object has a single method, add_parser(), which takes a command name and any
Argparse official docs

Also,

Unfortunately the public API does not allow to get the subparsers, it only lets you add them, and do that once. So you would have to toss the subparsers object around to add something later
https://pythonhosted.org/argh/reference.html

So, no I don't think there is a public base object that we can refer to.

@cooperlees

This comment has been minimized.

Copy link
Contributor

cooperlees commented Oct 27, 2019

Thanks for the excellent research and your first contribution! Will merge away.

I guess we could open a low pri argument parser bug to make it more typing friendly. I’ll think about it. Modules will become more typing friendly now it’s becoming more prevalent in code.

@cooperlees cooperlees merged commit fd77ed7 into pypa:master Oct 27, 2019
7 checks passed
7 checks passed
codecov/patch 100% of diff hit (target 83.2%)
Details
codecov/project Absolute coverage decreased by -0.01% but relative coverage increased by +16.79% compared to c52c606
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
pypa.bandersnatch Build #20191027.1 succeeded
Details
pypa.bandersnatch (Testing_bandersnatch_Mac Python36) Testing_bandersnatch_Mac Python36 succeeded
Details
pypa.bandersnatch (Testing_bandersnatch_Mac Python36Lint) Testing_bandersnatch_Mac Python36Lint succeeded
Details
pypa.bandersnatch (Testing_bandersnatch_Mac Python37) Testing_bandersnatch_Mac Python37 succeeded
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.