Skip to content

Commit b1ef640

Browse files
committed
Update docs
1 parent f93920d commit b1ef640

3 files changed

Lines changed: 11 additions & 19 deletions

File tree

Doc/library/argparse.rst

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ ArgumentParser objects
7474
prefix_chars='-', fromfile_prefix_chars=None, \
7575
argument_default=None, conflict_handler='error', \
7676
add_help=True, allow_abbrev=True, exit_on_error=True, \
77-
*, suggest_on_error=False, color=False)
77+
*, suggest_on_error=False, color=True)
7878
7979
Create a new :class:`ArgumentParser` object. All parameters should be passed
8080
as keyword arguments. Each parameter has its own more detailed description
@@ -119,7 +119,7 @@ ArgumentParser objects
119119
* suggest_on_error_ - Enables suggestions for mistyped argument choices
120120
and subparser names (default: ``False``)
121121

122-
* color_ - Allow color output (default: ``False``)
122+
* color_ - Allow color output (default: ``True``)
123123

124124
.. versionchanged:: 3.5
125125
*allow_abbrev* parameter was added.
@@ -620,27 +620,19 @@ keyword argument::
620620
color
621621
^^^^^
622622

623-
By default, the help message is printed in plain text. If you want to allow
624-
color in help messages, you can enable it by setting ``color`` to ``True``::
623+
By default, the help message is printed in color. If you want to plain text
624+
help messages, you can disable it by setting ``color`` to ``False``::
625625

626626
>>> parser = argparse.ArgumentParser(description='Process some integers.',
627-
... color=True)
627+
... color=False)
628628
>>> parser.add_argument('--action', choices=['sum', 'max'])
629629
>>> parser.add_argument('integers', metavar='N', type=int, nargs='+',
630630
... help='an integer for the accumulator')
631631
>>> parser.parse_args(['--help'])
632632

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

636-
If you're writing code that needs to be compatible with older Python versions
637-
and want to opportunistically use ``color`` when it's available, you
638-
can set it as an attribute after initializing the parser instead of using the
639-
keyword argument::
640-
641-
>>> parser = argparse.ArgumentParser(description='Process some integers.')
642-
>>> parser.color = True
643-
644636
.. versionadded:: 3.14
645637

646638

Doc/whatsnew/3.14.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,11 +1204,10 @@ argparse
12041204

12051205
.. _whatsnew314-color-argparse:
12061206

1207-
* Introduced the optional *color* parameter to
1208-
:class:`argparse.ArgumentParser`, enabling color for help text.
1209-
This can be controlled by :ref:`environment variables
1210-
<using-on-controlling-color>`. Color has also been enabled for help in the
1211-
:ref:`stdlib CLIs <library-cmdline>` which use :mod:`!argparse`.
1207+
* Enable color for help text, which can be disabled with the optional *color*
1208+
parameter to :class:`argparse.ArgumentParser`.
1209+
This can also be controlled by :ref:`environment variables
1210+
<using-on-controlling-color>`.
12121211
(Contributed by Hugo van Kemenade in :gh:`130645`.)
12131212

12141213

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Default to color help in argparse.

0 commit comments

Comments
 (0)