-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Closed
Closed
Copy link
Labels
stdlibPython modules in the Lib dirPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
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
Linked PRs
Metadata
Metadata
Assignees
Labels
stdlibPython modules in the Lib dirPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error