Skip to content

Commit

Permalink
more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl committed Sep 21, 2023
1 parent 061914b commit 7c50de2
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions ovos_workshop/skills/fallback.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7c50de2

Please sign in to comment.