Skip to content

Commit c4f3d8c

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

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
@@ -558,7 +558,8 @@ PyDoc_STRVAR(genericalias__doc__,
558558
"--\n\n"
559559
"Represent a PEP 585 generic type\n"
560560
"\n"
561-
"E.g. for t = list[int], t.__origin__ is list and t.__args__ is (int,).");
561+
"For example, for t = list[int], t.__origin__ is list and t.__args__\n"
562+
"is (int,).");
562563

563564
static PyObject *
564565
ga_getitem(PyObject *self, PyObject *item)

Objects/tupleobject.c

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

831831
PyDoc_STRVAR(tuple_class_getitem_doc,
832832
"Tuples are generic over the types of their contents.\n\n\
833-
For example, use ``tuple[int, str]`` for a pair whose first element is an int and second element is a string.\n\n\
834-
Tuples also support the form ``tuple[T, ...]`` to indicate an arbitrary length tuple of elements of type T.");
833+
For example, use ``tuple[int, str]`` for a pair whose first element\n\
834+
is an int and second element is a string.\n\n\
835+
Tuples also support the form ``tuple[T, ...]`` to indicate\n\
836+
an arbitrary length tuple of elements of type T.");
835837

836838
static PyMethodDef tuple_methods[] = {
837839
TUPLE___GETNEWARGS___METHODDEF

Objects/typevarobject.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1841,8 +1841,9 @@ PyDoc_STRVAR(generic_class_getitem_doc,
18411841
"Parameterizes a generic class.\n\
18421842
\n\
18431843
At least, parameterizing a generic class is the *main* thing this\n\
1844-
method does. For example, for some generic class `Foo`, this is called\n\
1845-
when we do `Foo[int]` - there, with `cls=Foo` and `params=int`.\n\
1844+
method does. For example, for some generic class `Foo`, this is\n\
1845+
called when we do `Foo[int]` - there, with `cls=Foo` and\n\
1846+
`params=int`.\n\
18461847
\n\
18471848
However, note that this method is also called when defining generic\n\
18481849
classes in the first place with `class Foo[T]: ...`.\n\

0 commit comments

Comments
 (0)