-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
Incorrect description of the __signature__ attribute in docs #115937
Comments
Instead of rewriting the implementation in prose, another option is to word the recently added sentence more vague. Also, in the case of discrepancies between docs and implementation, we (almost) never align the code with the docs, as that in most cases is bound to be a breaking change. |
Explaining the current implementation as presented here, while it may not be the best choice for other reasons, is not very hard to explain in a simple manner.
inspect.signature then makes a signature object out of it. What would be weird though, is that there would be no documented way of turning a string like |
Isn't documentation expected to be as precise as possible?
Perhaps, this case is a special one.
For a background, new logic was introduced recently (since 3.12) in #100039. Maybe @ethanfurman could explain why parsing text signatures was chosen instead of using the Signature class in a pure-Python code? Recent discussion (https://discuss.python.org/t/43914/) reveals, that the
This forces us to document the format for the |
No, the style guide advises economy of expression:
|
This is an alternative to python#100168.
Hmm, I think we have a working alternative for #100168, that has no need in support callables or parsing text. There is also type check, added to solve #66000. I think, adding a setter method in typeobject.c might be an alternative.
That's hardly the case. Missing parts aren't just "corner cases" or something "complex". Logic is simple. Just... undocumented. |
I think that's what we should ascertain in the first place. Edit: it's actually not a breaking change, since a type check on
|
BTW, #115984 is in a simplest version. We could do proper deprecation for changes, introduced in the 3.12 release. |
…() docs Co-authored-by: Carol Willing <carolcode@willingconsulting.com> Co-authored-by: Gregory P. Smith <greg@krypto.org> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
#116086) Co-authored-by: Carol Willing <carolcode@willingconsulting.com> Co-authored-by: Gregory P. Smith <greg@krypto.org> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
…() docs (pythonGH-116086) (cherry picked from commit fb2e17b) Co-authored-by: Erlend E. Aasland <erlend@python.org> Co-authored-by: Carol Willing <carolcode@willingconsulting.com> Co-authored-by: Gregory P. Smith <greg@krypto.org> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
…() docs (pythonGH-116086) (cherry picked from commit fb2e17b) Co-authored-by: Erlend E. Aasland <erlend@python.org> Co-authored-by: Carol Willing <carolcode@willingconsulting.com> Co-authored-by: Gregory P. Smith <greg@krypto.org> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
…e() docs (GH-116086) (#116106) gh-115937: Remove implementation details from inspect.signature() docs (GH-116086) (cherry picked from commit fb2e17b) Co-authored-by: Erlend E. Aasland <erlend@python.org> Co-authored-by: Carol Willing <carolcode@willingconsulting.com> Co-authored-by: Gregory P. Smith <greg@krypto.org> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
…e() docs (GH-116086) (#116107) gh-115937: Remove implementation details from inspect.signature() docs (GH-116086) (cherry picked from commit fb2e17b) Co-authored-by: Erlend E. Aasland <erlend@python.org> Co-authored-by: Carol Willing <carolcode@willingconsulting.com> Co-authored-by: Gregory P. Smith <greg@krypto.org> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
@erlend-aasland, could you, please remove "bug" label? Apparently, parsing a string, taken from the |
…() docs (python#116086) Co-authored-by: Carol Willing <carolcode@willingconsulting.com> Co-authored-by: Gregory P. Smith <greg@krypto.org> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
…() docs (python#116086) Co-authored-by: Carol Willing <carolcode@willingconsulting.com> Co-authored-by: Gregory P. Smith <greg@krypto.org> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
…() docs (python#116086) Co-authored-by: Carol Willing <carolcode@willingconsulting.com> Co-authored-by: Gregory P. Smith <greg@krypto.org> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Bug report
Bug description:
Since #106311 its documented in the
inspect.signature()
sphinx docs as:"If the passed object has a
__signature__
attribute, this function returns it without further computations."That looks correct per PEP 362, see the implementation section. But actual code logic goes far away from this simple description:
cpython/Lib/inspect.py
Lines 2549 to 2562 in 8e8ab75
Either we should document this properly (then this is a documentation issue). Or we could change the code and remove undocumented logic. As this attribute was documented recently, I'll suggest the second option.
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
The text was updated successfully, but these errors were encountered: