From 7634587fa44e06efac3dd0e375b1cd7d64ff2aa1 Mon Sep 17 00:00:00 2001 From: JRoot Junior Date: Sat, 6 Jul 2024 19:33:47 +0300 Subject: [PATCH] Override InputPaidMedia media type to `str | InputFile` --- .butcher/types/InputPaidMediaPhoto/replace.yml | 11 +++++++++++ .butcher/types/InputPaidMediaVideo/replace.yml | 11 +++++++++++ aiogram/types/input_paid_media_photo.py | 7 ++++--- aiogram/types/input_paid_media_video.py | 4 ++-- 4 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 .butcher/types/InputPaidMediaPhoto/replace.yml create mode 100644 .butcher/types/InputPaidMediaVideo/replace.yml diff --git a/.butcher/types/InputPaidMediaPhoto/replace.yml b/.butcher/types/InputPaidMediaPhoto/replace.yml new file mode 100644 index 00000000..17ac606b --- /dev/null +++ b/.butcher/types/InputPaidMediaPhoto/replace.yml @@ -0,0 +1,11 @@ +annotations: + media: + parsed_type: + type: union + items: + - type: std + name: str + - type: entity + references: + category: types + name: InputFile diff --git a/.butcher/types/InputPaidMediaVideo/replace.yml b/.butcher/types/InputPaidMediaVideo/replace.yml new file mode 100644 index 00000000..17ac606b --- /dev/null +++ b/.butcher/types/InputPaidMediaVideo/replace.yml @@ -0,0 +1,11 @@ +annotations: + media: + parsed_type: + type: union + items: + - type: std + name: str + - type: entity + references: + category: types + name: InputFile diff --git a/aiogram/types/input_paid_media_photo.py b/aiogram/types/input_paid_media_photo.py index 3c7018cf..66b5201d 100644 --- a/aiogram/types/input_paid_media_photo.py +++ b/aiogram/types/input_paid_media_photo.py @@ -1,9 +1,10 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Literal +from typing import TYPE_CHECKING, Any, Literal, Union from ..enums import InputPaidMediaType from .input_paid_media import InputPaidMedia +from .input_file import InputFile class InputPaidMediaPhoto(InputPaidMedia): @@ -15,7 +16,7 @@ class InputPaidMediaPhoto(InputPaidMedia): type: Literal[InputPaidMediaType.PHOTO] = InputPaidMediaType.PHOTO """Type of the media, must be *photo*""" - media: str + media: Union[str, InputFile] """File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass 'attach://' to upload a new one using multipart/form-data under name. :ref:`More information on Sending Files » `""" if TYPE_CHECKING: @@ -26,7 +27,7 @@ class InputPaidMediaPhoto(InputPaidMedia): __pydantic__self__, *, type: Literal[InputPaidMediaType.PHOTO] = InputPaidMediaType.PHOTO, - media: str, + media: Union[str, InputFile], **__pydantic_kwargs: Any, ) -> None: # DO NOT EDIT MANUALLY!!! diff --git a/aiogram/types/input_paid_media_video.py b/aiogram/types/input_paid_media_video.py index df844054..4511afbb 100644 --- a/aiogram/types/input_paid_media_video.py +++ b/aiogram/types/input_paid_media_video.py @@ -16,7 +16,7 @@ class InputPaidMediaVideo(InputPaidMedia): type: Literal[InputPaidMediaType.VIDEO] = InputPaidMediaType.VIDEO """Type of the media, must be *video*""" - media: str + media: Union[str, InputFile] """File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass 'attach://' to upload a new one using multipart/form-data under name. :ref:`More information on Sending Files » `""" thumbnail: Optional[Union[InputFile, str]] = None """*Optional*. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass 'attach://' if the thumbnail was uploaded using multipart/form-data under . :ref:`More information on Sending Files » `""" @@ -37,7 +37,7 @@ class InputPaidMediaVideo(InputPaidMedia): __pydantic__self__, *, type: Literal[InputPaidMediaType.VIDEO] = InputPaidMediaType.VIDEO, - media: str, + media: Union[str, InputFile], thumbnail: Optional[Union[InputFile, str]] = None, width: Optional[int] = None, height: Optional[int] = None,