-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
__signature__ in the inspect module #106310
Comments
ncoghlan
pushed a commit
that referenced
this issue
Oct 20, 2023
Document the __signature__ attribute Co-authored-by: Alex Waygood <[email protected]>
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this issue
Oct 20, 2023
Document the __signature__ attribute (cherry picked from commit b07f232) Co-authored-by: Gouvernathor <[email protected]> Co-authored-by: Alex Waygood <[email protected]>
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this issue
Oct 20, 2023
Document the __signature__ attribute (cherry picked from commit b07f232) Co-authored-by: Gouvernathor <[email protected]> Co-authored-by: Alex Waygood <[email protected]>
hugovk
pushed a commit
that referenced
this issue
Oct 23, 2023
…111145) Co-authored-by: Gouvernathor <[email protected]> Co-authored-by: Alex Waygood <[email protected]>
hugovk
pushed a commit
that referenced
this issue
Oct 23, 2023
…111146) Co-authored-by: Gouvernathor <[email protected]> Co-authored-by: Alex Waygood <[email protected]>
aisk
pushed a commit
to aisk/cpython
that referenced
this issue
Feb 11, 2024
Document the __signature__ attribute Co-authored-by: Alex Waygood <[email protected]>
Glyphack
pushed a commit
to Glyphack/cpython
that referenced
this issue
Sep 2, 2024
Document the __signature__ attribute Co-authored-by: Alex Waygood <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Documentation
The
__signature__
attribute is treated by inspect.signature (and inspect.Signature.from_callable) as an override which is returned instead of computing the signature through the ordinary process.__text_signature__
serves a similar purpose but containing a string version of the signature.That's for the implementation.
None of the two are mentioned in the signature or Signature sections of the inspect module's doc page. However, the inspect.unwrap function's doc entry mentions, in an example, that inspect.signature does recognize the
__signature__
attribute, without saying what it does with it.This is the only mention of
__signature__
or__text_signature__
in the doc, excluding changelogs, whatsnew, and the Argument clinic section which is overtly implementation-dependent.However, it is also mentioned in the PEP 362 which introduced Signature, albeit in the Implementation section.
It should be clarified whether what
__signature__
does is documented or not. It's a very useful feature to be able to cache or lie about a function's signature, and I think it should be supported.If not, then inspect.unwrap should stop mentioning it and use another example.
Linked PRs
The text was updated successfully, but these errors were encountered: