Skip to content

Support operator module callables in inspect.signature #86951

Closed

Description

@plammens
mannequin
BPO 42785
Nosy @plammens

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2020-12-30.12:38:08.138>
labels = ['type-feature', 'library', '3.9']
title = 'Support operator module callables in inspect.signature'
updated_at = <Date 2020-12-30.12:39:03.612>
user = '/plammens'

bugs.python.org fields:

activity = <Date 2020-12-30.12:39:03.612>
actor = 'plammens'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2020-12-30.12:38:08.138>
creator = 'plammens'
dependencies = []
files = []
hgrepos = []
issue_num = 42785
keywords = []
message_count = 2.0
messages = ['384061', '384062']
nosy_count = 1.0
nosy_names = ['plammens']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue42785'
versions = ['Python 3.9']

Activity

  1. plammens commented on Dec 30, 2020

    plammensmannequin
    MannequinAuthor

    Currently, inspect.signature doesn't support all callables from the operator module, e.g. operator.attrgetter:

    >>> import inspect
    >>> import operator
    >>> inspect.signature(operator.attrgetter("spam"))
    ValueError: callable operator.attrgetter('is_host') is not supported by signature

    Support for this could be added either directly to inspect.signature or by adding __signature__ attributes to operator's classes.

  2. added
    stdlibStandard Library Python modules in the Lib/ directory
    type-featureA feature request or enhancement
    on Dec 30, 2020
  3. plammens commented on Dec 30, 2020

    plammensmannequin
    MannequinAuthor

    Correction:

    ValueError: callable operator.attrgetter('spam') is not supported by signature
    
  4. transferred this issue fromon Apr 10, 2022
  5. wRAR commented on Apr 4, 2024

    @wRAR

    Looks like this is fixed in Python 3.12:

    >>> import inspect
    >>> import operator
    >>> inspect.signature(operator.attrgetter("spam"))
    <Signature (*args, **kwargs)>
    
  6. wRAR commented on Apr 4, 2024

    @wRAR

    Specifically, it's fixed in the unreleased 3.12.3 (currently available in Debian unstable), probably by #116198

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.9 (EOL)end of lifestdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions