diff --git a/ovos_workshop/skills/fallback.py b/ovos_workshop/skills/fallback.py index f4d67e08..963f65ae 100644 --- a/ovos_workshop/skills/fallback.py +++ b/ovos_workshop/skills/fallback.py @@ -61,25 +61,22 @@ class FallbackSkill(_MetaFB, metaclass=_MutableFallback): A Fallback can either observe or consume an utterance. A consumed utterance will not be seen by any other Fallback handlers. """ + def __new__classic__(cls, *args, **kwargs): + if cls is FallbackSkill: + # direct instantiation of class, dynamic wizardry for unittests + # return V2 as expected, V1 will eventually be dropped + return FallbackSkillV2(*args, **kwargs) + cls.__bases__ = (FallbackSkillV1, FallbackSkill, _MetaFB) + return super().__new__(cls, *args, **kwargs) - @staticmethod - def __get_bases_classic(): - LOG.debug("Using V1 Fallback") - return (FallbackSkillV1, FallbackSkill, _MetaFB) - - @backwards_compat(classic_core=__get_bases_classic, - pre_008=__get_bases_classic) - @staticmethod - def __get_bases(): - LOG.debug("Using V2 Fallback") - return (FallbackSkillV2, FallbackSkill, _MetaFB) - + @backwards_compat(classic_core=__new__classic__, + pre_008=__new__classic__) def __new__(cls, *args, **kwargs): if cls is FallbackSkill: - # direct instantiation of class, dynamic wizardry or unittests + # direct instantiation of class, dynamic wizardry for unittests # return V2 as expected, V1 will eventually be dropped return FallbackSkillV2(*args, **kwargs) - cls.__bases__ = cls.__get_bases() + cls.__bases__ = (FallbackSkillV2, FallbackSkill, _MetaFB) return super().__new__(cls, *args, **kwargs) @classmethod