Skip to content

Commit 72157aa

Browse files
Use less signatures and more default values.
1 parent 5f13e6f commit 72157aa

File tree

2 files changed

+19
-36
lines changed

2 files changed

+19
-36
lines changed

Doc/library/functions.rst

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,8 @@ are always available. They are listed here in alphabetical order.
182182
.. versionadded:: 3.7
183183

184184
.. _func-bytearray:
185-
.. class:: bytearray()
186-
bytearray(source)
187-
bytearray(source, encoding)
188-
bytearray(source, encoding, errors)
185+
.. class:: bytearray(source=b'')
186+
bytearray(source, encoding, errors='strict')
189187
:noindex:
190188

191189
Return a new array of bytes. The :class:`bytearray` class is a mutable
@@ -215,10 +213,8 @@ are always available. They are listed here in alphabetical order.
215213

216214

217215
.. _func-bytes:
218-
.. class:: bytes()
219-
bytes(source)
220-
bytes(source, encoding)
221-
bytes(source, encoding, errors)
216+
.. class:: bytes(source=b'')
217+
bytes(source, encoding, errors='strict')
222218
:noindex:
223219

224220
Return a new "bytes" object which is an immutable sequence of integers in
@@ -848,7 +844,7 @@ are always available. They are listed here in alphabetical order.
848844

849845

850846
.. _func-frozenset:
851-
.. class:: frozenset(iterable=set(), /)
847+
.. class:: frozenset(iterable=(), /)
852848
:noindex:
853849

854850
Return a new :class:`frozenset` object, optionally with elements taken from
@@ -1146,8 +1142,7 @@ are always available. They are listed here in alphabetical order.
11461142

11471143

11481144
.. _func-list:
1149-
.. class:: list()
1150-
list(iterable, /)
1145+
.. class:: list(iterable=(), /)
11511146
:noindex:
11521147

11531148
Rather than being a function, :class:`list` is actually a mutable
@@ -1763,7 +1758,7 @@ are always available. They are listed here in alphabetical order.
17631758
return f"Person('{self.name}', {self.age})"
17641759

17651760

1766-
.. function:: reversed(sequence, /)
1761+
.. function:: reversed(object, /)
17671762

17681763
Return a reverse :term:`iterator`. The argument must be an object which has
17691764
a :meth:`~object.__reversed__` method or supports the sequence protocol (the
@@ -1799,8 +1794,7 @@ are always available. They are listed here in alphabetical order.
17991794

18001795

18011796
.. _func-set:
1802-
.. class:: set()
1803-
set(iterable, /)
1797+
.. class:: set(iterable=(), /)
18041798
:noindex:
18051799

18061800
Return a new :class:`set` object, optionally with elements taken from
@@ -1940,10 +1934,8 @@ are always available. They are listed here in alphabetical order.
19401934
single: string; str() (built-in function)
19411935

19421936
.. _func-str:
1943-
.. class:: str()
1944-
str(object)
1945-
str(object, encoding)
1946-
str(object, encoding, errors)
1937+
.. class:: str(object='')
1938+
str(object, encoding, errors='strict')
19471939
str(object, *, errors)
19481940
:noindex:
19491941
@@ -2059,8 +2051,7 @@ are always available. They are listed here in alphabetical order.
20592051

20602052

20612053
.. _func-tuple:
2062-
.. class:: tuple()
2063-
tuple(iterable, /)
2054+
.. class:: tuple(iterable=(), /)
20642055
:noindex:
20652056

20662057
Rather than being a function, :class:`tuple` is actually an immutable

Doc/library/stdtypes.rst

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,8 +1312,7 @@ Lists are mutable sequences, typically used to store collections of
13121312
homogeneous items (where the precise degree of similarity will vary by
13131313
application).
13141314

1315-
.. class:: list()
1316-
list(iterable, /)
1315+
.. class:: list(iterable=(), /)
13171316

13181317
Lists may be constructed in several ways:
13191318

@@ -1394,8 +1393,7 @@ built-in). Tuples are also used for cases where an immutable sequence of
13941393
homogeneous data is needed (such as allowing storage in a :class:`set` or
13951394
:class:`dict` instance).
13961395

1397-
.. class:: tuple()
1398-
tuple(iterable, /)
1396+
.. class:: tuple(iterable=(), /)
13991397

14001398
Tuples may be constructed in a number of ways:
14011399

@@ -1698,10 +1696,8 @@ multiple fragments.
16981696
.. index::
16991697
single: string; str (built-in class)
17001698

1701-
.. class:: str()
1702-
str(object)
1703-
str(object, encoding)
1704-
str(object, encoding, errors)
1699+
.. class:: str(object='')
1700+
str(object, encoding, errors='strict')
17051701
str(object, *, errors)
17061702
17071703
Return a :ref:`string <textseq>` version of *object*. If *object* is not
@@ -2895,10 +2891,8 @@ binary protocols are based on the ASCII text encoding, bytes objects offer
28952891
several methods that are only valid when working with ASCII compatible
28962892
data and are closely related to string objects in a variety of other ways.
28972893

2898-
.. class:: bytes()
2899-
bytes(source)
2900-
bytes(source, encoding)
2901-
bytes(source, encoding, errors)
2894+
.. class:: bytes(source=b'')
2895+
bytes(source, encoding, errors='strict')
29022896

29032897
Firstly, the syntax for bytes literals is largely the same as that for string
29042898
literals, except that a ``b`` prefix is added:
@@ -3008,10 +3002,8 @@ Bytearray Objects
30083002
:class:`bytearray` objects are a mutable counterpart to :class:`bytes`
30093003
objects.
30103004

3011-
.. class:: bytearray()
3012-
bytearray(source)
3013-
bytearray(source, encoding)
3014-
bytearray(source, encoding, errors)
3005+
.. class:: bytearray(source=b'')
3006+
bytearray(source, encoding, errors='strict')
30153007

30163008
There is no dedicated literal syntax for bytearray objects, instead
30173009
they are always created by calling the constructor:

0 commit comments

Comments
 (0)