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

Autogenerate signature for METH_NOARGS and perhaps METH_O extension functions #84805

Closed
anntzer mannequin opened this issue May 14, 2020 · 2 comments
Closed

Autogenerate signature for METH_NOARGS and perhaps METH_O extension functions #84805

anntzer mannequin opened this issue May 14, 2020 · 2 comments
Labels
3.13 new features, bugs and security fixes topic-C-API type-feature A feature request or enhancement

Comments

@anntzer
Copy link
Mannequin

anntzer mannequin commented May 14, 2020

BPO 40625
Nosy @anntzer

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-05-14.11:46:04.481>
labels = ['expert-C-API', '3.9']
title = 'Autogenerate signature for METH_NOARGS and perhaps METH_O extension functions'
updated_at = <Date 2020-05-14.11:46:04.481>
user = 'https://github.com/anntzer'

bugs.python.org fields:

activity = <Date 2020-05-14.11:46:04.481>
actor = 'Antony.Lee'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['C API']
creation = <Date 2020-05-14.11:46:04.481>
creator = 'Antony.Lee'
dependencies = []
files = []
hgrepos = []
issue_num = 40625
keywords = []
message_count = 1.0
messages = ['368830']
nosy_count = 1.0
nosy_names = ['Antony.Lee']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = None
url = 'https://bugs.python.org/issue40625'
versions = ['Python 3.9']

Linked PRs

@anntzer
Copy link
Mannequin Author

anntzer mannequin commented May 14, 2020

It would be nice if METH_NOARGS extension methods had an autogenerated signature (or rather, autogenerated __text_signature__ that gets picked up by inspect.signature). After all, the signature is trivially known at compile time.

The same could possibly be done for METH_O methods, for which the effective signature is known too. The name of the sole parameter is not known, but given that the parameter is (I believe?) positional only, that name "shouldn't" really matter (in the sense, e.g., that whether signature.bind() succeeds or not doesn't depend on the parameter name).

@anntzer anntzer mannequin added 3.9 only security fixes topic-C-API labels May 14, 2020
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
@iritkatriel iritkatriel added type-feature A feature request or enhancement 3.13 new features, bugs and security fixes and removed 3.9 only security fixes labels May 5, 2023
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Aug 9, 2023
@serhiy-storchaka
Copy link
Member

It is an interesting idea and I implemented it in #107794.

The one difference with Argument Clinic generated signature is that it names the first implicit argument $module in module-level functions and $self in unbound methods, while my PR use $self in both cases. But it does not matter, because it is always removed in module-level functions. The end user never sees a difference until it looks at __text_signature__ directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.13 new features, bugs and security fixes topic-C-API type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants