Skip to content

Commit ad3c99e

Browse files
gh-92446: Improve argparse choices docs; revert bad change to lzma docs (#94627)
Based on the definition of the collections.abc classes, it is more accurate to use "sequence" instead of "container" when describing argparse choices. A previous attempt at fixing this in #92450 was mistaken; this PR reverts that change. Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
1 parent dbc1e69 commit ad3c99e

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

Doc/library/argparse.rst

+6-6
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ The add_argument() method
765765

766766
* type_ - The type to which the command-line argument should be converted.
767767

768-
* choices_ - A container of the allowable values for the argument.
768+
* choices_ - A sequence of the allowable values for the argument.
769769

770770
* required_ - Whether or not the command-line option may be omitted
771771
(optionals only).
@@ -1209,7 +1209,7 @@ choices
12091209
^^^^^^^
12101210

12111211
Some command-line arguments should be selected from a restricted set of values.
1212-
These can be handled by passing a container object as the *choices* keyword
1212+
These can be handled by passing a sequence object as the *choices* keyword
12131213
argument to :meth:`~ArgumentParser.add_argument`. When the command line is
12141214
parsed, argument values will be checked, and an error message will be displayed
12151215
if the argument was not one of the acceptable values::
@@ -1223,9 +1223,9 @@ if the argument was not one of the acceptable values::
12231223
game.py: error: argument move: invalid choice: 'fire' (choose from 'rock',
12241224
'paper', 'scissors')
12251225

1226-
Note that inclusion in the *choices* container is checked after any type_
1226+
Note that inclusion in the *choices* sequence is checked after any type_
12271227
conversions have been performed, so the type of the objects in the *choices*
1228-
container should match the type_ specified::
1228+
sequence should match the type_ specified::
12291229

12301230
>>> parser = argparse.ArgumentParser(prog='doors.py')
12311231
>>> parser.add_argument('door', type=int, choices=range(1, 4))
@@ -1235,8 +1235,8 @@ container should match the type_ specified::
12351235
usage: doors.py [-h] {1,2,3}
12361236
doors.py: error: argument door: invalid choice: 4 (choose from 1, 2, 3)
12371237

1238-
Any container can be passed as the *choices* value, so :class:`list` objects,
1239-
:class:`set` objects, and custom containers are all supported.
1238+
Any sequence can be passed as the *choices* value, so :class:`list` objects,
1239+
:class:`tuple` objects, and custom sequences are all supported.
12401240

12411241
Use of :class:`enum.Enum` is not recommended because it is difficult to
12421242
control its appearance in usage, help, and error messages.

Doc/library/lzma.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ Compressing and decompressing data in memory
147147
This format is more limited than ``.xz`` -- it does not support integrity
148148
checks or multiple filters.
149149

150-
* :const:`FORMAT_RAW`: A raw data stream, not using sequences format.
150+
* :const:`FORMAT_RAW`: A raw data stream, not using any container format.
151151
This format specifier does not support integrity checks, and requires that
152152
you always specify a custom filter chain (for both compression and
153153
decompression). Additionally, data compressed in this manner cannot be

0 commit comments

Comments
 (0)