-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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 inspect.Signature.from_callable() #61575
Comments
While working on a subclass of inspect.Signature, I realized that inspect.signature is treated as the constructor. So subclassing isn't so simple. At first I considered adding an extra parameter to inspect.signature allowing different Signature classes. Not much later it became clear that all that code should simply be in classmethod. I've called it Signature.from_callable. Patch attached. |
Agree in general, but you need to update the docs also. |
Hi Eric, I'm not sure why do you want this. Having "Signature.from_callable" does not allow you to change behaviour of 'inspect.signature' function. More over, it creates a confusion about what API should be used - 'inspect.signature' or 'inspect.Signature.from_callable'. |
The difference is that inspect.signature is not friendly to Signature |
OK, suppose you have "Signature.from_callable". You then create a subclass |
Eric, Moreover, 'Signature.from_function' and newly added 'Signature.from_builtin' |
It's not about customizing inspect.signature. It's about customizing the |
OK, got it now. Green light from me. Looking through the code, I saw that 'from_builtin' doesn't use the 'Signature._parameter_cls' (as in from_function). That's probably needs to be fixed as well, maybe in a separate issue. |
New changeset 8a4e44473fdd by Yury Selivanov in branch 'default': |
Thanks, Yury! |
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: