Skip to content

Commit b6d3236

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

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
@@ -569,7 +569,8 @@ PyDoc_STRVAR(genericalias__doc__,
569569
"--\n\n"
570570
"Represent a PEP 585 generic type\n"
571571
"\n"
572-
"E.g. for t = list[int], t.__origin__ is list and t.__args__ is (int,).");
572+
"For example, for t = list[int], t.__origin__ is list and t.__args__\n"
573+
"is (int,).");
573574

574575
static PyObject *
575576
ga_getitem(PyObject *self, PyObject *item)

Objects/tupleobject.c

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

879879
PyDoc_STRVAR(tuple_class_getitem_doc,
880880
"Tuples are generic over the types of their contents.\n\n\
881-
For example, use ``tuple[int, str]`` for a pair whose first element is an int and second element is a string.\n\n\
882-
Tuples also support the form ``tuple[T, ...]`` to indicate an arbitrary length tuple of elements of type T.");
881+
For example, use ``tuple[int, str]`` for a pair whose first element\n\
882+
is an int and second element is a string.\n\n\
883+
Tuples also support the form ``tuple[T, ...]`` to indicate\n\
884+
an arbitrary length tuple of elements of type T.");
883885

884886
static PyMethodDef tuple_methods[] = {
885887
TUPLE___GETNEWARGS___METHODDEF

Objects/typevarobject.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2218,8 +2218,9 @@ PyDoc_STRVAR(generic_class_getitem_doc,
22182218
"Parameterizes a generic class.\n\
22192219
\n\
22202220
At least, parameterizing a generic class is the *main* thing this\n\
2221-
method does. For example, for some generic class `Foo`, this is called\n\
2222-
when we do `Foo[int]` - there, with `cls=Foo` and `params=int`.\n\
2221+
method does. For example, for some generic class `Foo`, this is\n\
2222+
called when we do `Foo[int]` - there, with `cls=Foo` and\n\
2223+
`params=int`.\n\
22232224
\n\
22242225
However, note that this method is also called when defining generic\n\
22252226
classes in the first place with `class Foo[T]: ...`.\n\

0 commit comments

Comments
 (0)