Skip to content

Commit ef6f063

Browse files
gh-142389: Add backticks to stdlib argparse help to display in colour (#149384)
Co-authored-by: Savannah Ostrowski <savannah@python.org>
1 parent 53a7f76 commit ef6f063

33 files changed

Lines changed: 115 additions & 123 deletions

Lib/ast.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ def main(args=None):
666666

667667
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
668668
parser.add_argument('infile', nargs='?', default='-',
669-
help='the file to parse; defaults to stdin')
669+
help='the file to parse; defaults to `stdin`')
670670
parser.add_argument('-m', '--mode', default='exec',
671671
choices=('exec', 'single', 'eval', 'func_type'),
672672
help='specify what kind of code must be parsed')
@@ -679,8 +679,8 @@ def main(args=None):
679679
help='indentation of nodes (number of spaces)')
680680
parser.add_argument('--feature-version',
681681
type=str, default=None, metavar='VERSION',
682-
help='Python version in the format 3.x '
683-
'(for example, 3.10)')
682+
help='Python version in the format `3.x` '
683+
'(for example, `3.10`)')
684684
parser.add_argument('-O', '--optimize',
685685
type=int, default=-1, metavar='LEVEL',
686686
help='optimization level for parser')

Lib/asyncio/__main__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ def interrupt(self) -> None:
159159
parser = argparse.ArgumentParser(
160160
prog="python3 -m asyncio",
161161
description="Interactive asyncio shell and CLI tools",
162-
color=True,
163162
)
164163
subparsers = parser.add_subparsers(help="sub-commands", dest="command")
165164
ps = subparsers.add_parser(

Lib/calendar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,7 @@ def main(args=None):
922922
"-t", "--type",
923923
default="text",
924924
choices=("text", "html"),
925-
help="output type (text or html)"
925+
help="output type (`text` or `html`)"
926926
)
927927
parser.add_argument(
928928
"-f", "--first-weekday",

Lib/code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ def interact(banner=None, readfunc=None, local=None, exitmsg=None, local_exit=Fa
385385
if __name__ == "__main__":
386386
import argparse
387387

388-
parser = argparse.ArgumentParser(color=True)
388+
parser = argparse.ArgumentParser()
389389
parser.add_argument('-q', action='store_true',
390390
help="don't print version and copyright messages")
391391
args = parser.parse_args()

Lib/compileall.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,6 @@ def main():
326326

327327
parser = argparse.ArgumentParser(
328328
description='Utilities to support installing Python libraries.',
329-
color=True,
330329
)
331330
parser.add_argument('-l', action='store_const', const=0,
332331
default=None, dest='maxlevels',
@@ -338,10 +337,10 @@ def main():
338337
parser.add_argument('-f', action='store_true', dest='force',
339338
help='force rebuild even if timestamps are up to date')
340339
parser.add_argument('-q', action='count', dest='quiet', default=0,
341-
help='output only error messages; -qq will suppress '
340+
help='output only error messages; `-qq` will suppress '
342341
'the error messages as well.')
343342
parser.add_argument('-b', action='store_true', dest='legacy',
344-
help='use legacy (pre-PEP3147) compiled file locations')
343+
help='use legacy (pre-PEP 3147) compiled file locations')
345344
parser.add_argument('-d', metavar='DESTDIR', dest='ddir', default=None,
346345
help=('directory to prepend to file paths for use in '
347346
'compile-time tracebacks and in runtime '
@@ -367,28 +366,28 @@ def main():
367366
'of each file considered for compilation'))
368367
parser.add_argument('-i', metavar='FILE', dest='flist',
369368
help=('add all the files and directories listed in '
370-
'FILE to the list considered for compilation; '
371-
'if "-", names are read from stdin'))
369+
'`FILE` to the list considered for compilation; '
370+
'if `"-"`, names are read from `stdin`'))
372371
parser.add_argument('compile_dest', metavar='FILE|DIR', nargs='*',
373372
help=('zero or more file and directory names '
374373
'to compile; if no arguments given, defaults '
375-
'to the equivalent of -l sys.path'))
374+
'to the equivalent of `-l` `sys.path`'))
376375
parser.add_argument('-j', '--workers', default=1,
377376
type=int, help='Run compileall concurrently')
378377
invalidation_modes = [mode.name.lower().replace('_', '-')
379378
for mode in py_compile.PycInvalidationMode]
380379
parser.add_argument('--invalidation-mode',
381380
choices=sorted(invalidation_modes),
382-
help=('set .pyc invalidation mode; defaults to '
383-
'"checked-hash" if the SOURCE_DATE_EPOCH '
381+
help=('set `.pyc` invalidation mode; defaults to '
382+
'`"checked-hash"` if the `SOURCE_DATE_EPOCH` '
384383
'environment variable is set, and '
385-
'"timestamp" otherwise.'))
384+
'`"timestamp"` otherwise.'))
386385
parser.add_argument('-o', action='append', type=int, dest='opt_levels',
387386
help=('Optimization levels to run compilation with. '
388-
'Default is -1 which uses the optimization level '
389-
'of the Python interpreter itself (see -O).'))
387+
'Default is `-1` which uses the optimization level '
388+
'of the Python interpreter itself (see `-O`).'))
390389
parser.add_argument('-e', metavar='DIR', dest='limit_sl_dest',
391-
help='Ignore symlinks pointing outsite of the DIR')
390+
help='Ignore symlinks pointing outsite of the `DIR`')
392391
parser.add_argument('--hardlink-dupes', action='store_true',
393392
dest='hardlink_dupes',
394393
help='Hardlink duplicated pyc files')

Lib/dis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,7 @@ def dis(self):
11461146
def main(args=None):
11471147
import argparse
11481148

1149-
parser = argparse.ArgumentParser(color=True)
1149+
parser = argparse.ArgumentParser()
11501150
parser.add_argument('-C', '--show-caches', action='store_true',
11511151
help='show inline caches')
11521152
parser.add_argument('-O', '--show-offsets', action='store_true',

Lib/doctest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2951,7 +2951,7 @@ def get(self):
29512951
def _test():
29522952
import argparse
29532953

2954-
parser = argparse.ArgumentParser(description="doctest runner", color=True)
2954+
parser = argparse.ArgumentParser(description="doctest runner")
29552955
parser.add_argument('-v', '--verbose', action='store_true', default=False,
29562956
help='print very verbose output for all tests')
29572957
parser.add_argument('-o', '--option', action='append',
@@ -2961,8 +2961,8 @@ def _test():
29612961
' than once to apply multiple options'))
29622962
parser.add_argument('-f', '--fail-fast', action='store_true',
29632963
help=('stop running tests after first failure (this'
2964-
' is a shorthand for -o FAIL_FAST, and is'
2965-
' in addition to any other -o options)'))
2964+
' is a shorthand for `-o FAIL_FAST`, and is'
2965+
' in addition to any other `-o` options)'))
29662966
parser.add_argument('file', nargs='+',
29672967
help='file containing the tests to run')
29682968
args = parser.parse_args()

Lib/ensurepip/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def _uninstall_helper(*, verbosity=0):
217217

218218
def _main(argv=None):
219219
import argparse
220-
parser = argparse.ArgumentParser(color=True)
220+
parser = argparse.ArgumentParser()
221221
parser.add_argument(
222222
"--version",
223223
action="version",

Lib/gzip.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -664,15 +664,14 @@ def decompress(data):
664664
def main():
665665
from argparse import ArgumentParser
666666
parser = ArgumentParser(description=
667-
"A simple command line interface for the gzip module: act like gzip, "
667+
"A simple command line interface for the `gzip` module: act like `gzip`, "
668668
"but do not delete the input file.",
669-
color=True,
670669
)
671670
group = parser.add_mutually_exclusive_group()
672671
group.add_argument('--fast', action='store_true', help='compress faster')
673672
group.add_argument('--best', action='store_true', help='compress better')
674673
group.add_argument("-d", "--decompress", action="store_true",
675-
help="act like gunzip instead of gzip")
674+
help="act like `gunzip` instead of `gzip`")
676675

677676
parser.add_argument("args", nargs="*", default=["-"], metavar='file')
678677
args = parser.parse_args()

Lib/http/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,7 @@ def _main(args=None):
10811081
import argparse
10821082
import contextlib
10831083

1084-
parser = argparse.ArgumentParser(color=True)
1084+
parser = argparse.ArgumentParser()
10851085
parser.add_argument('-b', '--bind', metavar='ADDRESS',
10861086
help='bind to this address '
10871087
'(default: all interfaces)')

0 commit comments

Comments
 (0)