Skip to content

Accept unknown kwargs in taurus mixin class constructors

Carlos Pascual requested to merge github/fork/cpascual/mixinkwargs into develop

BaseConfigurableClass, TaurusBaseComponent, TaurusBaseWidget and TaurusBaseWritableWidget are used as mixin classes, mostly with QtObject-derived classes.

In order to support cooperative multiple inheritance with the super() statement, they need to be able to accept unknown kwargs in their constructors. See: https://www.riverbankcomputing.com/static/Docs/PyQt5/multiinheritance.html

This allows the following pattern:

class Foo(QObject, TaurusBaseComponent):
    def __init__(self, bar=None, **kwargs):
        super(Foo, self).__init__(**kwargs)  # <- py2+py3
        # super().__init__(**kwargs)  # <- py3 only

        self.bar = bar

Merge request reports