Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support operator module callables in inspect.signature #86951

Closed
plammens mannequin opened this issue Dec 30, 2020 · 4 comments
Closed

Support operator module callables in inspect.signature #86951

plammens mannequin opened this issue Dec 30, 2020 · 4 comments
Labels
3.9 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@plammens
Copy link
Mannequin

plammens mannequin commented Dec 30, 2020

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 = 'https://github.com/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']

@plammens
Copy link
Mannequin Author

plammens mannequin commented Dec 30, 2020

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.

@plammens plammens mannequin added 3.9 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Dec 30, 2020
@plammens
Copy link
Mannequin Author

plammens mannequin commented Dec 30, 2020

Correction:

ValueError: callable operator.attrgetter('spam') is not supported by signature

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
@wRAR
Copy link

wRAR commented Apr 4, 2024

Looks like this is fixed in Python 3.12:

>>> import inspect
>>> import operator
>>> inspect.signature(operator.attrgetter("spam"))
<Signature (*args, **kwargs)>

@wRAR
Copy link

wRAR commented Apr 4, 2024

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
Labels
3.9 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants