absfuyu.core.decorator module

Absfuyu: Core

Decorator

Version: 5.1.0 Date updated: 10/03/2025 (dd/mm/yyyy)

absfuyu.core.decorator.dummy_decorator(obj: T) T[source]
absfuyu.core.decorator.dummy_decorator(obj: Callable[[P], R]) Callable[[P], R]

This is a decorator that does nothing. Normally used as a placeholder

absfuyu.core.decorator.dummy_decorator_with_args(*args, **kwargs)[source]

This is a decorator with args and kwargs that does nothing. Normally used as a placeholder

absfuyu.core.decorator.add_subclass_methods_decorator(cls: T) T[source]

Class decorator replace the __init_subclass__ method.

This method populates a dictionary with subclass names as keys and their available methods as values.

  • Create 2 class attributes: _METHOD_INCLUDE (bool) and SUBCLASS_METHODS (dict[str, list[str]])

  • Automatically add subclass methods to class variable: SUBCLASS_METHODS

  • Set class attribute _METHOD_INCLUDE to False to exclude from SUBCLASS_METHODS

Example:

>>> # Normal behavior
>>> @add_subclass_methods_decorator
>>> class TestParent: ...
>>> class TestChild(TestParent):
...     def method1(self): ...
>>> TestChild.SUBCLASS_METHODS
{'__main__.TestChild': ['method1']}
>>> # Hidden from ``SUBCLASS_METHODS``
>>> @add_subclass_methods_decorator
>>> class TestParent: ...
>>> class TestChildHidden(TestParent):
...     _METHOD_INCLUDE = False
...     def method1(self): ...
>>> TestChildHidden.SUBCLASS_METHODS
{}