Skip to content

Convert the struct module to use the Argument Clinic#143672

@skirpichev

Description

@skirpichev

Feature or enhancement

Proposal:

This is partially done, but some functions/methods aren't converted. Perhaps, due to missing support for starargs / var-positional parameters. Now it's possible. This also will fix some signatures.

>>> import inspect, struct >>> help(struct.pack) Help on built-in function pack in module _struct: pack(...) pack(format, v1, v2, ...) -> bytes Return a bytes object containing the values v1, v2, ... packed according to the format string. See help(struct) for more on format strings. >>> inspect.signature(struct.pack) Traceback (most recent call last): File "<python-input-6>", line 1, in <module> inspect.signature(struct.pack) ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^ File "/usr/local/lib/python3.15/inspect.py", line 3346, in signature return Signature.from_callable(obj, follow_wrapped=follow_wrapped, ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ globals=globals, locals=locals, eval_str=eval_str, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ annotation_format=annotation_format) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.15/inspect.py", line 3061, in from_callable return _signature_from_callable(obj, sigcls=cls, follow_wrapper_chains=follow_wrapped, globals=globals, locals=locals, eval_str=eval_str, annotation_format=annotation_format) File "/usr/local/lib/python3.15/inspect.py", line 2542, in _signature_from_callable return _signature_from_builtin(sigcls, obj, skip_bound_arg=skip_bound_arg) File "/usr/local/lib/python3.15/inspect.py", line 2326, in _signature_from_builtin raise ValueError("no signature found for builtin{!r}".format(func)) ValueError: no signature found for builtin <built-in function pack>

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions