-
Notifications
You must be signed in to change notification settings - Fork 42
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
ASI does not use abc.SerialDeviceMixIn #297
Comments
Probably just my incompetence. I have no idea why I didn't start with the SerialDeviceMixin. I will investigate. Will also need to change the ludl code as well. |
At some point, things start becoming personal preference, but I really think that having device classes subclassing from Asked by email:
Currently, the documentation for creating new devices has:
Which I think makes things quite simple, even if sometimes a bit more verbose. I suggest
The sending of commands and parsing of the reply, with any weirdnesses of it, are contained in the With regards to locking, there is |
That is clear. Thanks. Just to summarize and for my own clarification cause when I was looking into this concepts it was never clear to me how python implements inheritance and mixins. My takeaway was that python does not explicitly implement this difference. From what I could see, and you are confirming, is that there are different ways to implement this.
class Device():
...
class SerialMixIn()
...
class MyController(Device, SerialMixIn):
...
class Device():
...
class SerialMixIn()
...
class MyController(Device):
def __init__(conn_args):
self._conn = SerialMixIn(conn_args):
... Any other way to conceptualize these relationships? I think that for these use cases, using Protocol from the typing library might be an appropriate way to structure things. In this case the |
Python supports mixins simply because it supports multiple inheritance. In Python, a mixin is syntactically no different from other classes but while the "normal" classes represent an object on themselves that make sense to create, a mixin class make no sense on their own and if you instantiate an object of the mixin class you will get something that is not useful.
Juts a minor issue: in the composition case it is no longer a "MixIn", it would be a
I would split things a bit more. If you look into the Toptica iBeam code, the |
Is there any reason why the MS2000 is not using the abc.SerialDeviceMixin?
I saw the deprecation warning on the abc.SerialDeviceMixin but I don't really understand it. Aren't mixin classes for composition? Is this deprecation warning from a time where the SerialDevice was not a mixin yet?
The text was updated successfully, but these errors were encountered: