Skip to content

Commit a9a8f2e

Browse files
eriknwmpage
authored andcommitted
pythongh-94590: add signatures to operator itemgetter, attrgetter, methodcaller (python#94591)
These were intentionally skipped when operator was updated to use the argument clinic: python#64385 (comment) However, by not using the argument clinic, they missed out on getting signatures. This is a narrow PR to update the docstrings so that `__text_signature__` can be extracted from them. Updating to use the argument clinic is beyond scope. `methodcaller` uses `*args, **kwargs` to match variadic names used elsewhere, including in `operator.call`.
1 parent aa83510 commit a9a8f2e

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

Modules/_operator.c

+3-6
Original file line numberDiff line numberDiff line change
@@ -1162,8 +1162,7 @@ static PyMemberDef itemgetter_members[] = {
11621162
};
11631163

11641164
PyDoc_STRVAR(itemgetter_doc,
1165-
"itemgetter(item, ...) --> itemgetter object\n\
1166-
\n\
1165+
"itemgetter(item, /, *items)\n--\n\n\
11671166
Return a callable object that fetches the given item(s) from its operand.\n\
11681167
After f = itemgetter(2), the call f(r) returns r[2].\n\
11691168
After g = itemgetter(2, 5, 3), the call g(r) returns (r[2], r[5], r[3])");
@@ -1523,8 +1522,7 @@ static PyMemberDef attrgetter_members[] = {
15231522
};
15241523

15251524
PyDoc_STRVAR(attrgetter_doc,
1526-
"attrgetter(attr, ...) --> attrgetter object\n\
1527-
\n\
1525+
"attrgetter(attr, /, *attrs)\n--\n\n\
15281526
Return a callable object that fetches the given attribute(s) from its operand.\n\
15291527
After f = attrgetter('name'), the call f(r) returns r.name.\n\
15301528
After g = attrgetter('name', 'date'), the call g(r) returns (r.name, r.date).\n\
@@ -1775,8 +1773,7 @@ static PyMethodDef methodcaller_methods[] = {
17751773
{NULL}
17761774
};
17771775
PyDoc_STRVAR(methodcaller_doc,
1778-
"methodcaller(name, ...) --> methodcaller object\n\
1779-
\n\
1776+
"methodcaller(name, /, *args, **kwargs)\n--\n\n\
17801777
Return a callable object that calls the given method on its operand.\n\
17811778
After f = methodcaller('name'), the call f(r) returns r.name().\n\
17821779
After g = methodcaller('name', 'date', foo=1), the call g(r) returns\n\

0 commit comments

Comments
 (0)