Skip to content

Autogenerate signature for METH_NOARGS and perhaps METH_O extension functions #84805

Closed

Description

@anntzer
mannequin
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

Activity

  1. anntzer commented on May 14, 2020

    anntzermannequin
    MannequinAuthor

    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).

  2. transferred this issue fromon Apr 10, 2022
  3. added
    type-featureA feature request or enhancement
    3.13only security fixes
    and removed on May 5, 2023
  4. added a commit that references this issue on Aug 9, 2023
  5. serhiy-storchaka commented on Aug 9, 2023

    @serhiy-storchaka
    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.

  6. added a commit that references this issue on Aug 11, 2023
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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions