3 ms·
I recently encountered __init_subclass__ for the first time in Home Assistant's custom integrations. Configuration handlers were registerd by "just declaring th
by tsujamin 5y ago
I recently encountered __init_subclass__ for the first time in Home Assistant's custom integrations. Configuration handlers were registerd by "just declaring the class" like so and I couldn't grok how it was registered by the runtime
class MyCustomOptionsFlow(OptionsFlow, DOMAIN="MYPLUGIN"):...
A bit of digging showed that __init__subclass_ was being used effectively as a registration callback, adding the newly defined class/DOMAIN to the global CustomOptions handler at class definition.
Very neat, not immediately obvious however :/