Skip to content

Commit

Permalink
gh-94590: add signatures to operator itemgetter, attrgetter, methodca…
Browse files Browse the repository at this point in the history
…ller (#94591)

These were intentionally skipped when operator was updated to use the argument clinic:
#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`.
  • Loading branch information
eriknw authored Oct 6, 2022
1 parent effc25f commit 1c4728c
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions Modules/_operator.c
Original file line number Diff line number Diff line change
Expand Up @@ -1162,8 +1162,7 @@ static PyMemberDef itemgetter_members[] = {
};

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

PyDoc_STRVAR(attrgetter_doc,
"attrgetter(attr, ...) --> attrgetter object\n\
\n\
"attrgetter(attr, /, *attrs)\n--\n\n\
Return a callable object that fetches the given attribute(s) from its operand.\n\
After f = attrgetter('name'), the call f(r) returns r.name.\n\
After g = attrgetter('name', 'date'), the call g(r) returns (r.name, r.date).\n\
Expand Down Expand Up @@ -1775,8 +1773,7 @@ static PyMethodDef methodcaller_methods[] = {
{NULL}
};
PyDoc_STRVAR(methodcaller_doc,
"methodcaller(name, ...) --> methodcaller object\n\
\n\
"methodcaller(name, /, *args, **kwargs)\n--\n\n\
Return a callable object that calls the given method on its operand.\n\
After f = methodcaller('name'), the call f(r) returns r.name().\n\
After g = methodcaller('name', 'date', foo=1), the call g(r) returns\n\
Expand Down

0 comments on commit 1c4728c

Please sign in to comment.