bluesky / ophyd

hardware abstraction in Python with an emphasis on EPICS
https://blueskyproject.io/ophyd
BSD 3-Clause "New" or "Revised" License
51 stars 79 forks source link

Fix for issue 1184 #1185

Open mguijarr opened 7 months ago

mguijarr commented 7 months ago

Following comment by @cappel89 , this MR proposes to define PositionerBase as an abstract class.

This way, it would not be needed to mention move() method needs to be overwritten in a specific way, while still having a default implementation that can be called in subclasses (must be done explicitely). Same with .egu property, no need to ask developer to overwrite it -> it would be done automatically by Python...

What do you think ?

tacaswell commented 7 months ago

If I recall correctly, when we started working on ophyd we were using a metaclass for Device and multi-inherentance involving multiple-metaclasses results in Python telling you it is too complicated and refusing to do it. I think you could do it by making a MI meta-class of the meta-classes and then using that as the meta-class on the normally-MI'd class or something like that....so we chose to not use the second meta-class! When the subclass init hook became available we switch to using that (in the spirit of using the simplest language features we needed to get what we wanted) so I think that is why this now works.