Skip to content

Commit f3fd7b8

Browse files
[3.15] gh-150285: Fix too long docstrings in GenericAlias and __class_getitem__ (GH-151354) (GH-151367)
(cherry picked from commit 65047f2) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
1 parent b53743f commit f3fd7b8

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

Objects/genericaliasobject.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,8 @@ PyDoc_STRVAR(genericalias__doc__,
572572
"--\n\n"
573573
"Represent a PEP 585 generic type\n"
574574
"\n"
575-
"E.g. for t = list[int], t.__origin__ is list and t.__args__ is (int,).");
575+
"For example, for t = list[int], t.__origin__ is list and t.__args__\n"
576+
"is (int,).");
576577

577578
static PyObject *
578579
ga_getitem(PyObject *self, PyObject *item)

Objects/tupleobject.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -957,8 +957,10 @@ tuple___getnewargs___impl(PyTupleObject *self)
957957

958958
PyDoc_STRVAR(tuple_class_getitem_doc,
959959
"Tuples are generic over the types of their contents.\n\n\
960-
For example, use ``tuple[int, str]`` for a pair whose first element is an int and second element is a string.\n\n\
961-
Tuples also support the form ``tuple[T, ...]`` to indicate an arbitrary length tuple of elements of type T.");
960+
For example, use ``tuple[int, str]`` for a pair whose first element\n\
961+
is an int and second element is a string.\n\n\
962+
Tuples also support the form ``tuple[T, ...]`` to indicate\n\
963+
an arbitrary length tuple of elements of type T.");
962964

963965
static PyMethodDef tuple_methods[] = {
964966
TUPLE___GETNEWARGS___METHODDEF

Objects/typevarobject.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2311,8 +2311,9 @@ PyDoc_STRVAR(generic_class_getitem_doc,
23112311
"Parameterizes a generic class.\n\
23122312
\n\
23132313
At least, parameterizing a generic class is the *main* thing this\n\
2314-
method does. For example, for some generic class `Foo`, this is called\n\
2315-
when we do `Foo[int]` - there, with `cls=Foo` and `params=int`.\n\
2314+
method does. For example, for some generic class `Foo`, this is\n\
2315+
called when we do `Foo[int]` - there, with `cls=Foo` and\n\
2316+
`params=int`.\n\
23162317
\n\
23172318
However, note that this method is also called when defining generic\n\
23182319
classes in the first place with `class Foo[T]: ...`.\n\

0 commit comments

Comments
 (0)