-
Notifications
You must be signed in to change notification settings - Fork 85
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
Warn if "observe" decorator applied to method with only "self" #1428
Comments
One thing to watch out is that the inspection on callable arguments adds limitations on what kind of callables can be used.
Currently this works:
Calling |
Yes: I think it would be a warning, not an error, and we'd only issue the warning in the case that we could inspect the code - if we couldn't inspect the code we'd just let it pass. |
Having implemented a solution, I'm having second thoughts about this; it's a bit inefficient to be doing runtime type-checking for this. A static type-check may be a better solution. If we get the signature of |
Third thoughts: I think this is fine for the |
With the new 'observe' decorator, there's a potentially late-discovered bug that I've seen now in multiple different projects, and that's to forget to add the "event" argument on a previously argument-less
on_trait_change
target.It may be worth warning if the target of the "observe" decorator does not have exactly one positional argument in addition to "self".
The text was updated successfully, but these errors were encountered: