PyEMMA
PyEMMA copied to clipboard
Invoking parent classes constructors inconsistency because of super() usage
If a class in a hierarchy misses a call to super, eg. the most basic interface does not call super on object (which is pretty common in our code base), it is not ensured that in multi-inheritance (we use that a lot too) all constructors are being called. I'm currently not sure what the implications for PyEMMA are, but we should at least avoid this pattern completely or do it properly as may lead to uninitialized fields in the class tree, which can cause very subtle bugs.
Further reading: https://fuhm.net/super-harmful/
So what is the workaround that you would suggest for the moment to call methods from the superclass explicitly in a derived class? Just SuperClassName.method(self)? Should the same apply to __init__?
On 09/07/2017 11:25 AM, fabian-paul wrote:
So what is the workaround that you would suggest for the moment to call methods from the superclass explicitly in a derived class? Just |SuperClassName.method(self)|? Should the same apply to |init|?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/markovmodel/PyEMMA/issues/1153#issuecomment-327744661, or mute the thread https://github.com/notifications/unsubscribe-auth/AAKZL0duacAC8akFyOpuGd73T_9aUcUAks5sf7Z4gaJpZM4PHhdq.
Since using super correctly seems to be pretty hard, explicit calls should be easier. It also suits the Zen of Python.