-
-
Notifications
You must be signed in to change notification settings - Fork 98
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 a method to get a Callable's argument count #8596
Comments
This comment was marked as off-topic.
This comment was marked as off-topic.
@IntangibleMatter Please don't bump issues without contributing significant new information. Use the 👍 reaction button on the first post instead. |
Will take a look at possibly implementing this, will see how it goes |
Made quite a bit of progress, will probably open a PR soon |
This is already possible with the following code:
|
That doesn't cover everything, you can't use it for lambdas or for example, also it doesn't matter now since this has been added as a feature so you can just use the method |
Describe the project you are working on
Editor plugins
Describe the problem or limitation you are having in your project
Callable.unbind() allows unbinding a number of arguments, but there is no way to dynamically know how many arguments are allowed/should be unbound
Describe the feature / enhancement and how it helps to overcome the problem or limitation
A new method on Callable, called get_argument_count() or get_allowed_arguments_count() that returns the number of arguments allowed by the callable
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Here are 2 example usages:
To unbind some unknown Callable for a signal:
Example of a reusable, JavaScript style, array mapper. Only possible if this is implemented (optional index and array)
Which could be used like so:
If this enhancement will not be used often, can it be worked around with a few lines of script?
It's only possible with known Callables, but it's not currently possible to implement something like the above utility function
Is there a reason why this should be core and not an add-on in the asset library?
I don't think an add-on can do this
The text was updated successfully, but these errors were encountered: