Refactor type unions with ResultChatMemberUnion and ResultMenuButtonUnion

Replaced verbose type definitions of chat member and menu button unions with `ResultChatMemberUnion` and `ResultMenuButtonUnion` for improved readability and maintainability. Updated relevant methods, modules, and documentation to use the new type aliases consistently.
This commit is contained in:
JRoot Junior 2025-03-07 00:42:13 +02:00
parent f7c0e3d614
commit 28941439cf
No known key found for this signature in database
GPG key ID: 738964250D5FF6E2
11 changed files with 55 additions and 108 deletions

View file

@ -2,7 +2,7 @@
getChatAdministrators
#####################
Returns: :obj:`list[Union[ChatMemberOwner, ChatMemberAdministrator, ChatMemberMember, ChatMemberRestricted, ChatMemberLeft, ChatMemberBanned]]`
Returns: :obj:`list[ResultChatMemberUnion]`
.. automodule:: aiogram.methods.get_chat_administrators
:members:
@ -19,7 +19,7 @@ As bot method
.. code-block::
result: list[Union[ChatMemberOwner, ChatMemberAdministrator, ChatMemberMember, ChatMemberRestricted, ChatMemberLeft, ChatMemberBanned]] = await bot.get_chat_administrators(...)
result: list[ResultChatMemberUnion] = await bot.get_chat_administrators(...)
Method as object
@ -35,7 +35,7 @@ With specific bot
.. code-block:: python
result: list[Union[ChatMemberOwner, ChatMemberAdministrator, ChatMemberMember, ChatMemberRestricted, ChatMemberLeft, ChatMemberBanned]] = await bot(GetChatAdministrators(...))
result: list[ResultChatMemberUnion] = await bot(GetChatAdministrators(...))

View file

@ -2,7 +2,7 @@
getChatMember
#############
Returns: :obj:`Union[ChatMemberOwner, ChatMemberAdministrator, ChatMemberMember, ChatMemberRestricted, ChatMemberLeft, ChatMemberBanned]`
Returns: :obj:`ResultChatMemberUnion`
.. automodule:: aiogram.methods.get_chat_member
:members:
@ -19,7 +19,7 @@ As bot method
.. code-block::
result: Union[ChatMemberOwner, ChatMemberAdministrator, ChatMemberMember, ChatMemberRestricted, ChatMemberLeft, ChatMemberBanned] = await bot.get_chat_member(...)
result: ResultChatMemberUnion = await bot.get_chat_member(...)
Method as object
@ -35,7 +35,7 @@ With specific bot
.. code-block:: python
result: Union[ChatMemberOwner, ChatMemberAdministrator, ChatMemberMember, ChatMemberRestricted, ChatMemberLeft, ChatMemberBanned] = await bot(GetChatMember(...))
result: ResultChatMemberUnion = await bot(GetChatMember(...))

View file

@ -2,7 +2,7 @@
getChatMenuButton
#################
Returns: :obj:`Union[MenuButtonDefault, MenuButtonWebApp, MenuButtonCommands]`
Returns: :obj:`ResultMenuButtonUnion`
.. automodule:: aiogram.methods.get_chat_menu_button
:members:
@ -19,7 +19,7 @@ As bot method
.. code-block::
result: Union[MenuButtonDefault, MenuButtonWebApp, MenuButtonCommands] = await bot.get_chat_menu_button(...)
result: ResultMenuButtonUnion = await bot.get_chat_menu_button(...)
Method as object
@ -35,4 +35,4 @@ With specific bot
.. code-block:: python
result: Union[MenuButtonDefault, MenuButtonWebApp, MenuButtonCommands] = await bot(GetChatMenuButton(...))
result: ResultMenuButtonUnion = await bot(GetChatMenuButton(...))