Skip to content

GH-130645: Default to color help in argparse #136809

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

Merged
merged 7 commits into from
Jul 20, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improve description of disabling colour support locally vs in the Arg…
…umentParser
  • Loading branch information
AA-Turner committed Jul 19, 2025
commit 82c7e2511c631ab9dfb7a031bd078a27296233fa
10 changes: 5 additions & 5 deletions Doc/library/argparse.rst
Original file line number Diff line number Diff line change
Expand Up @@ -620,8 +620,11 @@ keyword argument::
color
^^^^^

By default, the help message is printed in color. If you want plain text
help messages, you can disable it by setting ``color`` to ``False``::
By default, the help message is printed in color using `ANSI escape sequences
<https://en.wikipedia.org/wiki/ANSI_escape_code>`__.
If you want plain text help messages, you can disable this :ref:`in your local
environment <using-on-controlling-color>`, or in the argument parser itself
by setting ``color`` to ``False``::

>>> parser = argparse.ArgumentParser(description='Process some integers.',
... color=False)
Expand All @@ -630,9 +633,6 @@ help messages, you can disable it by setting ``color`` to ``False``::
... help='an integer for the accumulator')
>>> parser.parse_args(['--help'])

Even if a CLI author has not disabled color, it can be
:ref:`controlled using environment variables <using-on-controlling-color>`.

.. versionadded:: 3.14


Expand Down
Loading