mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Move StatesGroup.get_root() from meta to class
This commit is contained in:
parent
07f5e50a68
commit
f2684e6e84
1 changed files with 6 additions and 7 deletions
|
|
@ -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__
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue