DOC: Use pipx as the docs parser program name - #2007
Open
karlhillx wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes the generated CLI reference in the Sphinx docs so it consistently shows pipx as the program name (instead of inheriting sys.argv[0] like sphinx-build during documentation builds).
Changes:
- Adds an optional
progoverride toget_command_parser()and uses it inbuild_parser()to forceprog="pipx"for docs generation. - Adds a regression test asserting both the root parser
progand the nestedrunsubparserprog. - Adds a changelog fragment documenting the docs output fix.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/pipx/main.py |
Allows explicitly overriding the argparse prog and forces pipx for the docs parser returned by build_parser(). |
tests/test_main.py |
Adds a regression test ensuring docs parser naming stays pipx even when sys.argv[0] is sphinx-build. |
changelog.d/2005.doc.md |
Documents the CLI reference output correction in the changelog fragments. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
1761
to
1764
| parser = argparse.ArgumentParser( | ||
| prog=prog_name(), | ||
| prog=prog or prog_name(), | ||
| formatter_class=LineWrapRawTextHelpFormatter, | ||
| description=PIPX_DESCRIPTION, |
Comment on lines
+76
to
+78
| assert parser.prog == "pipx" | ||
| subparsers = next(a for a in parser._actions if isinstance(a, argparse._SubParsersAction)) | ||
| assert subparsers.choices["run"].prog == "pipx run" |
karlhillx
force-pushed
the
fix/2005-docs-parser-prog
branch
from
August 15, 2026 12:21
1b55b75 to
1fb5dc3
Compare
build_parser() derives the program name from sys.argv[0] via prog_name(), which is sphinx-build during the docs build, so the generated run subparser is named 'sphinx-build run'. Let get_command_parser() accept an explicit prog and have build_parser() pass prog="pipx". Closes pypa#2005.
karlhillx
force-pushed
the
fix/2005-docs-parser-prog
branch
from
August 15, 2026 12:22
bf541b3 to
1a5d504
Compare
for more information, see https://pre-commit.ci
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.
Closes #2005.
The docs build renders the CLI reference from
build_parser(), which derivesthe program name from
sys.argv[0]viaprog_name(). During the Sphinx buildthat value is
sphinx-build, so the generatedrunsubparser is namedsphinx-build runinstead ofpipx run.Let
get_command_parser()accept an explicitprogand havebuild_parser()pass
prog="pipx", so the docs parser is always namedpipxregardless ofsys.argv[0]. Add a regression test asserting both the root and nestedsubparser program names, plus a
changelog.d/2005.doc.mdfragment.