jgdv.decorators.mixin

Classes

DelayMixin

TODO A Decorator for annotating a class with mixins

Mixin

Decorator to App/Prepend Mixins into the decorated class.

MixinNow

TODO The trigger for delayed mixins.

Module Contents

class jgdv.decorators.mixin.DelayMixin(keys, **kwargs)[source]

Bases: jgdv.decorators._core.DataDec

TODO A Decorator for annotating a class with mixins

Delays the construction of the True class until later, using @MixinNow

Parameters:

keys (str | list[str])

class jgdv.decorators.mixin.Mixin(
*mixins,
allow_inheritance=False,
silent=False,
)[source]

Bases: jgdv.decorators._core.MonotonicDec

Decorator to App/Prepend Mixins into the decorated class.

Converts:

class ClsName(mixins, Supers, Protocols, metaclass=MCls, **kwargs):...

into:

@Protocols(*ps)
@Mixin(*ms, None)
class ClsName(Supers): ...

(‘None’ is used to separate pre and post mixins)

Parameters:
  • mixins (jgdv.Maybe[type])

  • allow_inheritance (bool)

  • silent (bool)

_build_annotations_h(target, current) <Unknown>[source]

Given a list of the current annotation list, return its replacement

Parameters:
  • target (jgdv.decorators._interface.Decorable)

  • current (list)

Return type:

jgdv.Maybe[list]

_validate_mixins() <Unknown>[source]
Return type:

None

_validate_target_h(
target,
form,
args=None,
) <Unknown>[source]

Abstract class for specialization. Given the original target, throw an error here if it isn’t ‘correct’ in some way

Parameters:
Return type:

None

_wrap_class_h(cls) <Unknown>[source]

Override this to decorate a class

Parameters:

cls (jgdv.decorators._interface.Decorable)

Return type:

jgdv.decorators._interface.Decorated

__builder: ClassVar[jgdv.mixins.annotate.Subclasser]
_name_mod = 'M'
_silent = False
needs_args = True
class jgdv.decorators.mixin.MixinNow(
*args,
prefix=None,
mark=None,
data=None,
)[source]

Bases: jgdv.decorators._core.MonotonicDec

TODO The trigger for delayed mixins.

After using @DelayMixin, trigger the True class using this.

eg:

@MixinNow
@DelayMixin(m3, None, m4)
@DelayMixin(m1, m2)
class Blah:...
Parameters:
  • args (Any)

  • prefix (jgdv.Maybe[str])

  • mark (jgdv.Maybe[str])

  • data (jgdv.Maybe[str])