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

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

Closed
sobolevn opened this issue Nov 22, 2023 · 1 comment
Closed

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

sobolevn opened this issue Nov 22, 2023 · 1 comment
Assignees
Labels
docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error

Comments

@sobolevn
Copy link
Member

sobolevn commented Nov 22, 2023

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

@sobolevn sobolevn added type-bug An unexpected behavior, bug, or error docs Documentation in the Doc dir labels Nov 22, 2023
@sobolevn sobolevn self-assigned this Nov 22, 2023
@sobolevn
Copy link
Member Author

It is should be locals and globals, not localns and globalns

sobolevn added a commit to sobolevn/cpython that referenced this issue Nov 22, 2023
AlexWaygood added a commit that referenced this issue Dec 2, 2023
…llable` (#112317)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
AlexWaygood added a commit to AlexWaygood/cpython that referenced this issue Dec 2, 2023
…rom_callable` (python#112317)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
AlexWaygood added a commit that referenced this issue Dec 2, 2023
…from_callable` (#112317) (#112629)

gh-112316: Improve docs of `inspect.signature` and `Signature.from_callable` (#112317)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
AlexWaygood added a commit to AlexWaygood/cpython that referenced this issue Dec 2, 2023
…ature.from_callable` (python#112317)

(cherry-picked from commit a74daba)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
AlexWaygood added a commit that referenced this issue Dec 2, 2023
…from_callable` (#112317) (#112630)

(cherry-picked from commit a74daba)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
AlexWaygood added a commit to AlexWaygood/cpython that referenced this issue Dec 2, 2023
AlexWaygood added a commit to AlexWaygood/cpython that referenced this issue Dec 3, 2023
AlexWaygood added a commit that referenced this issue Dec 3, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Dec 3, 2023
…pect.Signature` (pythonGH-112631) (pythonGH-112649)

(cherry-picked from commit fc9e24b)
(cherry picked from commit 6221482)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
AlexWaygood added a commit that referenced this issue Dec 3, 2023
…spect.Signature` (GH-112631) (GH-112649) (#112652)

[3.12] gh-112316: improve docs for `inspect.signature` and `inspect.Signature` (GH-112631) (GH-112649)

(cherry-picked from commit fc9e24b)
(cherry picked from commit 6221482)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
aisk pushed a commit to aisk/cpython that referenced this issue Feb 11, 2024
…rom_callable` (python#112317)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
aisk pushed a commit to aisk/cpython that referenced this issue Feb 11, 2024
Glyphack pushed a commit to Glyphack/cpython that referenced this issue Sep 2, 2024
…rom_callable` (python#112317)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Glyphack pushed a commit to Glyphack/cpython that referenced this issue Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants