Skip to content

Docs: incorrect signature for inspect.Signature.from_callable #112316

Description

@sobolevn

Bug report

.. classmethod:: Signature.from_callable(obj, *, follow_wrapped=True, globalns=None, localns=None)
Return a :class:`Signature` (or its subclass) object for a given callable
``obj``. Pass ``follow_wrapped=False`` to get a signature of ``obj``
without unwrapping its ``__wrapped__`` chain. ``globalns`` and
``localns`` will be used as the namespaces when resolving annotations.
This method simplifies subclassing of :class:`Signature`::
class MySignature(Signature):
pass
sig = MySignature.from_callable(min)
assert isinstance(sig, MySignature)
Its behavior is otherwise identical to that of :func:`signature`.
.. versionadded:: 3.5
.. versionadded:: 3.10
``globalns`` and ``localns`` parameters.

It has several problems:

  1. Two .. versionadded entries, one should be .. versionchanged instead
  2. eval_str is missing from the signature, here how it looks on 3.10+: https://github.com/python/cpython/blob/3.10/Lib/inspect.py#L2998C1-L3002
  3. eval_str is not documented

Linked PRs

Metadata

Metadata

Assignees

Labels

docsDocumentation in the Doc dirtype-bugAn unexpected behavior, bug, or error

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions