Closed
Description
Bug report
Bug description:
On Python 3.12.3 and 3.11.9, it looks like the inspect.Signature
object for operator's attrgetter
, itemgetter
, and methodcaller
classes doesn't match their __call__
method signature:
>>> import inspect
>>> import operator
>>> inspect.signature(operator.attrgetter("spam"))
<Signature (*args, **kwargs)>
>>> inspect.signature(operator.itemgetter("spam"))
<Signature (*args, **kwargs)>
>>> inspect.signature(operator.methodcaller("spam"))
<Signature (*args, **kwargs)>
but their __call__
methods only accept a single argument:
# attrgetter / itemgetter
def __call__(self, obj):
return self._call(obj)
# methodcaller
def __call__(self, obj):
return getattr(obj, self._name)(*self._args, **self._kwargs)
CPython versions tested on:
3.11, 3.12
Operating systems tested on:
macOS