-
-
Notifications
You must be signed in to change notification settings - Fork 31k
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
Add introspection information for builtins #63873
Comments
Let's see if we can get introspection information for builtins using the Clinic for 3.4. Georg suggested part of the approach while we were hanging out in Tokyo. I'd considered it previously before but dispensed with the idea because it seemed too loopy. Actually it seems to work great. The approach:
Advantages of this approach:
Disadvantages of this approach:
The next step is probably to convert pydoc to use inspect.signature instead of the manky old methods it currently uses. After that, clean up the patch, and add a unit test or two. What do you think? |
If you review, you can ignore the changes to the .c files, those only got touched because of the new autogenerated "def (" lines in the docstrings. No other changes there. |
(Well, except for Object/methodobject.c.) |
I think there's a similar but slightly different convention in Sphinx |
I was deliberately trying to avoid something that a person might do by accident. Also, "def (" is consistently only five bytes, whereas "pterodactyl (" or whatever will often be much longer, in case static data size is a concern. But I could switch it to that if you think that's better. Certainly it's a tiny amount more readable. (I don't think this would make the docstrings compatible with sphinx autodoc though.) |
Sounds good to me (with either Larry's or Guido's spelling). We should ensure this still works with the config option that disables docstrings entirely. |
For Nick: "still works" as in the metadata is still available without docstrings or "still works" as in it won't crash? |
I changed it to "<callablename>(". Patch attached. Still works. |
"still works" as in "doesn't crash and the docstrings are still missing to |
Anybody have a better name for __textsig__ ? |
__signature_text__? __textsignature__? No need to abbreviate that much since there is no built-in function equivalent and people are not expected to work with it. |
I went with __text_signature__. I also did some more polishing, and added / fixed the unit tests, and even added a Misc/NEWS. Is it good enough to go in before the beta? |
+1 from me (I see this as the key benefit of argument clinic). For 3.5, we can look at ducktyping on the attribute, but for now I think |
Fresh patch attached. pydoc now uses inspect.signature instead of inspect.getfullargspec to generate the arguments for the function, and supports builtins. That's everything :D Planning on checking this in pretty soon, to get it in for beta (which hopefully still gets tagged today). |
New changeset 78ec18f5cb45 by Larry Hastings in branch 'default': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: