From 703407b7aa234e0637b47187af32cb9da7ffc5c7 Mon Sep 17 00:00:00 2001 From: JRoot Junior Date: Thu, 6 Mar 2025 23:24:03 +0200 Subject: [PATCH] Refactor: Introduce Union types for streamlined type handling Implemented Union types across various modules to consolidate and simplify type annotations. This change replaces repetitive union declarations with reusable Union aliases, improving code readability and maintainability. Updates applied to affected classes, methods, and imports accordingly. --- aiogram/client/bot.py | 188 ++---------------- aiogram/methods/answer_inline_query.py | 76 +------ aiogram/methods/answer_web_app_query.py | 72 +------ aiogram/methods/delete_my_commands.py | 36 +--- aiogram/methods/edit_message_media.py | 22 +- aiogram/methods/get_my_commands.py | 37 +--- .../methods/save_prepared_inline_message.py | 70 +------ aiogram/methods/send_paid_media.py | 7 +- aiogram/methods/set_chat_menu_button.py | 10 +- aiogram/methods/set_message_reaction.py | 10 +- aiogram/methods/set_my_commands.py | 37 +--- aiogram/methods/set_passport_data_errors.py | 42 +--- aiogram/types/__init__.py | 44 ++++ aiogram/types/background_fill_union.py | 11 + aiogram/types/background_type_fill.py | 12 +- aiogram/types/background_type_pattern.py | 12 +- aiogram/types/background_type_union.py | 12 ++ aiogram/types/bot_command_scope_union.py | 23 +++ aiogram/types/callback_query.py | 9 +- aiogram/types/chat.py | 14 +- aiogram/types/chat_background.py | 24 +-- aiogram/types/chat_boost.py | 12 +- aiogram/types/chat_boost_removed.py | 12 +- aiogram/types/chat_boost_source_union.py | 11 + aiogram/types/chat_full_info.py | 14 +- aiogram/types/chat_id_union.py | 5 + aiogram/types/chat_member_union.py | 19 ++ aiogram/types/chat_member_updated.py | 43 +--- aiogram/types/date_time_union.py | 6 + aiogram/types/external_reply_info.py | 15 +- aiogram/types/inaccessible_message.py | 7 +- aiogram/types/inline_query.py | 48 +---- aiogram/types/inline_query_result_article.py | 24 +-- aiogram/types/inline_query_result_audio.py | 26 +-- .../types/inline_query_result_cached_audio.py | 26 +-- .../inline_query_result_cached_document.py | 26 +-- .../types/inline_query_result_cached_gif.py | 26 +-- .../inline_query_result_cached_mpeg4_gif.py | 26 +-- .../types/inline_query_result_cached_photo.py | 26 +-- .../inline_query_result_cached_sticker.py | 28 +-- .../types/inline_query_result_cached_video.py | 26 +-- .../types/inline_query_result_cached_voice.py | 26 +-- aiogram/types/inline_query_result_contact.py | 28 +-- aiogram/types/inline_query_result_document.py | 26 +-- aiogram/types/inline_query_result_gif.py | 26 +-- aiogram/types/inline_query_result_location.py | 28 +-- .../types/inline_query_result_mpeg4_gif.py | 26 +-- aiogram/types/inline_query_result_photo.py | 26 +-- aiogram/types/inline_query_result_union.py | 47 +++++ aiogram/types/inline_query_result_venue.py | 28 +-- aiogram/types/inline_query_result_video.py | 26 +-- aiogram/types/inline_query_result_voice.py | 26 +-- aiogram/types/input_file_union.py | 7 + aiogram/types/input_media_union.py | 13 ++ aiogram/types/input_message_content_union.py | 17 ++ aiogram/types/input_paid_media_union.py | 8 + aiogram/types/input_poll_option_union.py | 7 + .../types/maybe_inaccessible_message_union.py | 8 + aiogram/types/menu_button_union.py | 9 + aiogram/types/message.py | 49 ++--- aiogram/types/message_origin_union.py | 12 ++ aiogram/types/message_reaction_updated.py | 18 +- aiogram/types/paid_media_info.py | 10 +- aiogram/types/paid_media_union.py | 9 + aiogram/types/passport_element_error_union.py | 27 +++ aiogram/types/reaction_count.py | 10 +- aiogram/types/reaction_type_union.py | 9 + aiogram/types/reply_markup_union.py | 12 ++ .../types/revenue_withdrawal_state_union.py | 11 + aiogram/types/star_transaction.py | 60 +----- aiogram/types/transaction_partner_fragment.py | 22 +- aiogram/types/transaction_partner_union.py | 21 ++ aiogram/types/transaction_partner_user.py | 12 +- 73 files changed, 560 insertions(+), 1298 deletions(-) create mode 100644 aiogram/types/background_fill_union.py create mode 100644 aiogram/types/background_type_union.py create mode 100644 aiogram/types/bot_command_scope_union.py create mode 100644 aiogram/types/chat_boost_source_union.py create mode 100644 aiogram/types/chat_id_union.py create mode 100644 aiogram/types/chat_member_union.py create mode 100644 aiogram/types/date_time_union.py create mode 100644 aiogram/types/inline_query_result_union.py create mode 100644 aiogram/types/input_file_union.py create mode 100644 aiogram/types/input_media_union.py create mode 100644 aiogram/types/input_message_content_union.py create mode 100644 aiogram/types/input_paid_media_union.py create mode 100644 aiogram/types/input_poll_option_union.py create mode 100644 aiogram/types/maybe_inaccessible_message_union.py create mode 100644 aiogram/types/menu_button_union.py create mode 100644 aiogram/types/message_origin_union.py create mode 100644 aiogram/types/paid_media_union.py create mode 100644 aiogram/types/passport_element_error_union.py create mode 100644 aiogram/types/reaction_type_union.py create mode 100644 aiogram/types/reply_markup_union.py create mode 100644 aiogram/types/revenue_withdrawal_state_union.py create mode 100644 aiogram/types/transaction_partner_union.py diff --git a/aiogram/client/bot.py b/aiogram/client/bot.py index f3e859f5..22da5154 100644 --- a/aiogram/client/bot.py +++ b/aiogram/client/bot.py @@ -161,13 +161,7 @@ from ..methods import ( ) from ..types import ( BotCommand, - BotCommandScopeAllChatAdministrators, - BotCommandScopeAllGroupChats, - BotCommandScopeAllPrivateChats, - BotCommandScopeChat, - BotCommandScopeChatAdministrators, - BotCommandScopeChatMember, - BotCommandScopeDefault, + BotCommandScopeUnion, BotDescription, BotName, BotShortDescription, @@ -189,35 +183,15 @@ from ..types import ( GameHighScore, Gifts, InlineKeyboardMarkup, - InlineQueryResultArticle, - InlineQueryResultAudio, - InlineQueryResultCachedAudio, - InlineQueryResultCachedDocument, - InlineQueryResultCachedGif, - InlineQueryResultCachedMpeg4Gif, - InlineQueryResultCachedPhoto, - InlineQueryResultCachedSticker, - InlineQueryResultCachedVideo, - InlineQueryResultCachedVoice, - InlineQueryResultContact, - InlineQueryResultDocument, - InlineQueryResultGame, - InlineQueryResultGif, - InlineQueryResultLocation, - InlineQueryResultMpeg4Gif, - InlineQueryResultPhoto, InlineQueryResultsButton, - InlineQueryResultVenue, - InlineQueryResultVideo, - InlineQueryResultVoice, + InlineQueryResultUnion, InputFile, - InputMediaAnimation, InputMediaAudio, InputMediaDocument, InputMediaPhoto, + InputMediaUnion, InputMediaVideo, - InputPaidMediaPhoto, - InputPaidMediaVideo, + InputPaidMediaUnion, InputPollOption, InputSticker, LabeledPrice, @@ -225,24 +199,15 @@ from ..types import ( MaskPosition, MenuButtonCommands, MenuButtonDefault, + MenuButtonUnion, MenuButtonWebApp, Message, MessageEntity, MessageId, - PassportElementErrorDataField, - PassportElementErrorFile, - PassportElementErrorFiles, - PassportElementErrorFrontSide, - PassportElementErrorReverseSide, - PassportElementErrorSelfie, - PassportElementErrorTranslationFile, - PassportElementErrorTranslationFiles, - PassportElementErrorUnspecified, + PassportElementErrorUnion, Poll, PreparedInlineMessage, - ReactionTypeCustomEmoji, - ReactionTypeEmoji, - ReactionTypePaid, + ReactionTypeUnion, ReplyKeyboardMarkup, ReplyKeyboardRemove, ReplyParameters, @@ -579,30 +544,7 @@ class Bot: async def answer_inline_query( self, inline_query_id: str, - results: list[ - Union[ - InlineQueryResultCachedAudio, - InlineQueryResultCachedDocument, - InlineQueryResultCachedGif, - InlineQueryResultCachedMpeg4Gif, - InlineQueryResultCachedPhoto, - InlineQueryResultCachedSticker, - InlineQueryResultCachedVideo, - InlineQueryResultCachedVoice, - InlineQueryResultArticle, - InlineQueryResultAudio, - InlineQueryResultContact, - InlineQueryResultGame, - InlineQueryResultDocument, - InlineQueryResultGif, - InlineQueryResultLocation, - InlineQueryResultMpeg4Gif, - InlineQueryResultPhoto, - InlineQueryResultVenue, - InlineQueryResultVideo, - InlineQueryResultVoice, - ] - ], + results: list[InlineQueryResultUnion], cache_time: Optional[int] = None, is_personal: Optional[bool] = None, next_offset: Optional[str] = None, @@ -700,28 +642,7 @@ class Bot: async def answer_web_app_query( self, web_app_query_id: str, - result: Union[ - InlineQueryResultCachedAudio, - InlineQueryResultCachedDocument, - InlineQueryResultCachedGif, - InlineQueryResultCachedMpeg4Gif, - InlineQueryResultCachedPhoto, - InlineQueryResultCachedSticker, - InlineQueryResultCachedVideo, - InlineQueryResultCachedVoice, - InlineQueryResultArticle, - InlineQueryResultAudio, - InlineQueryResultContact, - InlineQueryResultGame, - InlineQueryResultDocument, - InlineQueryResultGif, - InlineQueryResultLocation, - InlineQueryResultMpeg4Gif, - InlineQueryResultPhoto, - InlineQueryResultVenue, - InlineQueryResultVideo, - InlineQueryResultVoice, - ], + result: InlineQueryResultUnion, request_timeout: Optional[int] = None, ) -> SentWebAppMessage: """ @@ -1235,17 +1156,7 @@ class Bot: async def delete_my_commands( self, - scope: Optional[ - Union[ - BotCommandScopeDefault, - BotCommandScopeAllPrivateChats, - BotCommandScopeAllGroupChats, - BotCommandScopeAllChatAdministrators, - BotCommandScopeChat, - BotCommandScopeChatAdministrators, - BotCommandScopeChatMember, - ] - ] = None, + scope: Optional[BotCommandScopeUnion] = None, language_code: Optional[str] = None, request_timeout: Optional[int] = None, ) -> bool: @@ -1468,13 +1379,7 @@ class Bot: async def edit_message_media( self, - media: Union[ - InputMediaAnimation, - InputMediaDocument, - InputMediaAudio, - InputMediaPhoto, - InputMediaVideo, - ], + media: InputMediaUnion, business_connection_id: Optional[str] = None, chat_id: Optional[Union[int, str]] = None, message_id: Optional[int] = None, @@ -1875,17 +1780,7 @@ class Bot: async def get_my_commands( self, - scope: Optional[ - Union[ - BotCommandScopeDefault, - BotCommandScopeAllPrivateChats, - BotCommandScopeAllGroupChats, - BotCommandScopeAllChatAdministrators, - BotCommandScopeChat, - BotCommandScopeChatAdministrators, - BotCommandScopeChatMember, - ] - ] = None, + scope: Optional[BotCommandScopeUnion] = None, language_code: Optional[str] = None, request_timeout: Optional[int] = None, ) -> list[BotCommand]: @@ -3547,9 +3442,7 @@ class Bot: async def set_chat_menu_button( self, chat_id: Optional[int] = None, - menu_button: Optional[ - Union[MenuButtonCommands, MenuButtonWebApp, MenuButtonDefault] - ] = None, + menu_button: Optional[MenuButtonUnion] = None, request_timeout: Optional[int] = None, ) -> bool: """ @@ -3705,17 +3598,7 @@ class Bot: async def set_my_commands( self, commands: list[BotCommand], - scope: Optional[ - Union[ - BotCommandScopeDefault, - BotCommandScopeAllPrivateChats, - BotCommandScopeAllGroupChats, - BotCommandScopeAllChatAdministrators, - BotCommandScopeChat, - BotCommandScopeChatAdministrators, - BotCommandScopeChatMember, - ] - ] = None, + scope: Optional[BotCommandScopeUnion] = None, language_code: Optional[str] = None, request_timeout: Optional[int] = None, ) -> bool: @@ -3764,19 +3647,7 @@ class Bot: async def set_passport_data_errors( self, user_id: int, - errors: list[ - Union[ - PassportElementErrorDataField, - PassportElementErrorFrontSide, - PassportElementErrorReverseSide, - PassportElementErrorSelfie, - PassportElementErrorFile, - PassportElementErrorFiles, - PassportElementErrorTranslationFile, - PassportElementErrorTranslationFiles, - PassportElementErrorUnspecified, - ] - ], + errors: list[PassportElementErrorUnion], request_timeout: Optional[int] = None, ) -> bool: """ @@ -4612,9 +4483,7 @@ class Bot: self, chat_id: Union[int, str], message_id: int, - reaction: Optional[ - list[Union[ReactionTypeEmoji, ReactionTypeCustomEmoji, ReactionTypePaid]] - ] = None, + reaction: Optional[list[ReactionTypeUnion]] = None, is_big: Optional[bool] = None, request_timeout: Optional[int] = None, ) -> bool: @@ -4738,7 +4607,7 @@ class Bot: self, chat_id: Union[int, str], star_count: int, - media: list[Union[InputPaidMediaPhoto, InputPaidMediaVideo]], + media: list[InputPaidMediaUnion], business_connection_id: Optional[str] = None, payload: Optional[str] = None, caption: Optional[str] = None, @@ -4895,28 +4764,7 @@ class Bot: async def save_prepared_inline_message( self, user_id: int, - result: Union[ - InlineQueryResultCachedAudio, - InlineQueryResultCachedDocument, - InlineQueryResultCachedGif, - InlineQueryResultCachedMpeg4Gif, - InlineQueryResultCachedPhoto, - InlineQueryResultCachedSticker, - InlineQueryResultCachedVideo, - InlineQueryResultCachedVoice, - InlineQueryResultArticle, - InlineQueryResultAudio, - InlineQueryResultContact, - InlineQueryResultGame, - InlineQueryResultDocument, - InlineQueryResultGif, - InlineQueryResultLocation, - InlineQueryResultMpeg4Gif, - InlineQueryResultPhoto, - InlineQueryResultVenue, - InlineQueryResultVideo, - InlineQueryResultVoice, - ], + result: InlineQueryResultUnion, allow_user_chats: Optional[bool] = None, allow_bot_chats: Optional[bool] = None, allow_group_chats: Optional[bool] = None, diff --git a/aiogram/methods/answer_inline_query.py b/aiogram/methods/answer_inline_query.py index d30134e6..28848673 100644 --- a/aiogram/methods/answer_inline_query.py +++ b/aiogram/methods/answer_inline_query.py @@ -1,32 +1,10 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Optional, Union +from typing import TYPE_CHECKING, Any, Optional from pydantic import Field -from ..types import ( - InlineQueryResultArticle, - InlineQueryResultAudio, - InlineQueryResultCachedAudio, - InlineQueryResultCachedDocument, - InlineQueryResultCachedGif, - InlineQueryResultCachedMpeg4Gif, - InlineQueryResultCachedPhoto, - InlineQueryResultCachedSticker, - InlineQueryResultCachedVideo, - InlineQueryResultCachedVoice, - InlineQueryResultContact, - InlineQueryResultDocument, - InlineQueryResultGame, - InlineQueryResultGif, - InlineQueryResultLocation, - InlineQueryResultMpeg4Gif, - InlineQueryResultPhoto, - InlineQueryResultsButton, - InlineQueryResultVenue, - InlineQueryResultVideo, - InlineQueryResultVoice, -) +from ..types import InlineQueryResultsButton, InlineQueryResultUnion from .base import TelegramMethod @@ -44,30 +22,7 @@ class AnswerInlineQuery(TelegramMethod[bool]): inline_query_id: str """Unique identifier for the answered query""" - results: list[ - Union[ - InlineQueryResultCachedAudio, - InlineQueryResultCachedDocument, - InlineQueryResultCachedGif, - InlineQueryResultCachedMpeg4Gif, - InlineQueryResultCachedPhoto, - InlineQueryResultCachedSticker, - InlineQueryResultCachedVideo, - InlineQueryResultCachedVoice, - InlineQueryResultArticle, - InlineQueryResultAudio, - InlineQueryResultContact, - InlineQueryResultGame, - InlineQueryResultDocument, - InlineQueryResultGif, - InlineQueryResultLocation, - InlineQueryResultMpeg4Gif, - InlineQueryResultPhoto, - InlineQueryResultVenue, - InlineQueryResultVideo, - InlineQueryResultVoice, - ] - ] + results: list[InlineQueryResultUnion] """A JSON-serialized array of results for the inline query""" cache_time: Optional[int] = None """The maximum amount of time in seconds that the result of the inline query may be cached on the server. Defaults to 300.""" @@ -96,30 +51,7 @@ class AnswerInlineQuery(TelegramMethod[bool]): __pydantic__self__, *, inline_query_id: str, - results: list[ - Union[ - InlineQueryResultCachedAudio, - InlineQueryResultCachedDocument, - InlineQueryResultCachedGif, - InlineQueryResultCachedMpeg4Gif, - InlineQueryResultCachedPhoto, - InlineQueryResultCachedSticker, - InlineQueryResultCachedVideo, - InlineQueryResultCachedVoice, - InlineQueryResultArticle, - InlineQueryResultAudio, - InlineQueryResultContact, - InlineQueryResultGame, - InlineQueryResultDocument, - InlineQueryResultGif, - InlineQueryResultLocation, - InlineQueryResultMpeg4Gif, - InlineQueryResultPhoto, - InlineQueryResultVenue, - InlineQueryResultVideo, - InlineQueryResultVoice, - ] - ], + results: list[InlineQueryResultUnion], cache_time: Optional[int] = None, is_personal: Optional[bool] = None, next_offset: Optional[str] = None, diff --git a/aiogram/methods/answer_web_app_query.py b/aiogram/methods/answer_web_app_query.py index 4dc87ebd..edcbf7de 100644 --- a/aiogram/methods/answer_web_app_query.py +++ b/aiogram/methods/answer_web_app_query.py @@ -1,30 +1,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Union +from typing import TYPE_CHECKING, Any -from ..types import ( - InlineQueryResultArticle, - InlineQueryResultAudio, - InlineQueryResultCachedAudio, - InlineQueryResultCachedDocument, - InlineQueryResultCachedGif, - InlineQueryResultCachedMpeg4Gif, - InlineQueryResultCachedPhoto, - InlineQueryResultCachedSticker, - InlineQueryResultCachedVideo, - InlineQueryResultCachedVoice, - InlineQueryResultContact, - InlineQueryResultDocument, - InlineQueryResultGame, - InlineQueryResultGif, - InlineQueryResultLocation, - InlineQueryResultMpeg4Gif, - InlineQueryResultPhoto, - InlineQueryResultVenue, - InlineQueryResultVideo, - InlineQueryResultVoice, - SentWebAppMessage, -) +from ..types import InlineQueryResultUnion, SentWebAppMessage from .base import TelegramMethod @@ -40,28 +18,7 @@ class AnswerWebAppQuery(TelegramMethod[SentWebAppMessage]): web_app_query_id: str """Unique identifier for the query to be answered""" - result: Union[ - InlineQueryResultCachedAudio, - InlineQueryResultCachedDocument, - InlineQueryResultCachedGif, - InlineQueryResultCachedMpeg4Gif, - InlineQueryResultCachedPhoto, - InlineQueryResultCachedSticker, - InlineQueryResultCachedVideo, - InlineQueryResultCachedVoice, - InlineQueryResultArticle, - InlineQueryResultAudio, - InlineQueryResultContact, - InlineQueryResultGame, - InlineQueryResultDocument, - InlineQueryResultGif, - InlineQueryResultLocation, - InlineQueryResultMpeg4Gif, - InlineQueryResultPhoto, - InlineQueryResultVenue, - InlineQueryResultVideo, - InlineQueryResultVoice, - ] + result: InlineQueryResultUnion """A JSON-serialized object describing the message to be sent""" if TYPE_CHECKING: @@ -72,28 +29,7 @@ class AnswerWebAppQuery(TelegramMethod[SentWebAppMessage]): __pydantic__self__, *, web_app_query_id: str, - result: Union[ - InlineQueryResultCachedAudio, - InlineQueryResultCachedDocument, - InlineQueryResultCachedGif, - InlineQueryResultCachedMpeg4Gif, - InlineQueryResultCachedPhoto, - InlineQueryResultCachedSticker, - InlineQueryResultCachedVideo, - InlineQueryResultCachedVoice, - InlineQueryResultArticle, - InlineQueryResultAudio, - InlineQueryResultContact, - InlineQueryResultGame, - InlineQueryResultDocument, - InlineQueryResultGif, - InlineQueryResultLocation, - InlineQueryResultMpeg4Gif, - InlineQueryResultPhoto, - InlineQueryResultVenue, - InlineQueryResultVideo, - InlineQueryResultVoice, - ], + result: InlineQueryResultUnion, **__pydantic_kwargs: Any, ) -> None: # DO NOT EDIT MANUALLY!!! diff --git a/aiogram/methods/delete_my_commands.py b/aiogram/methods/delete_my_commands.py index e35ef67c..0d32d753 100644 --- a/aiogram/methods/delete_my_commands.py +++ b/aiogram/methods/delete_my_commands.py @@ -1,16 +1,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Optional, Union +from typing import TYPE_CHECKING, Any, Optional -from ..types import ( - BotCommandScopeAllChatAdministrators, - BotCommandScopeAllGroupChats, - BotCommandScopeAllPrivateChats, - BotCommandScopeChat, - BotCommandScopeChatAdministrators, - BotCommandScopeChatMember, - BotCommandScopeDefault, -) +from ..types import BotCommandScopeUnion from .base import TelegramMethod @@ -24,17 +16,7 @@ class DeleteMyCommands(TelegramMethod[bool]): __returning__ = bool __api_method__ = "deleteMyCommands" - scope: Optional[ - Union[ - BotCommandScopeDefault, - BotCommandScopeAllPrivateChats, - BotCommandScopeAllGroupChats, - BotCommandScopeAllChatAdministrators, - BotCommandScopeChat, - BotCommandScopeChatAdministrators, - BotCommandScopeChatMember, - ] - ] = None + scope: Optional[BotCommandScopeUnion] = None """A JSON-serialized object, describing scope of users for which the commands are relevant. Defaults to :class:`aiogram.types.bot_command_scope_default.BotCommandScopeDefault`.""" language_code: Optional[str] = None """A two-letter ISO 639-1 language code. If empty, commands will be applied to all users from the given scope, for whose language there are no dedicated commands""" @@ -46,17 +28,7 @@ class DeleteMyCommands(TelegramMethod[bool]): def __init__( __pydantic__self__, *, - scope: Optional[ - Union[ - BotCommandScopeDefault, - BotCommandScopeAllPrivateChats, - BotCommandScopeAllGroupChats, - BotCommandScopeAllChatAdministrators, - BotCommandScopeChat, - BotCommandScopeChatAdministrators, - BotCommandScopeChatMember, - ] - ] = None, + scope: Optional[BotCommandScopeUnion] = None, language_code: Optional[str] = None, **__pydantic_kwargs: Any, ) -> None: diff --git a/aiogram/methods/edit_message_media.py b/aiogram/methods/edit_message_media.py index 0e0a049b..bd0a616d 100644 --- a/aiogram/methods/edit_message_media.py +++ b/aiogram/methods/edit_message_media.py @@ -2,15 +2,7 @@ from __future__ import annotations from typing import TYPE_CHECKING, Any, Optional, Union -from ..types import ( - InlineKeyboardMarkup, - InputMediaAnimation, - InputMediaAudio, - InputMediaDocument, - InputMediaPhoto, - InputMediaVideo, - Message, -) +from ..types import InlineKeyboardMarkup, InputMediaUnion, Message from .base import TelegramMethod @@ -24,9 +16,7 @@ class EditMessageMedia(TelegramMethod[Union[Message, bool]]): __returning__ = Union[Message, bool] __api_method__ = "editMessageMedia" - media: Union[ - InputMediaAnimation, InputMediaDocument, InputMediaAudio, InputMediaPhoto, InputMediaVideo - ] + media: InputMediaUnion """A JSON-serialized object for a new media content of the message""" business_connection_id: Optional[str] = None """Unique identifier of the business connection on behalf of which the message to be edited was sent""" @@ -46,13 +36,7 @@ class EditMessageMedia(TelegramMethod[Union[Message, bool]]): def __init__( __pydantic__self__, *, - media: Union[ - InputMediaAnimation, - InputMediaDocument, - InputMediaAudio, - InputMediaPhoto, - InputMediaVideo, - ], + media: InputMediaUnion, business_connection_id: Optional[str] = None, chat_id: Optional[Union[int, str]] = None, message_id: Optional[int] = None, diff --git a/aiogram/methods/get_my_commands.py b/aiogram/methods/get_my_commands.py index b69d8c6b..c155f18f 100644 --- a/aiogram/methods/get_my_commands.py +++ b/aiogram/methods/get_my_commands.py @@ -1,17 +1,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Optional, Union +from typing import TYPE_CHECKING, Any, Optional -from ..types import ( - BotCommand, - BotCommandScopeAllChatAdministrators, - BotCommandScopeAllGroupChats, - BotCommandScopeAllPrivateChats, - BotCommandScopeChat, - BotCommandScopeChatAdministrators, - BotCommandScopeChatMember, - BotCommandScopeDefault, -) +from ..types import BotCommand, BotCommandScopeUnion from .base import TelegramMethod @@ -25,17 +16,7 @@ class GetMyCommands(TelegramMethod[list[BotCommand]]): __returning__ = list[BotCommand] __api_method__ = "getMyCommands" - scope: Optional[ - Union[ - BotCommandScopeDefault, - BotCommandScopeAllPrivateChats, - BotCommandScopeAllGroupChats, - BotCommandScopeAllChatAdministrators, - BotCommandScopeChat, - BotCommandScopeChatAdministrators, - BotCommandScopeChatMember, - ] - ] = None + scope: Optional[BotCommandScopeUnion] = None """A JSON-serialized object, describing scope of users. Defaults to :class:`aiogram.types.bot_command_scope_default.BotCommandScopeDefault`.""" language_code: Optional[str] = None """A two-letter ISO 639-1 language code or an empty string""" @@ -47,17 +28,7 @@ class GetMyCommands(TelegramMethod[list[BotCommand]]): def __init__( __pydantic__self__, *, - scope: Optional[ - Union[ - BotCommandScopeDefault, - BotCommandScopeAllPrivateChats, - BotCommandScopeAllGroupChats, - BotCommandScopeAllChatAdministrators, - BotCommandScopeChat, - BotCommandScopeChatAdministrators, - BotCommandScopeChatMember, - ] - ] = None, + scope: Optional[BotCommandScopeUnion] = None, language_code: Optional[str] = None, **__pydantic_kwargs: Any, ) -> None: diff --git a/aiogram/methods/save_prepared_inline_message.py b/aiogram/methods/save_prepared_inline_message.py index 07b53e34..aff799bc 100644 --- a/aiogram/methods/save_prepared_inline_message.py +++ b/aiogram/methods/save_prepared_inline_message.py @@ -1,28 +1,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Optional, Union +from typing import TYPE_CHECKING, Any, Optional -from ..types.inline_query_result_article import InlineQueryResultArticle -from ..types.inline_query_result_audio import InlineQueryResultAudio -from ..types.inline_query_result_cached_audio import InlineQueryResultCachedAudio -from ..types.inline_query_result_cached_document import InlineQueryResultCachedDocument -from ..types.inline_query_result_cached_gif import InlineQueryResultCachedGif -from ..types.inline_query_result_cached_mpeg4_gif import InlineQueryResultCachedMpeg4Gif -from ..types.inline_query_result_cached_photo import InlineQueryResultCachedPhoto -from ..types.inline_query_result_cached_sticker import InlineQueryResultCachedSticker -from ..types.inline_query_result_cached_video import InlineQueryResultCachedVideo -from ..types.inline_query_result_cached_voice import InlineQueryResultCachedVoice -from ..types.inline_query_result_contact import InlineQueryResultContact -from ..types.inline_query_result_document import InlineQueryResultDocument -from ..types.inline_query_result_game import InlineQueryResultGame -from ..types.inline_query_result_gif import InlineQueryResultGif -from ..types.inline_query_result_location import InlineQueryResultLocation -from ..types.inline_query_result_mpeg4_gif import InlineQueryResultMpeg4Gif -from ..types.inline_query_result_photo import InlineQueryResultPhoto -from ..types.inline_query_result_venue import InlineQueryResultVenue -from ..types.inline_query_result_video import InlineQueryResultVideo -from ..types.inline_query_result_voice import InlineQueryResultVoice -from ..types.prepared_inline_message import PreparedInlineMessage +from ..types import InlineQueryResultUnion, PreparedInlineMessage from .base import TelegramMethod @@ -38,28 +18,7 @@ class SavePreparedInlineMessage(TelegramMethod[PreparedInlineMessage]): user_id: int """Unique identifier of the target user that can use the prepared message""" - result: Union[ - InlineQueryResultCachedAudio, - InlineQueryResultCachedDocument, - InlineQueryResultCachedGif, - InlineQueryResultCachedMpeg4Gif, - InlineQueryResultCachedPhoto, - InlineQueryResultCachedSticker, - InlineQueryResultCachedVideo, - InlineQueryResultCachedVoice, - InlineQueryResultArticle, - InlineQueryResultAudio, - InlineQueryResultContact, - InlineQueryResultGame, - InlineQueryResultDocument, - InlineQueryResultGif, - InlineQueryResultLocation, - InlineQueryResultMpeg4Gif, - InlineQueryResultPhoto, - InlineQueryResultVenue, - InlineQueryResultVideo, - InlineQueryResultVoice, - ] + result: InlineQueryResultUnion """A JSON-serialized object describing the message to be sent""" allow_user_chats: Optional[bool] = None """Pass :code:`True` if the message can be sent to private chats with users""" @@ -78,28 +37,7 @@ class SavePreparedInlineMessage(TelegramMethod[PreparedInlineMessage]): __pydantic__self__, *, user_id: int, - result: Union[ - InlineQueryResultCachedAudio, - InlineQueryResultCachedDocument, - InlineQueryResultCachedGif, - InlineQueryResultCachedMpeg4Gif, - InlineQueryResultCachedPhoto, - InlineQueryResultCachedSticker, - InlineQueryResultCachedVideo, - InlineQueryResultCachedVoice, - InlineQueryResultArticle, - InlineQueryResultAudio, - InlineQueryResultContact, - InlineQueryResultGame, - InlineQueryResultDocument, - InlineQueryResultGif, - InlineQueryResultLocation, - InlineQueryResultMpeg4Gif, - InlineQueryResultPhoto, - InlineQueryResultVenue, - InlineQueryResultVideo, - InlineQueryResultVoice, - ], + result: InlineQueryResultUnion, allow_user_chats: Optional[bool] = None, allow_bot_chats: Optional[bool] = None, allow_group_chats: Optional[bool] = None, diff --git a/aiogram/methods/send_paid_media.py b/aiogram/methods/send_paid_media.py index ba7e1452..46cbffcc 100644 --- a/aiogram/methods/send_paid_media.py +++ b/aiogram/methods/send_paid_media.py @@ -5,8 +5,7 @@ from typing import TYPE_CHECKING, Any, Optional, Union from ..types import ( ForceReply, InlineKeyboardMarkup, - InputPaidMediaPhoto, - InputPaidMediaVideo, + InputPaidMediaUnion, Message, MessageEntity, ReplyKeyboardMarkup, @@ -30,7 +29,7 @@ class SendPaidMedia(TelegramMethod[Message]): """Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`). If the chat is a channel, all Telegram Star proceeds from this media will be credited to the chat's balance. Otherwise, they will be credited to the bot's balance.""" star_count: int """The number of Telegram Stars that must be paid to buy access to the media; 1-2500""" - media: list[Union[InputPaidMediaPhoto, InputPaidMediaVideo]] + media: list[InputPaidMediaUnion] """A JSON-serialized array describing the media to be sent; up to 10 items""" business_connection_id: Optional[str] = None """Unique identifier of the business connection on behalf of which the message will be sent""" @@ -66,7 +65,7 @@ class SendPaidMedia(TelegramMethod[Message]): *, chat_id: Union[int, str], star_count: int, - media: list[Union[InputPaidMediaPhoto, InputPaidMediaVideo]], + media: list[InputPaidMediaUnion], business_connection_id: Optional[str] = None, payload: Optional[str] = None, caption: Optional[str] = None, diff --git a/aiogram/methods/set_chat_menu_button.py b/aiogram/methods/set_chat_menu_button.py index 97515d5a..8ba8acc6 100644 --- a/aiogram/methods/set_chat_menu_button.py +++ b/aiogram/methods/set_chat_menu_button.py @@ -1,8 +1,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Optional, Union +from typing import TYPE_CHECKING, Any, Optional -from ..types import MenuButtonCommands, MenuButtonDefault, MenuButtonWebApp +from ..types import MenuButtonUnion from .base import TelegramMethod @@ -18,7 +18,7 @@ class SetChatMenuButton(TelegramMethod[bool]): chat_id: Optional[int] = None """Unique identifier for the target private chat. If not specified, default bot's menu button will be changed""" - menu_button: Optional[Union[MenuButtonCommands, MenuButtonWebApp, MenuButtonDefault]] = None + menu_button: Optional[MenuButtonUnion] = None """A JSON-serialized object for the bot's new menu button. Defaults to :class:`aiogram.types.menu_button_default.MenuButtonDefault`""" if TYPE_CHECKING: @@ -29,9 +29,7 @@ class SetChatMenuButton(TelegramMethod[bool]): __pydantic__self__, *, chat_id: Optional[int] = None, - menu_button: Optional[ - Union[MenuButtonCommands, MenuButtonWebApp, MenuButtonDefault] - ] = None, + menu_button: Optional[MenuButtonUnion] = None, **__pydantic_kwargs: Any, ) -> None: # DO NOT EDIT MANUALLY!!! diff --git a/aiogram/methods/set_message_reaction.py b/aiogram/methods/set_message_reaction.py index 923edaa8..cebfa9f5 100644 --- a/aiogram/methods/set_message_reaction.py +++ b/aiogram/methods/set_message_reaction.py @@ -1,6 +1,6 @@ from typing import TYPE_CHECKING, Any, Optional, Union -from ..types import ReactionTypeCustomEmoji, ReactionTypeEmoji, ReactionTypePaid +from ..types import ReactionTypeUnion from .base import TelegramMethod @@ -18,9 +18,7 @@ class SetMessageReaction(TelegramMethod[bool]): """Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)""" message_id: int """Identifier of the target message. If the message belongs to a media group, the reaction is set to the first non-deleted message in the group instead.""" - reaction: Optional[ - list[Union[ReactionTypeEmoji, ReactionTypeCustomEmoji, ReactionTypePaid]] - ] = None + reaction: Optional[list[ReactionTypeUnion]] = None """A JSON-serialized list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators. Paid reactions can't be used by bots.""" is_big: Optional[bool] = None """Pass :code:`True` to set the reaction with a big animation""" @@ -34,9 +32,7 @@ class SetMessageReaction(TelegramMethod[bool]): *, chat_id: Union[int, str], message_id: int, - reaction: Optional[ - list[Union[ReactionTypeEmoji, ReactionTypeCustomEmoji, ReactionTypePaid]] - ] = None, + reaction: Optional[list[ReactionTypeUnion]] = None, is_big: Optional[bool] = None, **__pydantic_kwargs: Any, ) -> None: diff --git a/aiogram/methods/set_my_commands.py b/aiogram/methods/set_my_commands.py index a8186c9b..5f9a0552 100644 --- a/aiogram/methods/set_my_commands.py +++ b/aiogram/methods/set_my_commands.py @@ -1,17 +1,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Optional, Union +from typing import TYPE_CHECKING, Any, Optional -from ..types import ( - BotCommand, - BotCommandScopeAllChatAdministrators, - BotCommandScopeAllGroupChats, - BotCommandScopeAllPrivateChats, - BotCommandScopeChat, - BotCommandScopeChatAdministrators, - BotCommandScopeChatMember, - BotCommandScopeDefault, -) +from ..types import BotCommand, BotCommandScopeUnion from .base import TelegramMethod @@ -27,17 +18,7 @@ class SetMyCommands(TelegramMethod[bool]): commands: list[BotCommand] """A JSON-serialized list of bot commands to be set as the list of the bot's commands. At most 100 commands can be specified.""" - scope: Optional[ - Union[ - BotCommandScopeDefault, - BotCommandScopeAllPrivateChats, - BotCommandScopeAllGroupChats, - BotCommandScopeAllChatAdministrators, - BotCommandScopeChat, - BotCommandScopeChatAdministrators, - BotCommandScopeChatMember, - ] - ] = None + scope: Optional[BotCommandScopeUnion] = None """A JSON-serialized object, describing scope of users for which the commands are relevant. Defaults to :class:`aiogram.types.bot_command_scope_default.BotCommandScopeDefault`.""" language_code: Optional[str] = None """A two-letter ISO 639-1 language code. If empty, commands will be applied to all users from the given scope, for whose language there are no dedicated commands""" @@ -50,17 +31,7 @@ class SetMyCommands(TelegramMethod[bool]): __pydantic__self__, *, commands: list[BotCommand], - scope: Optional[ - Union[ - BotCommandScopeDefault, - BotCommandScopeAllPrivateChats, - BotCommandScopeAllGroupChats, - BotCommandScopeAllChatAdministrators, - BotCommandScopeChat, - BotCommandScopeChatAdministrators, - BotCommandScopeChatMember, - ] - ] = None, + scope: Optional[BotCommandScopeUnion] = None, language_code: Optional[str] = None, **__pydantic_kwargs: Any, ) -> None: diff --git a/aiogram/methods/set_passport_data_errors.py b/aiogram/methods/set_passport_data_errors.py index 9d50ffae..73f2b92d 100644 --- a/aiogram/methods/set_passport_data_errors.py +++ b/aiogram/methods/set_passport_data_errors.py @@ -1,18 +1,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Union +from typing import TYPE_CHECKING, Any -from ..types import ( - PassportElementErrorDataField, - PassportElementErrorFile, - PassportElementErrorFiles, - PassportElementErrorFrontSide, - PassportElementErrorReverseSide, - PassportElementErrorSelfie, - PassportElementErrorTranslationFile, - PassportElementErrorTranslationFiles, - PassportElementErrorUnspecified, -) +from ..types import PassportElementErrorUnion from .base import TelegramMethod @@ -29,19 +19,7 @@ class SetPassportDataErrors(TelegramMethod[bool]): user_id: int """User identifier""" - errors: list[ - Union[ - PassportElementErrorDataField, - PassportElementErrorFrontSide, - PassportElementErrorReverseSide, - PassportElementErrorSelfie, - PassportElementErrorFile, - PassportElementErrorFiles, - PassportElementErrorTranslationFile, - PassportElementErrorTranslationFiles, - PassportElementErrorUnspecified, - ] - ] + errors: list[PassportElementErrorUnion] """A JSON-serialized array describing the errors""" if TYPE_CHECKING: @@ -52,19 +30,7 @@ class SetPassportDataErrors(TelegramMethod[bool]): __pydantic__self__, *, user_id: int, - errors: list[ - Union[ - PassportElementErrorDataField, - PassportElementErrorFrontSide, - PassportElementErrorReverseSide, - PassportElementErrorSelfie, - PassportElementErrorFile, - PassportElementErrorFiles, - PassportElementErrorTranslationFile, - PassportElementErrorTranslationFiles, - PassportElementErrorUnspecified, - ] - ], + errors: list[PassportElementErrorUnion], **__pydantic_kwargs: Any, ) -> None: # DO NOT EDIT MANUALLY!!! diff --git a/aiogram/types/__init__.py b/aiogram/types/__init__.py index 8966b4db..9a2a1ab7 100644 --- a/aiogram/types/__init__.py +++ b/aiogram/types/__init__.py @@ -7,10 +7,12 @@ from .background_fill import BackgroundFill from .background_fill_freeform_gradient import BackgroundFillFreeformGradient from .background_fill_gradient import BackgroundFillGradient from .background_fill_solid import BackgroundFillSolid +from .background_fill_union import BackgroundFillUnion from .background_type import BackgroundType from .background_type_chat_theme import BackgroundTypeChatTheme from .background_type_fill import BackgroundTypeFill from .background_type_pattern import BackgroundTypePattern +from .background_type_union import BackgroundTypeUnion from .background_type_wallpaper import BackgroundTypeWallpaper from .base import UNSET_PARSE_MODE, TelegramObject from .birthdate import Birthdate @@ -25,6 +27,7 @@ from .bot_command_scope_chat import BotCommandScopeChat from .bot_command_scope_chat_administrators import BotCommandScopeChatAdministrators from .bot_command_scope_chat_member import BotCommandScopeChatMember from .bot_command_scope_default import BotCommandScopeDefault +from .bot_command_scope_union import BotCommandScopeUnion from .bot_description import BotDescription from .bot_name import BotName from .bot_short_description import BotShortDescription @@ -46,8 +49,10 @@ from .chat_boost_source import ChatBoostSource from .chat_boost_source_gift_code import ChatBoostSourceGiftCode from .chat_boost_source_giveaway import ChatBoostSourceGiveaway from .chat_boost_source_premium import ChatBoostSourcePremium +from .chat_boost_source_union import ChatBoostSourceUnion from .chat_boost_updated import ChatBoostUpdated from .chat_full_info import ChatFullInfo +from .chat_id_union import ChatIdUnion from .chat_invite_link import ChatInviteLink from .chat_join_request import ChatJoinRequest from .chat_location import ChatLocation @@ -58,6 +63,7 @@ from .chat_member_left import ChatMemberLeft from .chat_member_member import ChatMemberMember from .chat_member_owner import ChatMemberOwner from .chat_member_restricted import ChatMemberRestricted +from .chat_member_union import ChatMemberUnion from .chat_member_updated import ChatMemberUpdated from .chat_permissions import ChatPermissions from .chat_photo import ChatPhoto @@ -66,6 +72,7 @@ from .chosen_inline_result import ChosenInlineResult from .contact import Contact from .copy_text_button import CopyTextButton from .custom import DateTime +from .date_time_union import DateTimeUnion from .dice import Dice from .document import Document from .downloadable import Downloadable @@ -112,12 +119,14 @@ from .inline_query_result_gif import InlineQueryResultGif from .inline_query_result_location import InlineQueryResultLocation from .inline_query_result_mpeg4_gif import InlineQueryResultMpeg4Gif from .inline_query_result_photo import InlineQueryResultPhoto +from .inline_query_result_union import InlineQueryResultUnion from .inline_query_result_venue import InlineQueryResultVenue from .inline_query_result_video import InlineQueryResultVideo from .inline_query_result_voice import InlineQueryResultVoice from .inline_query_results_button import InlineQueryResultsButton from .input_contact_message_content import InputContactMessageContent from .input_file import BufferedInputFile, FSInputFile, InputFile, URLInputFile +from .input_file_union import InputFileUnion from .input_invoice_message_content import InputInvoiceMessageContent from .input_location_message_content import InputLocationMessageContent from .input_media import InputMedia @@ -125,12 +134,16 @@ from .input_media_animation import InputMediaAnimation from .input_media_audio import InputMediaAudio from .input_media_document import InputMediaDocument from .input_media_photo import InputMediaPhoto +from .input_media_union import InputMediaUnion from .input_media_video import InputMediaVideo from .input_message_content import InputMessageContent +from .input_message_content_union import InputMessageContentUnion from .input_paid_media import InputPaidMedia from .input_paid_media_photo import InputPaidMediaPhoto +from .input_paid_media_union import InputPaidMediaUnion from .input_paid_media_video import InputPaidMediaVideo from .input_poll_option import InputPollOption +from .input_poll_option_union import InputPollOptionUnion from .input_sticker import InputSticker from .input_text_message_content import InputTextMessageContent from .input_venue_message_content import InputVenueMessageContent @@ -146,9 +159,11 @@ from .location import Location from .login_url import LoginUrl from .mask_position import MaskPosition from .maybe_inaccessible_message import MaybeInaccessibleMessage +from .maybe_inaccessible_message_union import MaybeInaccessibleMessageUnion from .menu_button import MenuButton from .menu_button_commands import MenuButtonCommands from .menu_button_default import MenuButtonDefault +from .menu_button_union import MenuButtonUnion from .menu_button_web_app import MenuButtonWebApp from .message import ContentType, Message from .message_auto_delete_timer_changed import MessageAutoDeleteTimerChanged @@ -158,6 +173,7 @@ from .message_origin import MessageOrigin from .message_origin_channel import MessageOriginChannel from .message_origin_chat import MessageOriginChat from .message_origin_hidden_user import MessageOriginHiddenUser +from .message_origin_union import MessageOriginUnion from .message_origin_user import MessageOriginUser from .message_reaction_count_updated import MessageReactionCountUpdated from .message_reaction_updated import MessageReactionUpdated @@ -167,6 +183,7 @@ from .paid_media_info import PaidMediaInfo from .paid_media_photo import PaidMediaPhoto from .paid_media_preview import PaidMediaPreview from .paid_media_purchased import PaidMediaPurchased +from .paid_media_union import PaidMediaUnion from .paid_media_video import PaidMediaVideo from .passport_data import PassportData from .passport_element_error import PassportElementError @@ -180,6 +197,7 @@ from .passport_element_error_translation_file import PassportElementErrorTransla from .passport_element_error_translation_files import ( PassportElementErrorTranslationFiles, ) +from .passport_element_error_union import PassportElementErrorUnion from .passport_element_error_unspecified import PassportElementErrorUnspecified from .passport_file import PassportFile from .photo_size import PhotoSize @@ -194,15 +212,18 @@ from .reaction_type import ReactionType from .reaction_type_custom_emoji import ReactionTypeCustomEmoji from .reaction_type_emoji import ReactionTypeEmoji from .reaction_type_paid import ReactionTypePaid +from .reaction_type_union import ReactionTypeUnion from .refunded_payment import RefundedPayment from .reply_keyboard_markup import ReplyKeyboardMarkup from .reply_keyboard_remove import ReplyKeyboardRemove +from .reply_markup_union import ReplyMarkupUnion from .reply_parameters import ReplyParameters from .response_parameters import ResponseParameters from .revenue_withdrawal_state import RevenueWithdrawalState from .revenue_withdrawal_state_failed import RevenueWithdrawalStateFailed from .revenue_withdrawal_state_pending import RevenueWithdrawalStatePending from .revenue_withdrawal_state_succeeded import RevenueWithdrawalStateSucceeded +from .revenue_withdrawal_state_union import RevenueWithdrawalStateUnion from .sent_web_app_message import SentWebAppMessage from .shared_user import SharedUser from .shipping_address import ShippingAddress @@ -223,6 +244,7 @@ from .transaction_partner_fragment import TransactionPartnerFragment from .transaction_partner_other import TransactionPartnerOther from .transaction_partner_telegram_ads import TransactionPartnerTelegramAds from .transaction_partner_telegram_api import TransactionPartnerTelegramApi +from .transaction_partner_union import TransactionPartnerUnion from .transaction_partner_user import TransactionPartnerUser from .update import Update from .user import User @@ -251,10 +273,12 @@ __all__ = ( "BackgroundFillFreeformGradient", "BackgroundFillGradient", "BackgroundFillSolid", + "BackgroundFillUnion", "BackgroundType", "BackgroundTypeChatTheme", "BackgroundTypeFill", "BackgroundTypePattern", + "BackgroundTypeUnion", "BackgroundTypeWallpaper", "Birthdate", "BotCommand", @@ -266,6 +290,7 @@ __all__ = ( "BotCommandScopeChatAdministrators", "BotCommandScopeChatMember", "BotCommandScopeDefault", + "BotCommandScopeUnion", "BotDescription", "BotName", "BotShortDescription", @@ -288,8 +313,10 @@ __all__ = ( "ChatBoostSourceGiftCode", "ChatBoostSourceGiveaway", "ChatBoostSourcePremium", + "ChatBoostSourceUnion", "ChatBoostUpdated", "ChatFullInfo", + "ChatIdUnion", "ChatInviteLink", "ChatJoinRequest", "ChatLocation", @@ -300,6 +327,7 @@ __all__ = ( "ChatMemberMember", "ChatMemberOwner", "ChatMemberRestricted", + "ChatMemberUnion", "ChatMemberUpdated", "ChatPermissions", "ChatPhoto", @@ -309,6 +337,7 @@ __all__ = ( "ContentType", "CopyTextButton", "DateTime", + "DateTimeUnion", "Dice", "Document", "Downloadable", @@ -356,12 +385,14 @@ __all__ = ( "InlineQueryResultLocation", "InlineQueryResultMpeg4Gif", "InlineQueryResultPhoto", + "InlineQueryResultUnion", "InlineQueryResultVenue", "InlineQueryResultVideo", "InlineQueryResultVoice", "InlineQueryResultsButton", "InputContactMessageContent", "InputFile", + "InputFileUnion", "InputInvoiceMessageContent", "InputLocationMessageContent", "InputMedia", @@ -369,12 +400,16 @@ __all__ = ( "InputMediaAudio", "InputMediaDocument", "InputMediaPhoto", + "InputMediaUnion", "InputMediaVideo", "InputMessageContent", + "InputMessageContentUnion", "InputPaidMedia", "InputPaidMediaPhoto", + "InputPaidMediaUnion", "InputPaidMediaVideo", "InputPollOption", + "InputPollOptionUnion", "InputSticker", "InputTextMessageContent", "InputVenueMessageContent", @@ -390,9 +425,11 @@ __all__ = ( "LoginUrl", "MaskPosition", "MaybeInaccessibleMessage", + "MaybeInaccessibleMessageUnion", "MenuButton", "MenuButtonCommands", "MenuButtonDefault", + "MenuButtonUnion", "MenuButtonWebApp", "Message", "MessageAutoDeleteTimerChanged", @@ -402,6 +439,7 @@ __all__ = ( "MessageOriginChannel", "MessageOriginChat", "MessageOriginHiddenUser", + "MessageOriginUnion", "MessageOriginUser", "MessageReactionCountUpdated", "MessageReactionUpdated", @@ -411,6 +449,7 @@ __all__ = ( "PaidMediaPhoto", "PaidMediaPreview", "PaidMediaPurchased", + "PaidMediaUnion", "PaidMediaVideo", "PassportData", "PassportElementError", @@ -422,6 +461,7 @@ __all__ = ( "PassportElementErrorSelfie", "PassportElementErrorTranslationFile", "PassportElementErrorTranslationFiles", + "PassportElementErrorUnion", "PassportElementErrorUnspecified", "PassportFile", "PhotoSize", @@ -436,15 +476,18 @@ __all__ = ( "ReactionTypeCustomEmoji", "ReactionTypeEmoji", "ReactionTypePaid", + "ReactionTypeUnion", "RefundedPayment", "ReplyKeyboardMarkup", "ReplyKeyboardRemove", + "ReplyMarkupUnion", "ReplyParameters", "ResponseParameters", "RevenueWithdrawalState", "RevenueWithdrawalStateFailed", "RevenueWithdrawalStatePending", "RevenueWithdrawalStateSucceeded", + "RevenueWithdrawalStateUnion", "SentWebAppMessage", "SharedUser", "ShippingAddress", @@ -466,6 +509,7 @@ __all__ = ( "TransactionPartnerOther", "TransactionPartnerTelegramAds", "TransactionPartnerTelegramApi", + "TransactionPartnerUnion", "TransactionPartnerUser", "UNSET_PARSE_MODE", "URLInputFile", diff --git a/aiogram/types/background_fill_union.py b/aiogram/types/background_fill_union.py new file mode 100644 index 00000000..cb54f511 --- /dev/null +++ b/aiogram/types/background_fill_union.py @@ -0,0 +1,11 @@ +from __future__ import annotations + +from typing import Union + +from .background_fill_freeform_gradient import BackgroundFillFreeformGradient +from .background_fill_gradient import BackgroundFillGradient +from .background_fill_solid import BackgroundFillSolid + +BackgroundFillUnion = Union[ + BackgroundFillSolid, BackgroundFillGradient, BackgroundFillFreeformGradient +] diff --git a/aiogram/types/background_type_fill.py b/aiogram/types/background_type_fill.py index c506e4ea..49f2767d 100644 --- a/aiogram/types/background_type_fill.py +++ b/aiogram/types/background_type_fill.py @@ -1,13 +1,11 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Literal, Union +from typing import TYPE_CHECKING, Any, Literal from .background_type import BackgroundType if TYPE_CHECKING: - from .background_fill_freeform_gradient import BackgroundFillFreeformGradient - from .background_fill_gradient import BackgroundFillGradient - from .background_fill_solid import BackgroundFillSolid + from .background_fill_union import BackgroundFillUnion class BackgroundTypeFill(BackgroundType): @@ -19,7 +17,7 @@ class BackgroundTypeFill(BackgroundType): type: Literal["fill"] = "fill" """Type of the background, always 'fill'""" - fill: Union[BackgroundFillSolid, BackgroundFillGradient, BackgroundFillFreeformGradient] + fill: BackgroundFillUnion """The background fill""" dark_theme_dimming: int """Dimming of the background in dark themes, as a percentage; 0-100""" @@ -32,9 +30,7 @@ class BackgroundTypeFill(BackgroundType): __pydantic__self__, *, type: Literal["fill"] = "fill", - fill: Union[ - BackgroundFillSolid, BackgroundFillGradient, BackgroundFillFreeformGradient - ], + fill: BackgroundFillUnion, dark_theme_dimming: int, **__pydantic_kwargs: Any, ) -> None: diff --git a/aiogram/types/background_type_pattern.py b/aiogram/types/background_type_pattern.py index 0c3ba3a3..f7e0b8cc 100644 --- a/aiogram/types/background_type_pattern.py +++ b/aiogram/types/background_type_pattern.py @@ -1,13 +1,11 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Literal, Optional, Union +from typing import TYPE_CHECKING, Any, Literal, Optional from .background_type import BackgroundType if TYPE_CHECKING: - from .background_fill_freeform_gradient import BackgroundFillFreeformGradient - from .background_fill_gradient import BackgroundFillGradient - from .background_fill_solid import BackgroundFillSolid + from .background_fill_union import BackgroundFillUnion from .document import Document @@ -22,7 +20,7 @@ class BackgroundTypePattern(BackgroundType): """Type of the background, always 'pattern'""" document: Document """Document with the pattern""" - fill: Union[BackgroundFillSolid, BackgroundFillGradient, BackgroundFillFreeformGradient] + fill: BackgroundFillUnion """The background fill that is combined with the pattern""" intensity: int """Intensity of the pattern when it is shown above the filled background; 0-100""" @@ -40,9 +38,7 @@ class BackgroundTypePattern(BackgroundType): *, type: Literal["pattern"] = "pattern", document: Document, - fill: Union[ - BackgroundFillSolid, BackgroundFillGradient, BackgroundFillFreeformGradient - ], + fill: BackgroundFillUnion, intensity: int, is_inverted: Optional[bool] = None, is_moving: Optional[bool] = None, diff --git a/aiogram/types/background_type_union.py b/aiogram/types/background_type_union.py new file mode 100644 index 00000000..66a2582d --- /dev/null +++ b/aiogram/types/background_type_union.py @@ -0,0 +1,12 @@ +from __future__ import annotations + +from typing import Union + +from .background_type_chat_theme import BackgroundTypeChatTheme +from .background_type_fill import BackgroundTypeFill +from .background_type_pattern import BackgroundTypePattern +from .background_type_wallpaper import BackgroundTypeWallpaper + +BackgroundTypeUnion = Union[ + BackgroundTypeFill, BackgroundTypeWallpaper, BackgroundTypePattern, BackgroundTypeChatTheme +] diff --git a/aiogram/types/bot_command_scope_union.py b/aiogram/types/bot_command_scope_union.py new file mode 100644 index 00000000..45788f94 --- /dev/null +++ b/aiogram/types/bot_command_scope_union.py @@ -0,0 +1,23 @@ +from __future__ import annotations + +from typing import Union + +from .bot_command_scope_all_chat_administrators import ( + BotCommandScopeAllChatAdministrators, +) +from .bot_command_scope_all_group_chats import BotCommandScopeAllGroupChats +from .bot_command_scope_all_private_chats import BotCommandScopeAllPrivateChats +from .bot_command_scope_chat import BotCommandScopeChat +from .bot_command_scope_chat_administrators import BotCommandScopeChatAdministrators +from .bot_command_scope_chat_member import BotCommandScopeChatMember +from .bot_command_scope_default import BotCommandScopeDefault + +BotCommandScopeUnion = Union[ + BotCommandScopeDefault, + BotCommandScopeAllPrivateChats, + BotCommandScopeAllGroupChats, + BotCommandScopeAllChatAdministrators, + BotCommandScopeChat, + BotCommandScopeChatAdministrators, + BotCommandScopeChatMember, +] diff --git a/aiogram/types/callback_query.py b/aiogram/types/callback_query.py index c3b33b5f..d976c1b8 100644 --- a/aiogram/types/callback_query.py +++ b/aiogram/types/callback_query.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Optional, Union +from typing import TYPE_CHECKING, Any, Optional from pydantic import Field @@ -8,8 +8,7 @@ from .base import TelegramObject if TYPE_CHECKING: from ..methods import AnswerCallbackQuery - from .inaccessible_message import InaccessibleMessage - from .message import Message + from .maybe_inaccessible_message_union import MaybeInaccessibleMessageUnion from .user import User @@ -28,7 +27,7 @@ class CallbackQuery(TelegramObject): """Sender""" chat_instance: str """Global identifier, uniquely corresponding to the chat to which the message with the callback button was sent. Useful for high scores in :class:`aiogram.methods.games.Games`.""" - message: Optional[Union[Message, InaccessibleMessage]] = None + message: Optional[MaybeInaccessibleMessageUnion] = None """*Optional*. Message sent by the bot with the callback button that originated the query""" inline_message_id: Optional[str] = None """*Optional*. Identifier of the message sent via the bot in inline mode, that originated the query.""" @@ -47,7 +46,7 @@ class CallbackQuery(TelegramObject): id: str, from_user: User, chat_instance: str, - message: Optional[Union[Message, InaccessibleMessage]] = None, + message: Optional[MaybeInaccessibleMessageUnion] = None, inline_message_id: Optional[str] = None, data: Optional[str] = None, game_short_name: Optional[str] = None, diff --git a/aiogram/types/chat.py b/aiogram/types/chat.py index ddb0f983..2c4b0342 100644 --- a/aiogram/types/chat.py +++ b/aiogram/types/chat.py @@ -48,9 +48,7 @@ if TYPE_CHECKING: from .chat_photo import ChatPhoto from .input_file import InputFile from .message import Message - from .reaction_type_custom_emoji import ReactionTypeCustomEmoji - from .reaction_type_emoji import ReactionTypeEmoji - from .reaction_type_paid import ReactionTypePaid + from .reaction_type_union import ReactionTypeUnion class Chat(TelegramObject): @@ -84,9 +82,9 @@ class Chat(TelegramObject): .. deprecated:: API:7.3 https://core.telegram.org/bots/api-changelog#may-6-2024""" - available_reactions: Optional[ - list[Union[ReactionTypeEmoji, ReactionTypeCustomEmoji, ReactionTypePaid]] - ] = Field(None, json_schema_extra={"deprecated": True}) + available_reactions: Optional[list[ReactionTypeUnion]] = Field( + None, json_schema_extra={"deprecated": True} + ) """*Optional*. List of available reactions allowed in the chat. If omitted, then all `emoji reactions `_ are allowed. Returned only in :class:`aiogram.methods.get_chat.GetChat`. .. deprecated:: API:7.3 @@ -284,9 +282,7 @@ class Chat(TelegramObject): is_forum: Optional[bool] = None, accent_color_id: Optional[int] = None, active_usernames: Optional[list[str]] = None, - available_reactions: Optional[ - list[Union[ReactionTypeEmoji, ReactionTypeCustomEmoji, ReactionTypePaid]] - ] = None, + available_reactions: Optional[list[ReactionTypeUnion]] = None, background_custom_emoji_id: Optional[str] = None, bio: Optional[str] = None, birthdate: Optional[Birthdate] = None, diff --git a/aiogram/types/chat_background.py b/aiogram/types/chat_background.py index 937b4366..c234c8e6 100644 --- a/aiogram/types/chat_background.py +++ b/aiogram/types/chat_background.py @@ -1,13 +1,11 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Union +from typing import TYPE_CHECKING, Any + +from .base import TelegramObject if TYPE_CHECKING: - from .background_type_chat_theme import BackgroundTypeChatTheme - from .background_type_fill import BackgroundTypeFill - from .background_type_pattern import BackgroundTypePattern - from .background_type_wallpaper import BackgroundTypeWallpaper -from .base import TelegramObject + from .background_type_union import BackgroundTypeUnion class ChatBackground(TelegramObject): @@ -17,9 +15,7 @@ class ChatBackground(TelegramObject): Source: https://core.telegram.org/bots/api#chatbackground """ - type: Union[ - BackgroundTypeFill, BackgroundTypeWallpaper, BackgroundTypePattern, BackgroundTypeChatTheme - ] + type: BackgroundTypeUnion """Type of the background""" if TYPE_CHECKING: @@ -27,15 +23,7 @@ class ChatBackground(TelegramObject): # This section was auto-generated via `butcher` def __init__( - __pydantic__self__, - *, - type: Union[ - BackgroundTypeFill, - BackgroundTypeWallpaper, - BackgroundTypePattern, - BackgroundTypeChatTheme, - ], - **__pydantic_kwargs: Any, + __pydantic__self__, *, type: BackgroundTypeUnion, **__pydantic_kwargs: Any ) -> None: # DO NOT EDIT MANUALLY!!! # This method was auto-generated via `butcher` diff --git a/aiogram/types/chat_boost.py b/aiogram/types/chat_boost.py index 96e444f9..a4d2dc28 100644 --- a/aiogram/types/chat_boost.py +++ b/aiogram/types/chat_boost.py @@ -1,14 +1,12 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Union +from typing import TYPE_CHECKING, Any from .base import TelegramObject from .custom import DateTime if TYPE_CHECKING: - from .chat_boost_source_gift_code import ChatBoostSourceGiftCode - from .chat_boost_source_giveaway import ChatBoostSourceGiveaway - from .chat_boost_source_premium import ChatBoostSourcePremium + from .chat_boost_source_union import ChatBoostSourceUnion class ChatBoost(TelegramObject): @@ -24,7 +22,7 @@ class ChatBoost(TelegramObject): """Point in time (Unix timestamp) when the chat was boosted""" expiration_date: DateTime """Point in time (Unix timestamp) when the boost will automatically expire, unless the booster's Telegram Premium subscription is prolonged""" - source: Union[ChatBoostSourcePremium, ChatBoostSourceGiftCode, ChatBoostSourceGiveaway] + source: ChatBoostSourceUnion """Source of the added boost""" if TYPE_CHECKING: @@ -37,9 +35,7 @@ class ChatBoost(TelegramObject): boost_id: str, add_date: DateTime, expiration_date: DateTime, - source: Union[ - ChatBoostSourcePremium, ChatBoostSourceGiftCode, ChatBoostSourceGiveaway - ], + source: ChatBoostSourceUnion, **__pydantic_kwargs: Any, ) -> None: # DO NOT EDIT MANUALLY!!! diff --git a/aiogram/types/chat_boost_removed.py b/aiogram/types/chat_boost_removed.py index 094b0572..8ce7dee1 100644 --- a/aiogram/types/chat_boost_removed.py +++ b/aiogram/types/chat_boost_removed.py @@ -1,15 +1,13 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Union +from typing import TYPE_CHECKING, Any from .base import TelegramObject from .custom import DateTime if TYPE_CHECKING: from .chat import Chat - from .chat_boost_source_gift_code import ChatBoostSourceGiftCode - from .chat_boost_source_giveaway import ChatBoostSourceGiveaway - from .chat_boost_source_premium import ChatBoostSourcePremium + from .chat_boost_source_union import ChatBoostSourceUnion class ChatBoostRemoved(TelegramObject): @@ -25,7 +23,7 @@ class ChatBoostRemoved(TelegramObject): """Unique identifier of the boost""" remove_date: DateTime """Point in time (Unix timestamp) when the boost was removed""" - source: Union[ChatBoostSourcePremium, ChatBoostSourceGiftCode, ChatBoostSourceGiveaway] + source: ChatBoostSourceUnion """Source of the removed boost""" if TYPE_CHECKING: @@ -38,9 +36,7 @@ class ChatBoostRemoved(TelegramObject): chat: Chat, boost_id: str, remove_date: DateTime, - source: Union[ - ChatBoostSourcePremium, ChatBoostSourceGiftCode, ChatBoostSourceGiveaway - ], + source: ChatBoostSourceUnion, **__pydantic_kwargs: Any, ) -> None: # DO NOT EDIT MANUALLY!!! diff --git a/aiogram/types/chat_boost_source_union.py b/aiogram/types/chat_boost_source_union.py new file mode 100644 index 00000000..8b69aa66 --- /dev/null +++ b/aiogram/types/chat_boost_source_union.py @@ -0,0 +1,11 @@ +from __future__ import annotations + +from typing import Union + +from .chat_boost_source_gift_code import ChatBoostSourceGiftCode +from .chat_boost_source_giveaway import ChatBoostSourceGiveaway +from .chat_boost_source_premium import ChatBoostSourcePremium + +ChatBoostSourceUnion = Union[ + ChatBoostSourcePremium, ChatBoostSourceGiftCode, ChatBoostSourceGiveaway +] diff --git a/aiogram/types/chat_full_info.py b/aiogram/types/chat_full_info.py index 85f11060..6d804313 100644 --- a/aiogram/types/chat_full_info.py +++ b/aiogram/types/chat_full_info.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Optional, Union +from typing import TYPE_CHECKING, Any, Optional from .chat import Chat from .custom import DateTime @@ -14,9 +14,7 @@ if TYPE_CHECKING: from .chat_permissions import ChatPermissions from .chat_photo import ChatPhoto from .message import Message - from .reaction_type_custom_emoji import ReactionTypeCustomEmoji - from .reaction_type_emoji import ReactionTypeEmoji - from .reaction_type_paid import ReactionTypePaid + from .reaction_type_union import ReactionTypeUnion class ChatFullInfo(Chat): @@ -58,9 +56,7 @@ class ChatFullInfo(Chat): """*Optional*. For private chats with business accounts, the opening hours of the business""" personal_chat: Optional[Chat] = None """*Optional*. For private chats, the personal channel of the user""" - available_reactions: Optional[ - list[Union[ReactionTypeEmoji, ReactionTypeCustomEmoji, ReactionTypePaid]] - ] = None + available_reactions: Optional[list[ReactionTypeUnion]] = None """*Optional*. List of available reactions allowed in the chat. If omitted, then all `emoji reactions `_ are allowed.""" background_custom_emoji_id: Optional[str] = None """*Optional*. Custom emoji identifier of the emoji chosen by the chat for the reply header and link preview background""" @@ -142,9 +138,7 @@ class ChatFullInfo(Chat): business_location: Optional[BusinessLocation] = None, business_opening_hours: Optional[BusinessOpeningHours] = None, personal_chat: Optional[Chat] = None, - available_reactions: Optional[ - list[Union[ReactionTypeEmoji, ReactionTypeCustomEmoji, ReactionTypePaid]] - ] = None, + available_reactions: Optional[list[ReactionTypeUnion]] = None, background_custom_emoji_id: Optional[str] = None, profile_accent_color_id: Optional[int] = None, profile_background_custom_emoji_id: Optional[str] = None, diff --git a/aiogram/types/chat_id_union.py b/aiogram/types/chat_id_union.py new file mode 100644 index 00000000..1ed35693 --- /dev/null +++ b/aiogram/types/chat_id_union.py @@ -0,0 +1,5 @@ +from __future__ import annotations + +from typing import Union + +ChatIdUnion = Union[int, str] diff --git a/aiogram/types/chat_member_union.py b/aiogram/types/chat_member_union.py new file mode 100644 index 00000000..83289769 --- /dev/null +++ b/aiogram/types/chat_member_union.py @@ -0,0 +1,19 @@ +from __future__ import annotations + +from typing import Union + +from .chat_member_administrator import ChatMemberAdministrator +from .chat_member_banned import ChatMemberBanned +from .chat_member_left import ChatMemberLeft +from .chat_member_member import ChatMemberMember +from .chat_member_owner import ChatMemberOwner +from .chat_member_restricted import ChatMemberRestricted + +ChatMemberUnion = Union[ + ChatMemberOwner, + ChatMemberAdministrator, + ChatMemberMember, + ChatMemberRestricted, + ChatMemberLeft, + ChatMemberBanned, +] diff --git a/aiogram/types/chat_member_updated.py b/aiogram/types/chat_member_updated.py index 297fbf74..33e61f27 100644 --- a/aiogram/types/chat_member_updated.py +++ b/aiogram/types/chat_member_updated.py @@ -31,12 +31,7 @@ if TYPE_CHECKING: ) from .chat import Chat from .chat_invite_link import ChatInviteLink - from .chat_member_administrator import ChatMemberAdministrator - from .chat_member_banned import ChatMemberBanned - from .chat_member_left import ChatMemberLeft - from .chat_member_member import ChatMemberMember - from .chat_member_owner import ChatMemberOwner - from .chat_member_restricted import ChatMemberRestricted + from .chat_member_union import ChatMemberUnion from .force_reply import ForceReply from .inline_keyboard_markup import InlineKeyboardMarkup from .input_file import InputFile @@ -67,23 +62,9 @@ class ChatMemberUpdated(TelegramObject): """Performer of the action, which resulted in the change""" date: DateTime """Date the change was done in Unix time""" - old_chat_member: Union[ - ChatMemberOwner, - ChatMemberAdministrator, - ChatMemberMember, - ChatMemberRestricted, - ChatMemberLeft, - ChatMemberBanned, - ] + old_chat_member: ChatMemberUnion """Previous information about the chat member""" - new_chat_member: Union[ - ChatMemberOwner, - ChatMemberAdministrator, - ChatMemberMember, - ChatMemberRestricted, - ChatMemberLeft, - ChatMemberBanned, - ] + new_chat_member: ChatMemberUnion """New information about the chat member""" invite_link: Optional[ChatInviteLink] = None """*Optional*. Chat invite link, which was used by the user to join the chat; for joining by invite link events only.""" @@ -102,22 +83,8 @@ class ChatMemberUpdated(TelegramObject): chat: Chat, from_user: User, date: DateTime, - old_chat_member: Union[ - ChatMemberOwner, - ChatMemberAdministrator, - ChatMemberMember, - ChatMemberRestricted, - ChatMemberLeft, - ChatMemberBanned, - ], - new_chat_member: Union[ - ChatMemberOwner, - ChatMemberAdministrator, - ChatMemberMember, - ChatMemberRestricted, - ChatMemberLeft, - ChatMemberBanned, - ], + old_chat_member: ChatMemberUnion, + new_chat_member: ChatMemberUnion, invite_link: Optional[ChatInviteLink] = None, via_join_request: Optional[bool] = None, via_chat_folder_invite_link: Optional[bool] = None, diff --git a/aiogram/types/date_time_union.py b/aiogram/types/date_time_union.py new file mode 100644 index 00000000..8ac15f17 --- /dev/null +++ b/aiogram/types/date_time_union.py @@ -0,0 +1,6 @@ +from __future__ import annotations + +import datetime +from typing import Union + +DateTimeUnion = Union[datetime.datetime, datetime.timedelta, int] diff --git a/aiogram/types/external_reply_info.py b/aiogram/types/external_reply_info.py index 260fa6ff..776cdb28 100644 --- a/aiogram/types/external_reply_info.py +++ b/aiogram/types/external_reply_info.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Optional, Union +from typing import TYPE_CHECKING, Any, Optional from .base import TelegramObject @@ -17,10 +17,7 @@ if TYPE_CHECKING: from .invoice import Invoice from .link_preview_options import LinkPreviewOptions from .location import Location - from .message_origin_channel import MessageOriginChannel - from .message_origin_chat import MessageOriginChat - from .message_origin_hidden_user import MessageOriginHiddenUser - from .message_origin_user import MessageOriginUser + from .message_origin_union import MessageOriginUnion from .paid_media_info import PaidMediaInfo from .photo_size import PhotoSize from .poll import Poll @@ -39,9 +36,7 @@ class ExternalReplyInfo(TelegramObject): Source: https://core.telegram.org/bots/api#externalreplyinfo """ - origin: Union[ - MessageOriginUser, MessageOriginHiddenUser, MessageOriginChat, MessageOriginChannel - ] + origin: MessageOriginUnion """Origin of the message replied to by the given message""" chat: Optional[Chat] = None """*Optional*. Chat the original message belongs to. Available only if the chat is a supergroup or a channel.""" @@ -97,9 +92,7 @@ class ExternalReplyInfo(TelegramObject): def __init__( __pydantic__self__, *, - origin: Union[ - MessageOriginUser, MessageOriginHiddenUser, MessageOriginChat, MessageOriginChannel - ], + origin: MessageOriginUnion, chat: Optional[Chat] = None, message_id: Optional[int] = None, link_preview_options: Optional[LinkPreviewOptions] = None, diff --git a/aiogram/types/inaccessible_message.py b/aiogram/types/inaccessible_message.py index a4c38aac..67b838d7 100644 --- a/aiogram/types/inaccessible_message.py +++ b/aiogram/types/inaccessible_message.py @@ -37,8 +37,7 @@ if TYPE_CHECKING: from .input_media_document import InputMediaDocument from .input_media_photo import InputMediaPhoto from .input_media_video import InputMediaVideo - from .input_paid_media_photo import InputPaidMediaPhoto - from .input_paid_media_video import InputPaidMediaVideo + from .input_paid_media_union import InputPaidMediaUnion from .input_poll_option import InputPollOption from .labeled_price import LabeledPrice from .link_preview_options import LinkPreviewOptions @@ -2810,7 +2809,7 @@ class InaccessibleMessage(MaybeInaccessibleMessage): def answer_paid_media( self, star_count: int, - media: list[Union[InputPaidMediaPhoto, InputPaidMediaVideo]], + media: list[InputPaidMediaUnion], business_connection_id: Optional[str] = None, payload: Optional[str] = None, caption: Optional[str] = None, @@ -2881,7 +2880,7 @@ class InaccessibleMessage(MaybeInaccessibleMessage): def reply_paid_media( self, star_count: int, - media: list[Union[InputPaidMediaPhoto, InputPaidMediaVideo]], + media: list[InputPaidMediaUnion], business_connection_id: Optional[str] = None, payload: Optional[str] = None, caption: Optional[str] = None, diff --git a/aiogram/types/inline_query.py b/aiogram/types/inline_query.py index fefe0dd9..cbac7e51 100644 --- a/aiogram/types/inline_query.py +++ b/aiogram/types/inline_query.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Optional, Union +from typing import TYPE_CHECKING, Any, Optional from pydantic import Field @@ -8,26 +8,7 @@ from .base import TelegramObject if TYPE_CHECKING: from ..methods import AnswerInlineQuery - from .inline_query_result_article import InlineQueryResultArticle - from .inline_query_result_audio import InlineQueryResultAudio - from .inline_query_result_cached_audio import InlineQueryResultCachedAudio - from .inline_query_result_cached_document import InlineQueryResultCachedDocument - from .inline_query_result_cached_gif import InlineQueryResultCachedGif - from .inline_query_result_cached_mpeg4_gif import InlineQueryResultCachedMpeg4Gif - from .inline_query_result_cached_photo import InlineQueryResultCachedPhoto - from .inline_query_result_cached_sticker import InlineQueryResultCachedSticker - from .inline_query_result_cached_video import InlineQueryResultCachedVideo - from .inline_query_result_cached_voice import InlineQueryResultCachedVoice - from .inline_query_result_contact import InlineQueryResultContact - from .inline_query_result_document import InlineQueryResultDocument - from .inline_query_result_game import InlineQueryResultGame - from .inline_query_result_gif import InlineQueryResultGif - from .inline_query_result_location import InlineQueryResultLocation - from .inline_query_result_mpeg4_gif import InlineQueryResultMpeg4Gif - from .inline_query_result_photo import InlineQueryResultPhoto - from .inline_query_result_venue import InlineQueryResultVenue - from .inline_query_result_video import InlineQueryResultVideo - from .inline_query_result_voice import InlineQueryResultVoice + from .inline_query_result_union import InlineQueryResultUnion from .inline_query_results_button import InlineQueryResultsButton from .location import Location from .user import User @@ -84,30 +65,7 @@ class InlineQuery(TelegramObject): def answer( self, - results: list[ - Union[ - InlineQueryResultCachedAudio, - InlineQueryResultCachedDocument, - InlineQueryResultCachedGif, - InlineQueryResultCachedMpeg4Gif, - InlineQueryResultCachedPhoto, - InlineQueryResultCachedSticker, - InlineQueryResultCachedVideo, - InlineQueryResultCachedVoice, - InlineQueryResultArticle, - InlineQueryResultAudio, - InlineQueryResultContact, - InlineQueryResultGame, - InlineQueryResultDocument, - InlineQueryResultGif, - InlineQueryResultLocation, - InlineQueryResultMpeg4Gif, - InlineQueryResultPhoto, - InlineQueryResultVenue, - InlineQueryResultVideo, - InlineQueryResultVoice, - ] - ], + results: list[InlineQueryResultUnion], cache_time: Optional[int] = None, is_personal: Optional[bool] = None, next_offset: Optional[str] = None, diff --git a/aiogram/types/inline_query_result_article.py b/aiogram/types/inline_query_result_article.py index afd8ffdc..f922bee4 100644 --- a/aiogram/types/inline_query_result_article.py +++ b/aiogram/types/inline_query_result_article.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Literal, Optional, Union +from typing import TYPE_CHECKING, Any, Literal, Optional from pydantic import Field @@ -9,11 +9,7 @@ from .inline_query_result import InlineQueryResult if TYPE_CHECKING: from .inline_keyboard_markup import InlineKeyboardMarkup - from .input_contact_message_content import InputContactMessageContent - from .input_invoice_message_content import InputInvoiceMessageContent - from .input_location_message_content import InputLocationMessageContent - from .input_text_message_content import InputTextMessageContent - from .input_venue_message_content import InputVenueMessageContent + from .input_message_content_union import InputMessageContentUnion class InlineQueryResultArticle(InlineQueryResult): @@ -29,13 +25,7 @@ class InlineQueryResultArticle(InlineQueryResult): """Unique identifier for this result, 1-64 Bytes""" title: str """Title of the result""" - input_message_content: Union[ - InputTextMessageContent, - InputLocationMessageContent, - InputVenueMessageContent, - InputContactMessageContent, - InputInvoiceMessageContent, - ] + input_message_content: InputMessageContentUnion """Content of the message to be sent""" reply_markup: Optional[InlineKeyboardMarkup] = None """*Optional*. `Inline keyboard `_ attached to the message""" @@ -65,13 +55,7 @@ class InlineQueryResultArticle(InlineQueryResult): type: Literal[InlineQueryResultType.ARTICLE] = InlineQueryResultType.ARTICLE, id: str, title: str, - input_message_content: Union[ - InputTextMessageContent, - InputLocationMessageContent, - InputVenueMessageContent, - InputContactMessageContent, - InputInvoiceMessageContent, - ], + input_message_content: InputMessageContentUnion, reply_markup: Optional[InlineKeyboardMarkup] = None, url: Optional[str] = None, description: Optional[str] = None, diff --git a/aiogram/types/inline_query_result_audio.py b/aiogram/types/inline_query_result_audio.py index 461d806e..51f81f66 100644 --- a/aiogram/types/inline_query_result_audio.py +++ b/aiogram/types/inline_query_result_audio.py @@ -8,11 +8,7 @@ from .inline_query_result import InlineQueryResult if TYPE_CHECKING: from .inline_keyboard_markup import InlineKeyboardMarkup - from .input_contact_message_content import InputContactMessageContent - from .input_invoice_message_content import InputInvoiceMessageContent - from .input_location_message_content import InputLocationMessageContent - from .input_text_message_content import InputTextMessageContent - from .input_venue_message_content import InputVenueMessageContent + from .input_message_content_union import InputMessageContentUnion from .message_entity import MessageEntity @@ -43,15 +39,7 @@ class InlineQueryResultAudio(InlineQueryResult): """*Optional*. Audio duration in seconds""" reply_markup: Optional[InlineKeyboardMarkup] = None """*Optional*. `Inline keyboard `_ attached to the message""" - input_message_content: Optional[ - Union[ - InputTextMessageContent, - InputLocationMessageContent, - InputVenueMessageContent, - InputContactMessageContent, - InputInvoiceMessageContent, - ] - ] = None + input_message_content: Optional[InputMessageContentUnion] = None """*Optional*. Content of the message to be sent instead of the audio""" if TYPE_CHECKING: @@ -71,15 +59,7 @@ class InlineQueryResultAudio(InlineQueryResult): performer: Optional[str] = None, audio_duration: Optional[int] = None, reply_markup: Optional[InlineKeyboardMarkup] = None, - input_message_content: Optional[ - Union[ - InputTextMessageContent, - InputLocationMessageContent, - InputVenueMessageContent, - InputContactMessageContent, - InputInvoiceMessageContent, - ] - ] = None, + input_message_content: Optional[InputMessageContentUnion] = None, **__pydantic_kwargs: Any, ) -> None: # DO NOT EDIT MANUALLY!!! diff --git a/aiogram/types/inline_query_result_cached_audio.py b/aiogram/types/inline_query_result_cached_audio.py index 40ee181d..fdacd87e 100644 --- a/aiogram/types/inline_query_result_cached_audio.py +++ b/aiogram/types/inline_query_result_cached_audio.py @@ -8,11 +8,7 @@ from .inline_query_result import InlineQueryResult if TYPE_CHECKING: from .inline_keyboard_markup import InlineKeyboardMarkup - from .input_contact_message_content import InputContactMessageContent - from .input_invoice_message_content import InputInvoiceMessageContent - from .input_location_message_content import InputLocationMessageContent - from .input_text_message_content import InputTextMessageContent - from .input_venue_message_content import InputVenueMessageContent + from .input_message_content_union import InputMessageContentUnion from .message_entity import MessageEntity @@ -37,15 +33,7 @@ class InlineQueryResultCachedAudio(InlineQueryResult): """*Optional*. List of special entities that appear in the caption, which can be specified instead of *parse_mode*""" reply_markup: Optional[InlineKeyboardMarkup] = None """*Optional*. `Inline keyboard `_ attached to the message""" - input_message_content: Optional[ - Union[ - InputTextMessageContent, - InputLocationMessageContent, - InputVenueMessageContent, - InputContactMessageContent, - InputInvoiceMessageContent, - ] - ] = None + input_message_content: Optional[InputMessageContentUnion] = None """*Optional*. Content of the message to be sent instead of the audio""" if TYPE_CHECKING: @@ -62,15 +50,7 @@ class InlineQueryResultCachedAudio(InlineQueryResult): parse_mode: Optional[Union[str, Default]] = Default("parse_mode"), caption_entities: Optional[list[MessageEntity]] = None, reply_markup: Optional[InlineKeyboardMarkup] = None, - input_message_content: Optional[ - Union[ - InputTextMessageContent, - InputLocationMessageContent, - InputVenueMessageContent, - InputContactMessageContent, - InputInvoiceMessageContent, - ] - ] = None, + input_message_content: Optional[InputMessageContentUnion] = None, **__pydantic_kwargs: Any, ) -> None: # DO NOT EDIT MANUALLY!!! diff --git a/aiogram/types/inline_query_result_cached_document.py b/aiogram/types/inline_query_result_cached_document.py index d3cf947a..1552f507 100644 --- a/aiogram/types/inline_query_result_cached_document.py +++ b/aiogram/types/inline_query_result_cached_document.py @@ -8,11 +8,7 @@ from .inline_query_result import InlineQueryResult if TYPE_CHECKING: from .inline_keyboard_markup import InlineKeyboardMarkup - from .input_contact_message_content import InputContactMessageContent - from .input_invoice_message_content import InputInvoiceMessageContent - from .input_location_message_content import InputLocationMessageContent - from .input_text_message_content import InputTextMessageContent - from .input_venue_message_content import InputVenueMessageContent + from .input_message_content_union import InputMessageContentUnion from .message_entity import MessageEntity @@ -41,15 +37,7 @@ class InlineQueryResultCachedDocument(InlineQueryResult): """*Optional*. List of special entities that appear in the caption, which can be specified instead of *parse_mode*""" reply_markup: Optional[InlineKeyboardMarkup] = None """*Optional*. `Inline keyboard `_ attached to the message""" - input_message_content: Optional[ - Union[ - InputTextMessageContent, - InputLocationMessageContent, - InputVenueMessageContent, - InputContactMessageContent, - InputInvoiceMessageContent, - ] - ] = None + input_message_content: Optional[InputMessageContentUnion] = None """*Optional*. Content of the message to be sent instead of the file""" if TYPE_CHECKING: @@ -68,15 +56,7 @@ class InlineQueryResultCachedDocument(InlineQueryResult): parse_mode: Optional[Union[str, Default]] = Default("parse_mode"), caption_entities: Optional[list[MessageEntity]] = None, reply_markup: Optional[InlineKeyboardMarkup] = None, - input_message_content: Optional[ - Union[ - InputTextMessageContent, - InputLocationMessageContent, - InputVenueMessageContent, - InputContactMessageContent, - InputInvoiceMessageContent, - ] - ] = None, + input_message_content: Optional[InputMessageContentUnion] = None, **__pydantic_kwargs: Any, ) -> None: # DO NOT EDIT MANUALLY!!! diff --git a/aiogram/types/inline_query_result_cached_gif.py b/aiogram/types/inline_query_result_cached_gif.py index d4cb9b68..8c534941 100644 --- a/aiogram/types/inline_query_result_cached_gif.py +++ b/aiogram/types/inline_query_result_cached_gif.py @@ -8,11 +8,7 @@ from .inline_query_result import InlineQueryResult if TYPE_CHECKING: from .inline_keyboard_markup import InlineKeyboardMarkup - from .input_contact_message_content import InputContactMessageContent - from .input_invoice_message_content import InputInvoiceMessageContent - from .input_location_message_content import InputLocationMessageContent - from .input_text_message_content import InputTextMessageContent - from .input_venue_message_content import InputVenueMessageContent + from .input_message_content_union import InputMessageContentUnion from .message_entity import MessageEntity @@ -41,15 +37,7 @@ class InlineQueryResultCachedGif(InlineQueryResult): """*Optional*. Pass :code:`True`, if the caption must be shown above the message media""" reply_markup: Optional[InlineKeyboardMarkup] = None """*Optional*. `Inline keyboard `_ attached to the message""" - input_message_content: Optional[ - Union[ - InputTextMessageContent, - InputLocationMessageContent, - InputVenueMessageContent, - InputContactMessageContent, - InputInvoiceMessageContent, - ] - ] = None + input_message_content: Optional[InputMessageContentUnion] = None """*Optional*. Content of the message to be sent instead of the GIF animation""" if TYPE_CHECKING: @@ -70,15 +58,7 @@ class InlineQueryResultCachedGif(InlineQueryResult): "show_caption_above_media" ), reply_markup: Optional[InlineKeyboardMarkup] = None, - input_message_content: Optional[ - Union[ - InputTextMessageContent, - InputLocationMessageContent, - InputVenueMessageContent, - InputContactMessageContent, - InputInvoiceMessageContent, - ] - ] = None, + input_message_content: Optional[InputMessageContentUnion] = None, **__pydantic_kwargs: Any, ) -> None: # DO NOT EDIT MANUALLY!!! diff --git a/aiogram/types/inline_query_result_cached_mpeg4_gif.py b/aiogram/types/inline_query_result_cached_mpeg4_gif.py index 797bfaf3..7dd710fd 100644 --- a/aiogram/types/inline_query_result_cached_mpeg4_gif.py +++ b/aiogram/types/inline_query_result_cached_mpeg4_gif.py @@ -8,11 +8,7 @@ from .inline_query_result import InlineQueryResult if TYPE_CHECKING: from .inline_keyboard_markup import InlineKeyboardMarkup - from .input_contact_message_content import InputContactMessageContent - from .input_invoice_message_content import InputInvoiceMessageContent - from .input_location_message_content import InputLocationMessageContent - from .input_text_message_content import InputTextMessageContent - from .input_venue_message_content import InputVenueMessageContent + from .input_message_content_union import InputMessageContentUnion from .message_entity import MessageEntity @@ -41,15 +37,7 @@ class InlineQueryResultCachedMpeg4Gif(InlineQueryResult): """*Optional*. Pass :code:`True`, if the caption must be shown above the message media""" reply_markup: Optional[InlineKeyboardMarkup] = None """*Optional*. `Inline keyboard `_ attached to the message""" - input_message_content: Optional[ - Union[ - InputTextMessageContent, - InputLocationMessageContent, - InputVenueMessageContent, - InputContactMessageContent, - InputInvoiceMessageContent, - ] - ] = None + input_message_content: Optional[InputMessageContentUnion] = None """*Optional*. Content of the message to be sent instead of the video animation""" if TYPE_CHECKING: @@ -70,15 +58,7 @@ class InlineQueryResultCachedMpeg4Gif(InlineQueryResult): "show_caption_above_media" ), reply_markup: Optional[InlineKeyboardMarkup] = None, - input_message_content: Optional[ - Union[ - InputTextMessageContent, - InputLocationMessageContent, - InputVenueMessageContent, - InputContactMessageContent, - InputInvoiceMessageContent, - ] - ] = None, + input_message_content: Optional[InputMessageContentUnion] = None, **__pydantic_kwargs: Any, ) -> None: # DO NOT EDIT MANUALLY!!! diff --git a/aiogram/types/inline_query_result_cached_photo.py b/aiogram/types/inline_query_result_cached_photo.py index c67a5c0e..46df4ea1 100644 --- a/aiogram/types/inline_query_result_cached_photo.py +++ b/aiogram/types/inline_query_result_cached_photo.py @@ -8,11 +8,7 @@ from .inline_query_result import InlineQueryResult if TYPE_CHECKING: from .inline_keyboard_markup import InlineKeyboardMarkup - from .input_contact_message_content import InputContactMessageContent - from .input_invoice_message_content import InputInvoiceMessageContent - from .input_location_message_content import InputLocationMessageContent - from .input_text_message_content import InputTextMessageContent - from .input_venue_message_content import InputVenueMessageContent + from .input_message_content_union import InputMessageContentUnion from .message_entity import MessageEntity @@ -43,15 +39,7 @@ class InlineQueryResultCachedPhoto(InlineQueryResult): """*Optional*. Pass :code:`True`, if the caption must be shown above the message media""" reply_markup: Optional[InlineKeyboardMarkup] = None """*Optional*. `Inline keyboard `_ attached to the message""" - input_message_content: Optional[ - Union[ - InputTextMessageContent, - InputLocationMessageContent, - InputVenueMessageContent, - InputContactMessageContent, - InputInvoiceMessageContent, - ] - ] = None + input_message_content: Optional[InputMessageContentUnion] = None """*Optional*. Content of the message to be sent instead of the photo""" if TYPE_CHECKING: @@ -73,15 +61,7 @@ class InlineQueryResultCachedPhoto(InlineQueryResult): "show_caption_above_media" ), reply_markup: Optional[InlineKeyboardMarkup] = None, - input_message_content: Optional[ - Union[ - InputTextMessageContent, - InputLocationMessageContent, - InputVenueMessageContent, - InputContactMessageContent, - InputInvoiceMessageContent, - ] - ] = None, + input_message_content: Optional[InputMessageContentUnion] = None, **__pydantic_kwargs: Any, ) -> None: # DO NOT EDIT MANUALLY!!! diff --git a/aiogram/types/inline_query_result_cached_sticker.py b/aiogram/types/inline_query_result_cached_sticker.py index 4300023c..d8ae36b3 100644 --- a/aiogram/types/inline_query_result_cached_sticker.py +++ b/aiogram/types/inline_query_result_cached_sticker.py @@ -1,17 +1,13 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Literal, Optional, Union +from typing import TYPE_CHECKING, Any, Literal, Optional from ..enums import InlineQueryResultType from .inline_query_result import InlineQueryResult if TYPE_CHECKING: from .inline_keyboard_markup import InlineKeyboardMarkup - from .input_contact_message_content import InputContactMessageContent - from .input_invoice_message_content import InputInvoiceMessageContent - from .input_location_message_content import InputLocationMessageContent - from .input_text_message_content import InputTextMessageContent - from .input_venue_message_content import InputVenueMessageContent + from .input_message_content_union import InputMessageContentUnion class InlineQueryResultCachedSticker(InlineQueryResult): @@ -29,15 +25,7 @@ class InlineQueryResultCachedSticker(InlineQueryResult): """A valid file identifier of the sticker""" reply_markup: Optional[InlineKeyboardMarkup] = None """*Optional*. `Inline keyboard `_ attached to the message""" - input_message_content: Optional[ - Union[ - InputTextMessageContent, - InputLocationMessageContent, - InputVenueMessageContent, - InputContactMessageContent, - InputInvoiceMessageContent, - ] - ] = None + input_message_content: Optional[InputMessageContentUnion] = None """*Optional*. Content of the message to be sent instead of the sticker""" if TYPE_CHECKING: @@ -51,15 +39,7 @@ class InlineQueryResultCachedSticker(InlineQueryResult): id: str, sticker_file_id: str, reply_markup: Optional[InlineKeyboardMarkup] = None, - input_message_content: Optional[ - Union[ - InputTextMessageContent, - InputLocationMessageContent, - InputVenueMessageContent, - InputContactMessageContent, - InputInvoiceMessageContent, - ] - ] = None, + input_message_content: Optional[InputMessageContentUnion] = None, **__pydantic_kwargs: Any, ) -> None: # DO NOT EDIT MANUALLY!!! diff --git a/aiogram/types/inline_query_result_cached_video.py b/aiogram/types/inline_query_result_cached_video.py index c961e7c3..450f7115 100644 --- a/aiogram/types/inline_query_result_cached_video.py +++ b/aiogram/types/inline_query_result_cached_video.py @@ -8,11 +8,7 @@ from .inline_query_result import InlineQueryResult if TYPE_CHECKING: from .inline_keyboard_markup import InlineKeyboardMarkup - from .input_contact_message_content import InputContactMessageContent - from .input_invoice_message_content import InputInvoiceMessageContent - from .input_location_message_content import InputLocationMessageContent - from .input_text_message_content import InputTextMessageContent - from .input_venue_message_content import InputVenueMessageContent + from .input_message_content_union import InputMessageContentUnion from .message_entity import MessageEntity @@ -43,15 +39,7 @@ class InlineQueryResultCachedVideo(InlineQueryResult): """*Optional*. Pass :code:`True`, if the caption must be shown above the message media""" reply_markup: Optional[InlineKeyboardMarkup] = None """*Optional*. `Inline keyboard `_ attached to the message""" - input_message_content: Optional[ - Union[ - InputTextMessageContent, - InputLocationMessageContent, - InputVenueMessageContent, - InputContactMessageContent, - InputInvoiceMessageContent, - ] - ] = None + input_message_content: Optional[InputMessageContentUnion] = None """*Optional*. Content of the message to be sent instead of the video""" if TYPE_CHECKING: @@ -73,15 +61,7 @@ class InlineQueryResultCachedVideo(InlineQueryResult): "show_caption_above_media" ), reply_markup: Optional[InlineKeyboardMarkup] = None, - input_message_content: Optional[ - Union[ - InputTextMessageContent, - InputLocationMessageContent, - InputVenueMessageContent, - InputContactMessageContent, - InputInvoiceMessageContent, - ] - ] = None, + input_message_content: Optional[InputMessageContentUnion] = None, **__pydantic_kwargs: Any, ) -> None: # DO NOT EDIT MANUALLY!!! diff --git a/aiogram/types/inline_query_result_cached_voice.py b/aiogram/types/inline_query_result_cached_voice.py index eb8a19a8..5a7701c7 100644 --- a/aiogram/types/inline_query_result_cached_voice.py +++ b/aiogram/types/inline_query_result_cached_voice.py @@ -8,11 +8,7 @@ from .inline_query_result import InlineQueryResult if TYPE_CHECKING: from .inline_keyboard_markup import InlineKeyboardMarkup - from .input_contact_message_content import InputContactMessageContent - from .input_invoice_message_content import InputInvoiceMessageContent - from .input_location_message_content import InputLocationMessageContent - from .input_text_message_content import InputTextMessageContent - from .input_venue_message_content import InputVenueMessageContent + from .input_message_content_union import InputMessageContentUnion from .message_entity import MessageEntity @@ -39,15 +35,7 @@ class InlineQueryResultCachedVoice(InlineQueryResult): """*Optional*. List of special entities that appear in the caption, which can be specified instead of *parse_mode*""" reply_markup: Optional[InlineKeyboardMarkup] = None """*Optional*. `Inline keyboard `_ attached to the message""" - input_message_content: Optional[ - Union[ - InputTextMessageContent, - InputLocationMessageContent, - InputVenueMessageContent, - InputContactMessageContent, - InputInvoiceMessageContent, - ] - ] = None + input_message_content: Optional[InputMessageContentUnion] = None """*Optional*. Content of the message to be sent instead of the voice message""" if TYPE_CHECKING: @@ -65,15 +53,7 @@ class InlineQueryResultCachedVoice(InlineQueryResult): parse_mode: Optional[Union[str, Default]] = Default("parse_mode"), caption_entities: Optional[list[MessageEntity]] = None, reply_markup: Optional[InlineKeyboardMarkup] = None, - input_message_content: Optional[ - Union[ - InputTextMessageContent, - InputLocationMessageContent, - InputVenueMessageContent, - InputContactMessageContent, - InputInvoiceMessageContent, - ] - ] = None, + input_message_content: Optional[InputMessageContentUnion] = None, **__pydantic_kwargs: Any, ) -> None: # DO NOT EDIT MANUALLY!!! diff --git a/aiogram/types/inline_query_result_contact.py b/aiogram/types/inline_query_result_contact.py index cc2900cd..71c93975 100644 --- a/aiogram/types/inline_query_result_contact.py +++ b/aiogram/types/inline_query_result_contact.py @@ -1,17 +1,13 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Literal, Optional, Union +from typing import TYPE_CHECKING, Any, Literal, Optional from ..enums import InlineQueryResultType from .inline_query_result import InlineQueryResult if TYPE_CHECKING: from .inline_keyboard_markup import InlineKeyboardMarkup - from .input_contact_message_content import InputContactMessageContent - from .input_invoice_message_content import InputInvoiceMessageContent - from .input_location_message_content import InputLocationMessageContent - from .input_text_message_content import InputTextMessageContent - from .input_venue_message_content import InputVenueMessageContent + from .input_message_content_union import InputMessageContentUnion class InlineQueryResultContact(InlineQueryResult): @@ -35,15 +31,7 @@ class InlineQueryResultContact(InlineQueryResult): """*Optional*. Additional data about the contact in the form of a `vCard `_, 0-2048 bytes""" reply_markup: Optional[InlineKeyboardMarkup] = None """*Optional*. `Inline keyboard `_ attached to the message""" - input_message_content: Optional[ - Union[ - InputTextMessageContent, - InputLocationMessageContent, - InputVenueMessageContent, - InputContactMessageContent, - InputInvoiceMessageContent, - ] - ] = None + input_message_content: Optional[InputMessageContentUnion] = None """*Optional*. Content of the message to be sent instead of the contact""" thumbnail_url: Optional[str] = None """*Optional*. Url of the thumbnail for the result""" @@ -66,15 +54,7 @@ class InlineQueryResultContact(InlineQueryResult): last_name: Optional[str] = None, vcard: Optional[str] = None, reply_markup: Optional[InlineKeyboardMarkup] = None, - input_message_content: Optional[ - Union[ - InputTextMessageContent, - InputLocationMessageContent, - InputVenueMessageContent, - InputContactMessageContent, - InputInvoiceMessageContent, - ] - ] = None, + input_message_content: Optional[InputMessageContentUnion] = None, thumbnail_url: Optional[str] = None, thumbnail_width: Optional[int] = None, thumbnail_height: Optional[int] = None, diff --git a/aiogram/types/inline_query_result_document.py b/aiogram/types/inline_query_result_document.py index b52bfba5..dc1172f8 100644 --- a/aiogram/types/inline_query_result_document.py +++ b/aiogram/types/inline_query_result_document.py @@ -8,11 +8,7 @@ from .inline_query_result import InlineQueryResult if TYPE_CHECKING: from .inline_keyboard_markup import InlineKeyboardMarkup - from .input_contact_message_content import InputContactMessageContent - from .input_invoice_message_content import InputInvoiceMessageContent - from .input_location_message_content import InputLocationMessageContent - from .input_text_message_content import InputTextMessageContent - from .input_venue_message_content import InputVenueMessageContent + from .input_message_content_union import InputMessageContentUnion from .message_entity import MessageEntity @@ -43,15 +39,7 @@ class InlineQueryResultDocument(InlineQueryResult): """*Optional*. Short description of the result""" reply_markup: Optional[InlineKeyboardMarkup] = None """*Optional*. Inline keyboard attached to the message""" - input_message_content: Optional[ - Union[ - InputTextMessageContent, - InputLocationMessageContent, - InputVenueMessageContent, - InputContactMessageContent, - InputInvoiceMessageContent, - ] - ] = None + input_message_content: Optional[InputMessageContentUnion] = None """*Optional*. Content of the message to be sent instead of the file""" thumbnail_url: Optional[str] = None """*Optional*. URL of the thumbnail (JPEG only) for the file""" @@ -77,15 +65,7 @@ class InlineQueryResultDocument(InlineQueryResult): caption_entities: Optional[list[MessageEntity]] = None, description: Optional[str] = None, reply_markup: Optional[InlineKeyboardMarkup] = None, - input_message_content: Optional[ - Union[ - InputTextMessageContent, - InputLocationMessageContent, - InputVenueMessageContent, - InputContactMessageContent, - InputInvoiceMessageContent, - ] - ] = None, + input_message_content: Optional[InputMessageContentUnion] = None, thumbnail_url: Optional[str] = None, thumbnail_width: Optional[int] = None, thumbnail_height: Optional[int] = None, diff --git a/aiogram/types/inline_query_result_gif.py b/aiogram/types/inline_query_result_gif.py index cedc588c..910b21a9 100644 --- a/aiogram/types/inline_query_result_gif.py +++ b/aiogram/types/inline_query_result_gif.py @@ -8,11 +8,7 @@ from .inline_query_result import InlineQueryResult if TYPE_CHECKING: from .inline_keyboard_markup import InlineKeyboardMarkup - from .input_contact_message_content import InputContactMessageContent - from .input_invoice_message_content import InputInvoiceMessageContent - from .input_location_message_content import InputLocationMessageContent - from .input_text_message_content import InputTextMessageContent - from .input_venue_message_content import InputVenueMessageContent + from .input_message_content_union import InputMessageContentUnion from .message_entity import MessageEntity @@ -51,15 +47,7 @@ class InlineQueryResultGif(InlineQueryResult): """*Optional*. Pass :code:`True`, if the caption must be shown above the message media""" reply_markup: Optional[InlineKeyboardMarkup] = None """*Optional*. `Inline keyboard `_ attached to the message""" - input_message_content: Optional[ - Union[ - InputTextMessageContent, - InputLocationMessageContent, - InputVenueMessageContent, - InputContactMessageContent, - InputInvoiceMessageContent, - ] - ] = None + input_message_content: Optional[InputMessageContentUnion] = None """*Optional*. Content of the message to be sent instead of the GIF animation""" if TYPE_CHECKING: @@ -85,15 +73,7 @@ class InlineQueryResultGif(InlineQueryResult): "show_caption_above_media" ), reply_markup: Optional[InlineKeyboardMarkup] = None, - input_message_content: Optional[ - Union[ - InputTextMessageContent, - InputLocationMessageContent, - InputVenueMessageContent, - InputContactMessageContent, - InputInvoiceMessageContent, - ] - ] = None, + input_message_content: Optional[InputMessageContentUnion] = None, **__pydantic_kwargs: Any, ) -> None: # DO NOT EDIT MANUALLY!!! diff --git a/aiogram/types/inline_query_result_location.py b/aiogram/types/inline_query_result_location.py index 50b3ed8a..e62e8083 100644 --- a/aiogram/types/inline_query_result_location.py +++ b/aiogram/types/inline_query_result_location.py @@ -1,17 +1,13 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Literal, Optional, Union +from typing import TYPE_CHECKING, Any, Literal, Optional from ..enums import InlineQueryResultType from .inline_query_result import InlineQueryResult if TYPE_CHECKING: from .inline_keyboard_markup import InlineKeyboardMarkup - from .input_contact_message_content import InputContactMessageContent - from .input_invoice_message_content import InputInvoiceMessageContent - from .input_location_message_content import InputLocationMessageContent - from .input_text_message_content import InputTextMessageContent - from .input_venue_message_content import InputVenueMessageContent + from .input_message_content_union import InputMessageContentUnion class InlineQueryResultLocation(InlineQueryResult): @@ -41,15 +37,7 @@ class InlineQueryResultLocation(InlineQueryResult): """*Optional*. For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified.""" reply_markup: Optional[InlineKeyboardMarkup] = None """*Optional*. `Inline keyboard `_ attached to the message""" - input_message_content: Optional[ - Union[ - InputTextMessageContent, - InputLocationMessageContent, - InputVenueMessageContent, - InputContactMessageContent, - InputInvoiceMessageContent, - ] - ] = None + input_message_content: Optional[InputMessageContentUnion] = None """*Optional*. Content of the message to be sent instead of the location""" thumbnail_url: Optional[str] = None """*Optional*. Url of the thumbnail for the result""" @@ -75,15 +63,7 @@ class InlineQueryResultLocation(InlineQueryResult): heading: Optional[int] = None, proximity_alert_radius: Optional[int] = None, reply_markup: Optional[InlineKeyboardMarkup] = None, - input_message_content: Optional[ - Union[ - InputTextMessageContent, - InputLocationMessageContent, - InputVenueMessageContent, - InputContactMessageContent, - InputInvoiceMessageContent, - ] - ] = None, + input_message_content: Optional[InputMessageContentUnion] = None, thumbnail_url: Optional[str] = None, thumbnail_width: Optional[int] = None, thumbnail_height: Optional[int] = None, diff --git a/aiogram/types/inline_query_result_mpeg4_gif.py b/aiogram/types/inline_query_result_mpeg4_gif.py index 9fd1e716..7e50dd74 100644 --- a/aiogram/types/inline_query_result_mpeg4_gif.py +++ b/aiogram/types/inline_query_result_mpeg4_gif.py @@ -8,11 +8,7 @@ from .inline_query_result import InlineQueryResult if TYPE_CHECKING: from .inline_keyboard_markup import InlineKeyboardMarkup - from .input_contact_message_content import InputContactMessageContent - from .input_invoice_message_content import InputInvoiceMessageContent - from .input_location_message_content import InputLocationMessageContent - from .input_text_message_content import InputTextMessageContent - from .input_venue_message_content import InputVenueMessageContent + from .input_message_content_union import InputMessageContentUnion from .message_entity import MessageEntity @@ -51,15 +47,7 @@ class InlineQueryResultMpeg4Gif(InlineQueryResult): """*Optional*. Pass :code:`True`, if the caption must be shown above the message media""" reply_markup: Optional[InlineKeyboardMarkup] = None """*Optional*. `Inline keyboard `_ attached to the message""" - input_message_content: Optional[ - Union[ - InputTextMessageContent, - InputLocationMessageContent, - InputVenueMessageContent, - InputContactMessageContent, - InputInvoiceMessageContent, - ] - ] = None + input_message_content: Optional[InputMessageContentUnion] = None """*Optional*. Content of the message to be sent instead of the video animation""" if TYPE_CHECKING: @@ -85,15 +73,7 @@ class InlineQueryResultMpeg4Gif(InlineQueryResult): "show_caption_above_media" ), reply_markup: Optional[InlineKeyboardMarkup] = None, - input_message_content: Optional[ - Union[ - InputTextMessageContent, - InputLocationMessageContent, - InputVenueMessageContent, - InputContactMessageContent, - InputInvoiceMessageContent, - ] - ] = None, + input_message_content: Optional[InputMessageContentUnion] = None, **__pydantic_kwargs: Any, ) -> None: # DO NOT EDIT MANUALLY!!! diff --git a/aiogram/types/inline_query_result_photo.py b/aiogram/types/inline_query_result_photo.py index 942ad717..7af052a3 100644 --- a/aiogram/types/inline_query_result_photo.py +++ b/aiogram/types/inline_query_result_photo.py @@ -8,11 +8,7 @@ from .inline_query_result import InlineQueryResult if TYPE_CHECKING: from .inline_keyboard_markup import InlineKeyboardMarkup - from .input_contact_message_content import InputContactMessageContent - from .input_invoice_message_content import InputInvoiceMessageContent - from .input_location_message_content import InputLocationMessageContent - from .input_text_message_content import InputTextMessageContent - from .input_venue_message_content import InputVenueMessageContent + from .input_message_content_union import InputMessageContentUnion from .message_entity import MessageEntity @@ -49,15 +45,7 @@ class InlineQueryResultPhoto(InlineQueryResult): """*Optional*. Pass :code:`True`, if the caption must be shown above the message media""" reply_markup: Optional[InlineKeyboardMarkup] = None """*Optional*. `Inline keyboard `_ attached to the message""" - input_message_content: Optional[ - Union[ - InputTextMessageContent, - InputLocationMessageContent, - InputVenueMessageContent, - InputContactMessageContent, - InputInvoiceMessageContent, - ] - ] = None + input_message_content: Optional[InputMessageContentUnion] = None """*Optional*. Content of the message to be sent instead of the photo""" if TYPE_CHECKING: @@ -82,15 +70,7 @@ class InlineQueryResultPhoto(InlineQueryResult): "show_caption_above_media" ), reply_markup: Optional[InlineKeyboardMarkup] = None, - input_message_content: Optional[ - Union[ - InputTextMessageContent, - InputLocationMessageContent, - InputVenueMessageContent, - InputContactMessageContent, - InputInvoiceMessageContent, - ] - ] = None, + input_message_content: Optional[InputMessageContentUnion] = None, **__pydantic_kwargs: Any, ) -> None: # DO NOT EDIT MANUALLY!!! diff --git a/aiogram/types/inline_query_result_union.py b/aiogram/types/inline_query_result_union.py new file mode 100644 index 00000000..c2132b20 --- /dev/null +++ b/aiogram/types/inline_query_result_union.py @@ -0,0 +1,47 @@ +from __future__ import annotations + +from typing import Union + +from .inline_query_result_article import InlineQueryResultArticle +from .inline_query_result_audio import InlineQueryResultAudio +from .inline_query_result_cached_audio import InlineQueryResultCachedAudio +from .inline_query_result_cached_document import InlineQueryResultCachedDocument +from .inline_query_result_cached_gif import InlineQueryResultCachedGif +from .inline_query_result_cached_mpeg4_gif import InlineQueryResultCachedMpeg4Gif +from .inline_query_result_cached_photo import InlineQueryResultCachedPhoto +from .inline_query_result_cached_sticker import InlineQueryResultCachedSticker +from .inline_query_result_cached_video import InlineQueryResultCachedVideo +from .inline_query_result_cached_voice import InlineQueryResultCachedVoice +from .inline_query_result_contact import InlineQueryResultContact +from .inline_query_result_document import InlineQueryResultDocument +from .inline_query_result_game import InlineQueryResultGame +from .inline_query_result_gif import InlineQueryResultGif +from .inline_query_result_location import InlineQueryResultLocation +from .inline_query_result_mpeg4_gif import InlineQueryResultMpeg4Gif +from .inline_query_result_photo import InlineQueryResultPhoto +from .inline_query_result_venue import InlineQueryResultVenue +from .inline_query_result_video import InlineQueryResultVideo +from .inline_query_result_voice import InlineQueryResultVoice + +InlineQueryResultUnion = Union[ + InlineQueryResultCachedAudio, + InlineQueryResultCachedDocument, + InlineQueryResultCachedGif, + InlineQueryResultCachedMpeg4Gif, + InlineQueryResultCachedPhoto, + InlineQueryResultCachedSticker, + InlineQueryResultCachedVideo, + InlineQueryResultCachedVoice, + InlineQueryResultArticle, + InlineQueryResultAudio, + InlineQueryResultContact, + InlineQueryResultGame, + InlineQueryResultDocument, + InlineQueryResultGif, + InlineQueryResultLocation, + InlineQueryResultMpeg4Gif, + InlineQueryResultPhoto, + InlineQueryResultVenue, + InlineQueryResultVideo, + InlineQueryResultVoice, +] diff --git a/aiogram/types/inline_query_result_venue.py b/aiogram/types/inline_query_result_venue.py index b8775b6b..24628d23 100644 --- a/aiogram/types/inline_query_result_venue.py +++ b/aiogram/types/inline_query_result_venue.py @@ -1,17 +1,13 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Literal, Optional, Union +from typing import TYPE_CHECKING, Any, Literal, Optional from ..enums import InlineQueryResultType from .inline_query_result import InlineQueryResult if TYPE_CHECKING: from .inline_keyboard_markup import InlineKeyboardMarkup - from .input_contact_message_content import InputContactMessageContent - from .input_invoice_message_content import InputInvoiceMessageContent - from .input_location_message_content import InputLocationMessageContent - from .input_text_message_content import InputTextMessageContent - from .input_venue_message_content import InputVenueMessageContent + from .input_message_content_union import InputMessageContentUnion class InlineQueryResultVenue(InlineQueryResult): @@ -43,15 +39,7 @@ class InlineQueryResultVenue(InlineQueryResult): """*Optional*. Google Places type of the venue. (See `supported types `_.)""" reply_markup: Optional[InlineKeyboardMarkup] = None """*Optional*. `Inline keyboard `_ attached to the message""" - input_message_content: Optional[ - Union[ - InputTextMessageContent, - InputLocationMessageContent, - InputVenueMessageContent, - InputContactMessageContent, - InputInvoiceMessageContent, - ] - ] = None + input_message_content: Optional[InputMessageContentUnion] = None """*Optional*. Content of the message to be sent instead of the venue""" thumbnail_url: Optional[str] = None """*Optional*. Url of the thumbnail for the result""" @@ -78,15 +66,7 @@ class InlineQueryResultVenue(InlineQueryResult): google_place_id: Optional[str] = None, google_place_type: Optional[str] = None, reply_markup: Optional[InlineKeyboardMarkup] = None, - input_message_content: Optional[ - Union[ - InputTextMessageContent, - InputLocationMessageContent, - InputVenueMessageContent, - InputContactMessageContent, - InputInvoiceMessageContent, - ] - ] = None, + input_message_content: Optional[InputMessageContentUnion] = None, thumbnail_url: Optional[str] = None, thumbnail_width: Optional[int] = None, thumbnail_height: Optional[int] = None, diff --git a/aiogram/types/inline_query_result_video.py b/aiogram/types/inline_query_result_video.py index 54c9674c..72aa6224 100644 --- a/aiogram/types/inline_query_result_video.py +++ b/aiogram/types/inline_query_result_video.py @@ -8,11 +8,7 @@ from .inline_query_result import InlineQueryResult if TYPE_CHECKING: from .inline_keyboard_markup import InlineKeyboardMarkup - from .input_contact_message_content import InputContactMessageContent - from .input_invoice_message_content import InputInvoiceMessageContent - from .input_location_message_content import InputLocationMessageContent - from .input_text_message_content import InputTextMessageContent - from .input_venue_message_content import InputVenueMessageContent + from .input_message_content_union import InputMessageContentUnion from .message_entity import MessageEntity @@ -55,15 +51,7 @@ class InlineQueryResultVideo(InlineQueryResult): """*Optional*. Short description of the result""" reply_markup: Optional[InlineKeyboardMarkup] = None """*Optional*. `Inline keyboard `_ attached to the message""" - input_message_content: Optional[ - Union[ - InputTextMessageContent, - InputLocationMessageContent, - InputVenueMessageContent, - InputContactMessageContent, - InputInvoiceMessageContent, - ] - ] = None + input_message_content: Optional[InputMessageContentUnion] = None """*Optional*. Content of the message to be sent instead of the video. This field is **required** if InlineQueryResultVideo is used to send an HTML-page as a result (e.g., a YouTube video).""" if TYPE_CHECKING: @@ -90,15 +78,7 @@ class InlineQueryResultVideo(InlineQueryResult): video_duration: Optional[int] = None, description: Optional[str] = None, reply_markup: Optional[InlineKeyboardMarkup] = None, - input_message_content: Optional[ - Union[ - InputTextMessageContent, - InputLocationMessageContent, - InputVenueMessageContent, - InputContactMessageContent, - InputInvoiceMessageContent, - ] - ] = None, + input_message_content: Optional[InputMessageContentUnion] = None, **__pydantic_kwargs: Any, ) -> None: # DO NOT EDIT MANUALLY!!! diff --git a/aiogram/types/inline_query_result_voice.py b/aiogram/types/inline_query_result_voice.py index 0923a0e9..0d7bfc9d 100644 --- a/aiogram/types/inline_query_result_voice.py +++ b/aiogram/types/inline_query_result_voice.py @@ -8,11 +8,7 @@ from .inline_query_result import InlineQueryResult if TYPE_CHECKING: from .inline_keyboard_markup import InlineKeyboardMarkup - from .input_contact_message_content import InputContactMessageContent - from .input_invoice_message_content import InputInvoiceMessageContent - from .input_location_message_content import InputLocationMessageContent - from .input_text_message_content import InputTextMessageContent - from .input_venue_message_content import InputVenueMessageContent + from .input_message_content_union import InputMessageContentUnion from .message_entity import MessageEntity @@ -41,15 +37,7 @@ class InlineQueryResultVoice(InlineQueryResult): """*Optional*. Recording duration in seconds""" reply_markup: Optional[InlineKeyboardMarkup] = None """*Optional*. `Inline keyboard `_ attached to the message""" - input_message_content: Optional[ - Union[ - InputTextMessageContent, - InputLocationMessageContent, - InputVenueMessageContent, - InputContactMessageContent, - InputInvoiceMessageContent, - ] - ] = None + input_message_content: Optional[InputMessageContentUnion] = None """*Optional*. Content of the message to be sent instead of the voice recording""" if TYPE_CHECKING: @@ -68,15 +56,7 @@ class InlineQueryResultVoice(InlineQueryResult): caption_entities: Optional[list[MessageEntity]] = None, voice_duration: Optional[int] = None, reply_markup: Optional[InlineKeyboardMarkup] = None, - input_message_content: Optional[ - Union[ - InputTextMessageContent, - InputLocationMessageContent, - InputVenueMessageContent, - InputContactMessageContent, - InputInvoiceMessageContent, - ] - ] = None, + input_message_content: Optional[InputMessageContentUnion] = None, **__pydantic_kwargs: Any, ) -> None: # DO NOT EDIT MANUALLY!!! diff --git a/aiogram/types/input_file_union.py b/aiogram/types/input_file_union.py new file mode 100644 index 00000000..7038e400 --- /dev/null +++ b/aiogram/types/input_file_union.py @@ -0,0 +1,7 @@ +from __future__ import annotations + +from typing import Union + +from .input_file import InputFile + +InputFileUnion = Union[str, InputFile] diff --git a/aiogram/types/input_media_union.py b/aiogram/types/input_media_union.py new file mode 100644 index 00000000..89293822 --- /dev/null +++ b/aiogram/types/input_media_union.py @@ -0,0 +1,13 @@ +from __future__ import annotations + +from typing import Union + +from .input_media_animation import InputMediaAnimation +from .input_media_audio import InputMediaAudio +from .input_media_document import InputMediaDocument +from .input_media_photo import InputMediaPhoto +from .input_media_video import InputMediaVideo + +InputMediaUnion = Union[ + InputMediaAnimation, InputMediaDocument, InputMediaAudio, InputMediaPhoto, InputMediaVideo +] diff --git a/aiogram/types/input_message_content_union.py b/aiogram/types/input_message_content_union.py new file mode 100644 index 00000000..47454e39 --- /dev/null +++ b/aiogram/types/input_message_content_union.py @@ -0,0 +1,17 @@ +from __future__ import annotations + +from typing import Union + +from .input_contact_message_content import InputContactMessageContent +from .input_invoice_message_content import InputInvoiceMessageContent +from .input_location_message_content import InputLocationMessageContent +from .input_text_message_content import InputTextMessageContent +from .input_venue_message_content import InputVenueMessageContent + +InputMessageContentUnion = Union[ + InputTextMessageContent, + InputLocationMessageContent, + InputVenueMessageContent, + InputContactMessageContent, + InputInvoiceMessageContent, +] diff --git a/aiogram/types/input_paid_media_union.py b/aiogram/types/input_paid_media_union.py new file mode 100644 index 00000000..70c2465b --- /dev/null +++ b/aiogram/types/input_paid_media_union.py @@ -0,0 +1,8 @@ +from __future__ import annotations + +from typing import Union + +from .input_paid_media_photo import InputPaidMediaPhoto +from .input_paid_media_video import InputPaidMediaVideo + +InputPaidMediaUnion = Union[InputPaidMediaPhoto, InputPaidMediaVideo] diff --git a/aiogram/types/input_poll_option_union.py b/aiogram/types/input_poll_option_union.py new file mode 100644 index 00000000..30160880 --- /dev/null +++ b/aiogram/types/input_poll_option_union.py @@ -0,0 +1,7 @@ +from __future__ import annotations + +from typing import Union + +from .input_poll_option import InputPollOption + +InputPollOptionUnion = Union[InputPollOption, str] diff --git a/aiogram/types/maybe_inaccessible_message_union.py b/aiogram/types/maybe_inaccessible_message_union.py new file mode 100644 index 00000000..dfd6bfac --- /dev/null +++ b/aiogram/types/maybe_inaccessible_message_union.py @@ -0,0 +1,8 @@ +from __future__ import annotations + +from typing import Union + +from .inaccessible_message import InaccessibleMessage +from .message import Message + +MaybeInaccessibleMessageUnion = Union[Message, InaccessibleMessage] diff --git a/aiogram/types/menu_button_union.py b/aiogram/types/menu_button_union.py new file mode 100644 index 00000000..f880cdc3 --- /dev/null +++ b/aiogram/types/menu_button_union.py @@ -0,0 +1,9 @@ +from __future__ import annotations + +from typing import Union + +from .menu_button_commands import MenuButtonCommands +from .menu_button_default import MenuButtonDefault +from .menu_button_web_app import MenuButtonWebApp + +MenuButtonUnion = Union[MenuButtonCommands, MenuButtonWebApp, MenuButtonDefault] diff --git a/aiogram/types/message.py b/aiogram/types/message.py index 27664c5a..44e3f4d1 100644 --- a/aiogram/types/message.py +++ b/aiogram/types/message.py @@ -72,35 +72,29 @@ if TYPE_CHECKING: from .giveaway_completed import GiveawayCompleted from .giveaway_created import GiveawayCreated from .giveaway_winners import GiveawayWinners - from .inaccessible_message import InaccessibleMessage from .inline_keyboard_markup import InlineKeyboardMarkup from .input_file import InputFile - from .input_media_animation import InputMediaAnimation from .input_media_audio import InputMediaAudio from .input_media_document import InputMediaDocument from .input_media_photo import InputMediaPhoto + from .input_media_union import InputMediaUnion from .input_media_video import InputMediaVideo - from .input_paid_media_photo import InputPaidMediaPhoto - from .input_paid_media_video import InputPaidMediaVideo + from .input_paid_media_union import InputPaidMediaUnion from .input_poll_option import InputPollOption from .invoice import Invoice from .labeled_price import LabeledPrice from .link_preview_options import LinkPreviewOptions from .location import Location + from .maybe_inaccessible_message_union import MaybeInaccessibleMessageUnion from .message_auto_delete_timer_changed import MessageAutoDeleteTimerChanged from .message_entity import MessageEntity - from .message_origin_channel import MessageOriginChannel - from .message_origin_chat import MessageOriginChat - from .message_origin_hidden_user import MessageOriginHiddenUser - from .message_origin_user import MessageOriginUser + from .message_origin_union import MessageOriginUnion from .paid_media_info import PaidMediaInfo from .passport_data import PassportData from .photo_size import PhotoSize from .poll import Poll from .proximity_alert_triggered import ProximityAlertTriggered - from .reaction_type_custom_emoji import ReactionTypeCustomEmoji - from .reaction_type_emoji import ReactionTypeEmoji - from .reaction_type_paid import ReactionTypePaid + from .reaction_type_union import ReactionTypeUnion from .refunded_payment import RefundedPayment from .reply_keyboard_markup import ReplyKeyboardMarkup from .reply_keyboard_remove import ReplyKeyboardRemove @@ -148,9 +142,7 @@ class Message(MaybeInaccessibleMessage): """*Optional*. The bot that actually sent the message on behalf of the business account. Available only for outgoing messages sent on behalf of the connected business account.""" business_connection_id: Optional[str] = None """*Optional*. Unique identifier of the business connection from which the message was received. If non-empty, the message belongs to a chat of the corresponding business account that is independent from any potential bot chat which might share the same identifier.""" - forward_origin: Optional[ - Union[MessageOriginUser, MessageOriginHiddenUser, MessageOriginChat, MessageOriginChannel] - ] = None + forward_origin: Optional[MessageOriginUnion] = None """*Optional*. Information about the original message for forwarded messages""" is_topic_message: Optional[bool] = None """*Optional*. :code:`True`, if the message is sent to a forum topic""" @@ -246,7 +238,7 @@ class Message(MaybeInaccessibleMessage): """*Optional*. The group has been migrated to a supergroup with the specified identifier. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier.""" migrate_from_chat_id: Optional[int] = None """*Optional*. The supergroup has been migrated from a group with the specified identifier. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier.""" - pinned_message: Optional[Union[Message, InaccessibleMessage]] = None + pinned_message: Optional[MaybeInaccessibleMessageUnion] = None """*Optional*. Specified message was pinned. Note that the Message object in this field will not contain further *reply_to_message* fields even if it itself is a reply.""" invoice: Optional[Invoice] = None """*Optional*. Message is an invoice for a `payment `_, information about the invoice. `More about payments ยป `_""" @@ -354,14 +346,7 @@ class Message(MaybeInaccessibleMessage): sender_boost_count: Optional[int] = None, sender_business_bot: Optional[User] = None, business_connection_id: Optional[str] = None, - forward_origin: Optional[ - Union[ - MessageOriginUser, - MessageOriginHiddenUser, - MessageOriginChat, - MessageOriginChannel, - ] - ] = None, + forward_origin: Optional[MessageOriginUnion] = None, is_topic_message: Optional[bool] = None, is_automatic_forward: Optional[bool] = None, reply_to_message: Optional[Message] = None, @@ -409,7 +394,7 @@ class Message(MaybeInaccessibleMessage): message_auto_delete_timer_changed: Optional[MessageAutoDeleteTimerChanged] = None, migrate_to_chat_id: Optional[int] = None, migrate_from_chat_id: Optional[int] = None, - pinned_message: Optional[Union[Message, InaccessibleMessage]] = None, + pinned_message: Optional[MaybeInaccessibleMessageUnion] = None, invoice: Optional[Invoice] = None, successful_payment: Optional[SuccessfulPayment] = None, refunded_payment: Optional[RefundedPayment] = None, @@ -3745,13 +3730,7 @@ class Message(MaybeInaccessibleMessage): def edit_media( self, - media: Union[ - InputMediaAnimation, - InputMediaDocument, - InputMediaAudio, - InputMediaPhoto, - InputMediaVideo, - ], + media: InputMediaUnion, inline_message_id: Optional[str] = None, reply_markup: Optional[InlineKeyboardMarkup] = None, **kwargs: Any, @@ -4177,9 +4156,7 @@ class Message(MaybeInaccessibleMessage): def react( self, - reaction: Optional[ - list[Union[ReactionTypeEmoji, ReactionTypeCustomEmoji, ReactionTypePaid]] - ] = None, + reaction: Optional[list[ReactionTypeUnion]] = None, is_big: Optional[bool] = None, **kwargs: Any, ) -> SetMessageReaction: @@ -4220,7 +4197,7 @@ class Message(MaybeInaccessibleMessage): def answer_paid_media( self, star_count: int, - media: list[Union[InputPaidMediaPhoto, InputPaidMediaVideo]], + media: list[InputPaidMediaUnion], payload: Optional[str] = None, caption: Optional[str] = None, parse_mode: Optional[str] = None, @@ -4292,7 +4269,7 @@ class Message(MaybeInaccessibleMessage): def reply_paid_media( self, star_count: int, - media: list[Union[InputPaidMediaPhoto, InputPaidMediaVideo]], + media: list[InputPaidMediaUnion], payload: Optional[str] = None, caption: Optional[str] = None, parse_mode: Optional[str] = None, diff --git a/aiogram/types/message_origin_union.py b/aiogram/types/message_origin_union.py new file mode 100644 index 00000000..d34f1f74 --- /dev/null +++ b/aiogram/types/message_origin_union.py @@ -0,0 +1,12 @@ +from __future__ import annotations + +from typing import Union + +from .message_origin_channel import MessageOriginChannel +from .message_origin_chat import MessageOriginChat +from .message_origin_hidden_user import MessageOriginHiddenUser +from .message_origin_user import MessageOriginUser + +MessageOriginUnion = Union[ + MessageOriginUser, MessageOriginHiddenUser, MessageOriginChat, MessageOriginChannel +] diff --git a/aiogram/types/message_reaction_updated.py b/aiogram/types/message_reaction_updated.py index 23cf0e1e..c40ed6c9 100644 --- a/aiogram/types/message_reaction_updated.py +++ b/aiogram/types/message_reaction_updated.py @@ -1,15 +1,13 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Optional, Union +from typing import TYPE_CHECKING, Any, Optional from .base import TelegramObject if TYPE_CHECKING: from .chat import Chat from .custom import DateTime - from .reaction_type_custom_emoji import ReactionTypeCustomEmoji - from .reaction_type_emoji import ReactionTypeEmoji - from .reaction_type_paid import ReactionTypePaid + from .reaction_type_union import ReactionTypeUnion from .user import User @@ -26,9 +24,9 @@ class MessageReactionUpdated(TelegramObject): """Unique identifier of the message inside the chat""" date: DateTime """Date of the change in Unix time""" - old_reaction: list[Union[ReactionTypeEmoji, ReactionTypeCustomEmoji, ReactionTypePaid]] + old_reaction: list[ReactionTypeUnion] """Previous list of reaction types that were set by the user""" - new_reaction: list[Union[ReactionTypeEmoji, ReactionTypeCustomEmoji, ReactionTypePaid]] + new_reaction: list[ReactionTypeUnion] """New list of reaction types that have been set by the user""" user: Optional[User] = None """*Optional*. The user that changed the reaction, if the user isn't anonymous""" @@ -45,12 +43,8 @@ class MessageReactionUpdated(TelegramObject): chat: Chat, message_id: int, date: DateTime, - old_reaction: list[ - Union[ReactionTypeEmoji, ReactionTypeCustomEmoji, ReactionTypePaid] - ], - new_reaction: list[ - Union[ReactionTypeEmoji, ReactionTypeCustomEmoji, ReactionTypePaid] - ], + old_reaction: list[ReactionTypeUnion], + new_reaction: list[ReactionTypeUnion], user: Optional[User] = None, actor_chat: Optional[Chat] = None, **__pydantic_kwargs: Any, diff --git a/aiogram/types/paid_media_info.py b/aiogram/types/paid_media_info.py index 274f5d51..566c63e4 100644 --- a/aiogram/types/paid_media_info.py +++ b/aiogram/types/paid_media_info.py @@ -1,13 +1,11 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Union +from typing import TYPE_CHECKING, Any from .base import TelegramObject if TYPE_CHECKING: - from .paid_media_photo import PaidMediaPhoto - from .paid_media_preview import PaidMediaPreview - from .paid_media_video import PaidMediaVideo + from .paid_media_union import PaidMediaUnion class PaidMediaInfo(TelegramObject): @@ -19,7 +17,7 @@ class PaidMediaInfo(TelegramObject): star_count: int """The number of Telegram Stars that must be paid to buy access to the media""" - paid_media: list[Union[PaidMediaPreview, PaidMediaPhoto, PaidMediaVideo]] + paid_media: list[PaidMediaUnion] """Information about the paid media""" if TYPE_CHECKING: @@ -30,7 +28,7 @@ class PaidMediaInfo(TelegramObject): __pydantic__self__, *, star_count: int, - paid_media: list[Union[PaidMediaPreview, PaidMediaPhoto, PaidMediaVideo]], + paid_media: list[PaidMediaUnion], **__pydantic_kwargs: Any, ) -> None: # DO NOT EDIT MANUALLY!!! diff --git a/aiogram/types/paid_media_union.py b/aiogram/types/paid_media_union.py new file mode 100644 index 00000000..85eae573 --- /dev/null +++ b/aiogram/types/paid_media_union.py @@ -0,0 +1,9 @@ +from __future__ import annotations + +from typing import Union + +from .paid_media_photo import PaidMediaPhoto +from .paid_media_preview import PaidMediaPreview +from .paid_media_video import PaidMediaVideo + +PaidMediaUnion = Union[PaidMediaPreview, PaidMediaPhoto, PaidMediaVideo] diff --git a/aiogram/types/passport_element_error_union.py b/aiogram/types/passport_element_error_union.py new file mode 100644 index 00000000..e14fdf17 --- /dev/null +++ b/aiogram/types/passport_element_error_union.py @@ -0,0 +1,27 @@ +from __future__ import annotations + +from typing import Union + +from .passport_element_error_data_field import PassportElementErrorDataField +from .passport_element_error_file import PassportElementErrorFile +from .passport_element_error_files import PassportElementErrorFiles +from .passport_element_error_front_side import PassportElementErrorFrontSide +from .passport_element_error_reverse_side import PassportElementErrorReverseSide +from .passport_element_error_selfie import PassportElementErrorSelfie +from .passport_element_error_translation_file import PassportElementErrorTranslationFile +from .passport_element_error_translation_files import ( + PassportElementErrorTranslationFiles, +) +from .passport_element_error_unspecified import PassportElementErrorUnspecified + +PassportElementErrorUnion = Union[ + PassportElementErrorDataField, + PassportElementErrorFrontSide, + PassportElementErrorReverseSide, + PassportElementErrorSelfie, + PassportElementErrorFile, + PassportElementErrorFiles, + PassportElementErrorTranslationFile, + PassportElementErrorTranslationFiles, + PassportElementErrorUnspecified, +] diff --git a/aiogram/types/reaction_count.py b/aiogram/types/reaction_count.py index e4ee167b..4a64f0eb 100644 --- a/aiogram/types/reaction_count.py +++ b/aiogram/types/reaction_count.py @@ -1,13 +1,11 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Union +from typing import TYPE_CHECKING, Any from .base import TelegramObject if TYPE_CHECKING: - from .reaction_type_custom_emoji import ReactionTypeCustomEmoji - from .reaction_type_emoji import ReactionTypeEmoji - from .reaction_type_paid import ReactionTypePaid + from .reaction_type_union import ReactionTypeUnion class ReactionCount(TelegramObject): @@ -17,7 +15,7 @@ class ReactionCount(TelegramObject): Source: https://core.telegram.org/bots/api#reactioncount """ - type: Union[ReactionTypeEmoji, ReactionTypeCustomEmoji, ReactionTypePaid] + type: ReactionTypeUnion """Type of the reaction""" total_count: int """Number of times the reaction was added""" @@ -29,7 +27,7 @@ class ReactionCount(TelegramObject): def __init__( __pydantic__self__, *, - type: Union[ReactionTypeEmoji, ReactionTypeCustomEmoji, ReactionTypePaid], + type: ReactionTypeUnion, total_count: int, **__pydantic_kwargs: Any, ) -> None: diff --git a/aiogram/types/reaction_type_union.py b/aiogram/types/reaction_type_union.py new file mode 100644 index 00000000..783370a1 --- /dev/null +++ b/aiogram/types/reaction_type_union.py @@ -0,0 +1,9 @@ +from __future__ import annotations + +from typing import Union + +from .reaction_type_custom_emoji import ReactionTypeCustomEmoji +from .reaction_type_emoji import ReactionTypeEmoji +from .reaction_type_paid import ReactionTypePaid + +ReactionTypeUnion = Union[ReactionTypeEmoji, ReactionTypeCustomEmoji, ReactionTypePaid] diff --git a/aiogram/types/reply_markup_union.py b/aiogram/types/reply_markup_union.py new file mode 100644 index 00000000..13516995 --- /dev/null +++ b/aiogram/types/reply_markup_union.py @@ -0,0 +1,12 @@ +from __future__ import annotations + +from typing import Union + +from .force_reply import ForceReply +from .inline_keyboard_markup import InlineKeyboardMarkup +from .reply_keyboard_markup import ReplyKeyboardMarkup +from .reply_keyboard_remove import ReplyKeyboardRemove + +ReplyMarkupUnion = Union[ + InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply +] diff --git a/aiogram/types/revenue_withdrawal_state_union.py b/aiogram/types/revenue_withdrawal_state_union.py new file mode 100644 index 00000000..be913c26 --- /dev/null +++ b/aiogram/types/revenue_withdrawal_state_union.py @@ -0,0 +1,11 @@ +from __future__ import annotations + +from typing import Union + +from .revenue_withdrawal_state_failed import RevenueWithdrawalStateFailed +from .revenue_withdrawal_state_pending import RevenueWithdrawalStatePending +from .revenue_withdrawal_state_succeeded import RevenueWithdrawalStateSucceeded + +RevenueWithdrawalStateUnion = Union[ + RevenueWithdrawalStatePending, RevenueWithdrawalStateSucceeded, RevenueWithdrawalStateFailed +] diff --git a/aiogram/types/star_transaction.py b/aiogram/types/star_transaction.py index 5f91c59a..c6c645fa 100644 --- a/aiogram/types/star_transaction.py +++ b/aiogram/types/star_transaction.py @@ -1,20 +1,12 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Optional, Union +from typing import TYPE_CHECKING, Any, Optional from .base import TelegramObject from .custom import DateTime if TYPE_CHECKING: - from .transaction_partner_affiliate_program import ( - TransactionPartnerAffiliateProgram, - ) - from .transaction_partner_chat import TransactionPartnerChat - from .transaction_partner_fragment import TransactionPartnerFragment - from .transaction_partner_other import TransactionPartnerOther - from .transaction_partner_telegram_ads import TransactionPartnerTelegramAds - from .transaction_partner_telegram_api import TransactionPartnerTelegramApi - from .transaction_partner_user import TransactionPartnerUser + from .transaction_partner_union import TransactionPartnerUnion class StarTransaction(TelegramObject): @@ -32,29 +24,9 @@ class StarTransaction(TelegramObject): """Date the transaction was created in Unix time""" nanostar_amount: Optional[int] = None """*Optional*. The number of 1/1000000000 shares of Telegram Stars transferred by the transaction; from 0 to 999999999""" - source: Optional[ - Union[ - TransactionPartnerUser, - TransactionPartnerChat, - TransactionPartnerAffiliateProgram, - TransactionPartnerFragment, - TransactionPartnerTelegramAds, - TransactionPartnerTelegramApi, - TransactionPartnerOther, - ] - ] = None + source: Optional[TransactionPartnerUnion] = None """*Optional*. Source of an incoming transaction (e.g., a user purchasing goods or services, Fragment refunding a failed withdrawal). Only for incoming transactions""" - receiver: Optional[ - Union[ - TransactionPartnerUser, - TransactionPartnerChat, - TransactionPartnerAffiliateProgram, - TransactionPartnerFragment, - TransactionPartnerTelegramAds, - TransactionPartnerTelegramApi, - TransactionPartnerOther, - ] - ] = None + receiver: Optional[TransactionPartnerUnion] = None """*Optional*. Receiver of an outgoing transaction (e.g., a user for a purchase refund, Fragment for a withdrawal). Only for outgoing transactions""" if TYPE_CHECKING: @@ -68,28 +40,8 @@ class StarTransaction(TelegramObject): amount: int, date: DateTime, nanostar_amount: Optional[int] = None, - source: Optional[ - Union[ - TransactionPartnerUser, - TransactionPartnerChat, - TransactionPartnerAffiliateProgram, - TransactionPartnerFragment, - TransactionPartnerTelegramAds, - TransactionPartnerTelegramApi, - TransactionPartnerOther, - ] - ] = None, - receiver: Optional[ - Union[ - TransactionPartnerUser, - TransactionPartnerChat, - TransactionPartnerAffiliateProgram, - TransactionPartnerFragment, - TransactionPartnerTelegramAds, - TransactionPartnerTelegramApi, - TransactionPartnerOther, - ] - ] = None, + source: Optional[TransactionPartnerUnion] = None, + receiver: Optional[TransactionPartnerUnion] = None, **__pydantic_kwargs: Any, ) -> None: # DO NOT EDIT MANUALLY!!! diff --git a/aiogram/types/transaction_partner_fragment.py b/aiogram/types/transaction_partner_fragment.py index 350109e0..000e2281 100644 --- a/aiogram/types/transaction_partner_fragment.py +++ b/aiogram/types/transaction_partner_fragment.py @@ -1,14 +1,12 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Literal, Optional, Union +from typing import TYPE_CHECKING, Any, Literal, Optional from ..enums import TransactionPartnerType from .transaction_partner import TransactionPartner if TYPE_CHECKING: - from .revenue_withdrawal_state_failed import RevenueWithdrawalStateFailed - from .revenue_withdrawal_state_pending import RevenueWithdrawalStatePending - from .revenue_withdrawal_state_succeeded import RevenueWithdrawalStateSucceeded + from .revenue_withdrawal_state_union import RevenueWithdrawalStateUnion class TransactionPartnerFragment(TransactionPartner): @@ -20,13 +18,7 @@ class TransactionPartnerFragment(TransactionPartner): type: Literal[TransactionPartnerType.FRAGMENT] = TransactionPartnerType.FRAGMENT """Type of the transaction partner, always 'fragment'""" - withdrawal_state: Optional[ - Union[ - RevenueWithdrawalStatePending, - RevenueWithdrawalStateSucceeded, - RevenueWithdrawalStateFailed, - ] - ] = None + withdrawal_state: Optional[RevenueWithdrawalStateUnion] = None """*Optional*. State of the transaction if the transaction is outgoing""" if TYPE_CHECKING: @@ -37,13 +29,7 @@ class TransactionPartnerFragment(TransactionPartner): __pydantic__self__, *, type: Literal[TransactionPartnerType.FRAGMENT] = TransactionPartnerType.FRAGMENT, - withdrawal_state: Optional[ - Union[ - RevenueWithdrawalStatePending, - RevenueWithdrawalStateSucceeded, - RevenueWithdrawalStateFailed, - ] - ] = None, + withdrawal_state: Optional[RevenueWithdrawalStateUnion] = None, **__pydantic_kwargs: Any, ) -> None: # DO NOT EDIT MANUALLY!!! diff --git a/aiogram/types/transaction_partner_union.py b/aiogram/types/transaction_partner_union.py new file mode 100644 index 00000000..efe4489a --- /dev/null +++ b/aiogram/types/transaction_partner_union.py @@ -0,0 +1,21 @@ +from __future__ import annotations + +from typing import Union + +from .transaction_partner_affiliate_program import TransactionPartnerAffiliateProgram +from .transaction_partner_chat import TransactionPartnerChat +from .transaction_partner_fragment import TransactionPartnerFragment +from .transaction_partner_other import TransactionPartnerOther +from .transaction_partner_telegram_ads import TransactionPartnerTelegramAds +from .transaction_partner_telegram_api import TransactionPartnerTelegramApi +from .transaction_partner_user import TransactionPartnerUser + +TransactionPartnerUnion = Union[ + TransactionPartnerUser, + TransactionPartnerChat, + TransactionPartnerAffiliateProgram, + TransactionPartnerFragment, + TransactionPartnerTelegramAds, + TransactionPartnerTelegramApi, + TransactionPartnerOther, +] diff --git a/aiogram/types/transaction_partner_user.py b/aiogram/types/transaction_partner_user.py index 16ccc652..610433bb 100644 --- a/aiogram/types/transaction_partner_user.py +++ b/aiogram/types/transaction_partner_user.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Literal, Optional, Union +from typing import TYPE_CHECKING, Any, Literal, Optional from ..enums import TransactionPartnerType from .transaction_partner import TransactionPartner @@ -8,9 +8,7 @@ from .transaction_partner import TransactionPartner if TYPE_CHECKING: from .affiliate_info import AffiliateInfo from .gift import Gift - from .paid_media_photo import PaidMediaPhoto - from .paid_media_preview import PaidMediaPreview - from .paid_media_video import PaidMediaVideo + from .paid_media_union import PaidMediaUnion from .user import User @@ -31,7 +29,7 @@ class TransactionPartnerUser(TransactionPartner): """*Optional*. Bot-specified invoice payload""" subscription_period: Optional[int] = None """*Optional*. The duration of the paid subscription""" - paid_media: Optional[list[Union[PaidMediaPreview, PaidMediaPhoto, PaidMediaVideo]]] = None + paid_media: Optional[list[PaidMediaUnion]] = None """*Optional*. Information about the paid media bought by the user""" paid_media_payload: Optional[str] = None """*Optional*. Bot-specified paid media payload""" @@ -50,9 +48,7 @@ class TransactionPartnerUser(TransactionPartner): affiliate: Optional[AffiliateInfo] = None, invoice_payload: Optional[str] = None, subscription_period: Optional[int] = None, - paid_media: Optional[ - list[Union[PaidMediaPreview, PaidMediaPhoto, PaidMediaVideo]] - ] = None, + paid_media: Optional[list[PaidMediaUnion]] = None, paid_media_payload: Optional[str] = None, gift: Optional[Gift] = None, **__pydantic_kwargs: Any,