Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Clarify Documentation and Type Hints ofInput(Paid)Media#4762

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Bibo-Joshi merged 4 commits intomasterfromfix-inputmedia-docs/annotations
Apr 20, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletionschanges/unreleased/4762.PbcJGM8KPBMbKri3fdHKjh.toml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
documentation = "Clarify Documentation and Type Hints of ``InputMedia`` and ``InputPaidMedia``. Note that the ``media`` parameter accepts only objects of type ``str`` and ``InputFile``. The respective subclasses of ``Input(Paid)Media`` each accept a broader range of input type for the ``media`` parameter."
[[pull_requests]]
uid = "4762"
author_uid = "Bibo-Joshi"
closes_threads = []
20 changes: 6 additions & 14 deletionstelegram/_files/inputmedia.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -51,13 +51,8 @@ class InputMedia(TelegramObject):

Args:
media_type (:obj:`str`): Type of media that the instance represents.
media (:obj:`str` | :term:`file object` | :class:`~telegram.InputFile` | :obj:`bytes` | \
:class:`pathlib.Path` | :class:`telegram.Animation` | :class:`telegram.Audio` | \
:class:`telegram.Document` | :class:`telegram.PhotoSize` | \
:class:`telegram.Video`): File to send.
media (:obj:`str` | :class:`~telegram.InputFile`): File to send.
|fileinputnopath|
Lastly you can pass an existing telegram media object of the corresponding type
to send.
caption (:obj:`str`, optional): Caption of the media to be sent,
0-:tg-const:`telegram.constants.MessageLimit.CAPTION_LENGTH` characters after entities
parsing.
Expand DownExpand Up@@ -89,7 +84,7 @@ class InputMedia(TelegramObject):
def __init__(
self,
media_type: str,
media: Union[str, InputFile, MediaType],
media: Union[str, InputFile],
caption: Optional[str] = None,
caption_entities: Optional[Sequence[MessageEntity]] = None,
parse_mode: ODVInput[str] = DEFAULT_NONE,
Expand All@@ -98,7 +93,7 @@ def __init__(
):
super().__init__(api_kwargs=api_kwargs)
self.type: str = enum.get_member(constants.InputMediaType, media_type, media_type)
self.media: Union[str, InputFile, Animation, Audio, Document, PhotoSize, Video] = media
self.media: Union[str, InputFile] = media
self.caption: Optional[str] = caption
self.caption_entities: tuple[MessageEntity, ...] = parse_sequence_arg(caption_entities)
self.parse_mode: ODVInput[str] = parse_mode
Expand DownExpand Up@@ -129,11 +124,8 @@ class InputPaidMedia(TelegramObject):

Args:
type (:obj:`str`): Type of media that the instance represents.
media (:obj:`str` | :term:`file object` | :class:`~telegram.InputFile` | :obj:`bytes` | \
:class:`pathlib.Path` | :class:`telegram.PhotoSize` | :class:`telegram.Video`): File
media (:obj:`str` | :class:`~telegram.InputFile`): File
to send. |fileinputnopath|
Lastly you can pass an existing telegram media object of the corresponding type
to send.

Attributes:
type (:obj:`str`): Type of the input media.
Expand All@@ -150,13 +142,13 @@ class InputPaidMedia(TelegramObject):
def __init__(
self,
type: str, # pylint: disable=redefined-builtin
media: Union[str, InputFile, PhotoSize, Video],
media: Union[str, InputFile],
*,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
self.type: str = enum.get_member(constants.InputPaidMediaType, type, type)
self.media: Union[str, InputFile, PhotoSize, Video] = media
self.media: Union[str, InputFile] = media

self._freeze()

Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp