From d9aa1bdafa24ecb3a4eba72b4dd59d252c28527b Mon Sep 17 00:00:00 2001 From: AdiGro Date: Sat, 19 Oct 2024 09:23:56 +0200 Subject: [PATCH] move _has_redbot condition check under __init__ Class-level statements are executed when the class is defined, which will result in ImportError when RedCommandAdapter is defined despite redbot being optional. This moves the check under __init__ to prevent the same --- TagScriptEngine/adapter/redbotadapters.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/TagScriptEngine/adapter/redbotadapters.py b/TagScriptEngine/adapter/redbotadapters.py index bdbea23..f88f83c 100644 --- a/TagScriptEngine/adapter/redbotadapters.py +++ b/TagScriptEngine/adapter/redbotadapters.py @@ -23,13 +23,13 @@ class RedCommandAdapter(SimpleAdapter["Command"]): - if not _has_redbot: - raise ImportError("A Red-DiscordBot instance is required to use this.", name="redbot") - def __init__(self, base: Command, *, signature: Optional[str] = None) -> None: super().__init__(base=base) self.signature: Optional[str] = signature + if not _has_redbot: + raise ImportError("A Red-DiscordBot instance is required to use this.", name="redbot") + def update_attributes(self) -> None: command: Command = self.object self._attributes.update(