From 544a5d76acc1cbfa9cc41dd1429ac11dd6b5fee4 Mon Sep 17 00:00:00 2001 From: Daniel McKnight Date: Tue, 2 Jan 2024 11:57:45 -0800 Subject: [PATCH] More fallback init troubleshooting --- neon_utils/skills/neon_fallback_skill.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/neon_utils/skills/neon_fallback_skill.py b/neon_utils/skills/neon_fallback_skill.py index ca3cacb6..359aed29 100644 --- a/neon_utils/skills/neon_fallback_skill.py +++ b/neon_utils/skills/neon_fallback_skill.py @@ -42,7 +42,16 @@ class _MetaFB(OVOSSkill): """ -class NeonFallbackSkill(_MetaFB, FallbackSkillV1, NeonSkill): +class _MutableFallback(type(OVOSSkill)): + """ To override isinstance checks we need to use a metaclass """ + + def __instancecheck__(self, instance): + if isinstance(instance, FallbackSkillV1): + return True + return super().__instancecheck__(instance) + + +class NeonFallbackSkill(FallbackSkillV1, NeonSkill, metaclass=_MutableFallback): """ Class that extends the NeonSkill and FallbackSkill classes to provide NeonSkill functionality to any Fallback skill subclassing this class.