]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-94590: add signatures to operator itemgetter, attrgetter, methodcaller (#94591)
authorErik Welch <erik.n.welch@gmail.com>
Thu, 6 Oct 2022 20:35:53 +0000 (15:35 -0500)
committerGitHub <noreply@github.com>
Thu, 6 Oct 2022 20:35:53 +0000 (13:35 -0700)
These were intentionally skipped when operator was updated to use the argument clinic:
https://github.com/python/cpython/issues/64385#issuecomment-1093641466

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`.

Modules/_operator.c

index 51ca74eeeaee219404cc4321b0c3535b086d150f..77eabdb57af92107964702fe9e4cae7f52c9915d 100644 (file)
@@ -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])");
@@ -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\
@@ -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\