-
Notifications
You must be signed in to change notification settings - Fork 3
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
Allow Scan
to take no parameters
#62
Comments
It is intended that methods of |
It was my understanding that on My aim is really just to have that method be picked up as a |
Ah I see. No it does not find fields that are So, if you want to do this dynamically from a CLI argument you would need to make a method (or a Callable) in |
Initially I misread and did something like self.fastcs_method = Scan(self.update, poll_period) in # Globally
PandaController.update.fastcs_method = Scan(PandaController.update, 0.1) Works and sets up the scan correctly - the signature parameters see EditI can get around it with the following: class Updater:
fastcs_method = Scan(PandaController.update, poll_period)
self.updater = Updater() |
Can you not just do |
Unfortunately not, you can't add attributes to methods on objects, only methods on classes: from pprint import pprint
class Foo:
def bar(self):
pass
setattr(Foo.bar, "some_string", "meh")
setattr(Foo().bar, "some_string", "meh") # Raises attribute error |
Ah, right. You can do
but that is pretty horrible. I have recently tried refactoring this so that the decorator replaces the method with a callable
|
Currently
Scan
is only validating correctly if initialised through thescan
decorator:FastCS/src/fastcs/cs_methods.py
Lines 60 to 61 in bdab4fa
This is because
inspect.Signature.parameters
will ignoreself
, but not in the wrapped case:gives us
I would like to be able to pass a poll period into my controller at init time
but this leads to no
parameters
and the check above failing because the expectedself
argument isn't present.Suggestion
Change
FastCS/src/fastcs/cs_methods.py
Lines 60 to 61 in bdab4fa
to
The text was updated successfully, but these errors were encountered: