-
Notifications
You must be signed in to change notification settings - Fork 6
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
Introspection capabilities are incomplete for C objects #32
Comments
Can Argument Clinic be seen as a practical solution for the specific case of function signatures? It generates a |
PyO3 has internal functionality in its Rust "procedural macros" which works very similarly to argument clinic, we generate a I would be very keen to have some support for annotations for "builtin" functions and methods defined via the C-API, I think the inability for PyO3 to add annotations (without us implementing custom callables, which we're not keen to do yet) is one of the biggest technical limitations in the C API which affects PyO3 users. The workaround is for them to maintain separate |
(Making |
I would be interested in solving this issue properly by making all callables reliably introspectible. I'm not sure though whether we should do it by extending |
|
I was thinking of making Signature a builtin (so it can be used without the inspect module). As long as we stick with the |
That may be a good idea. I guess we'd have to make other parts of the |
Note that most Python type checkers are static, so they're not going to import the code and access attributes to determine function signatures. This means you will still need Also note there are several kinds of signatures common in C callables that |
Yes, I think in PyO3's case the ideal outcome is that at build time the pyi can be generated and shipped in the wheel. |
On some attribute access. Is that much worse than the current solution with parsing the
This approach mixes support for optional typing hints and more basic support for introspection signatures in extension modules. Generally, there are no type annotations in the stdlib. Thus, generated here (by AC?) stub files will be useless for type checkers... |
For example, we have hacks that give us signatures of callables in some cases, but we cannot introspect signatures of vectorcall/fastcall functions. We should have a formal introspection protocol to reliably obtain the signature of any callable.
Similarly, other introspection hacks in the inspect module should be formalised and implemented reliably as part of the C api.
The text was updated successfully, but these errors were encountered: