Closed woutdenolf closed 3 years ago
Probably yes. In fact, I incidentally spotted this warning code just yesterday and thought it would be time to act. :)
When a widget is derived from some other widget, that other, base widget must guarantee that all its method that are not marked as private (that is, have names beginning with _
) won't change. In the past, we have had problems with that so we decided to treat all widget classes as closed by default. The inspiration came from Kotlin, which -- unlike Java, where you can declare a class as final -- treats all classes as closed unless explicitly declared open.
This shouldn't have any consequences for you. You can mark any class as open by simply adding openclass=True
. By doing so, you declare that you'll respect backwards compatibility for all public methods, so your class is safe to derive from.
We, for instance, have lots of boiler code for learner in OWBaseLearner
(declared as class OWBaseLearner(OWWidget, metaclass=OWBaseLearnerMeta, openclass=True)
), projections have a base widget class OWProjectionWidgetBase(OWWidget, openclass=True)
, and so forth.
Perfect, openclass=True
is what I need.
https://github.com/biolab/orange-widget-base/blob/46873327908316435f0b4fdbd195aa64fdf9b8b1/orangewidget/widget.py#L376
Will this be enforced in the future and why?