From f2684e6e84fd22c7916fc2c9894b2e7b1589b7bc Mon Sep 17 00:00:00 2001 From: Alex Root Junior Date: Mon, 19 Apr 2021 01:50:45 +0300 Subject: [PATCH] Move StatesGroup.get_root() from meta to class --- aiogram/dispatcher/fsm/state.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/aiogram/dispatcher/fsm/state.py b/aiogram/dispatcher/fsm/state.py index c0814589..4d03c042 100644 --- a/aiogram/dispatcher/fsm/state.py +++ b/aiogram/dispatcher/fsm/state.py @@ -110,12 +110,6 @@ class StatesGroupMeta(type): def __all_states_names__(cls) -> Tuple[str, ...]: return tuple(state.state for state in cls.__all_states__ if state.state) - @no_type_check - def get_root(cls) -> "StatesGroup": - if cls.__parent__ is None: - return cls - return cls.__parent__.get_root() - def __contains__(cls, item: Any) -> bool: if isinstance(item, str): return item in cls.__all_states_names__ @@ -130,7 +124,12 @@ class StatesGroupMeta(type): class StatesGroup(metaclass=StatesGroupMeta): - pass + @classmethod + def get_root(cls) -> Type["StatesGroup"]: + if cls.__parent__ is None: + return cls + return cls.__parent__.get_root() + # def __call__(cls, event: TelegramObject, raw_state: Optional[str] = None) -> bool: # return raw_state in cls.__all_states_names__