I am looking for practical and non-synthetic use cases of Python class decorators. So far, the only case which made sense to me is registering a class in a publisher-subscriber system, e.g. plugins or events, something like:
@register
class MyPlugin(Plugin):
pass
or
@recieves_notifications
class Console:
def print(self, text):
...
Any other sane cases I've been thinking of could have been built on top of inheritance, metaclasses or decorating methods. Could you please share any good (or bad!) examples of using class decorators?
Thank you!
ABCMeta
, not@abstractclass
class decorator.