Explicit Type Annotations (#3508)

This commit is contained in:
Bibo-Joshi 2023-02-02 18:55:07 +01:00 committed by GitHub
parent 1701950a1d
commit 23d0bd8fe3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
137 changed files with 1353 additions and 1168 deletions

61
.github/workflows/type_completeness.yml vendored Normal file
View file

@ -0,0 +1,61 @@
name: Check Type Completeness
on:
pull_request:
branches:
- master
push:
branches:
- master
jobs:
test-type-completeness:
name: test-type-completeness
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: git fetch --depth=1 # https://github.com/actions/checkout/issues/329#issuecomment-674881489
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: 3.9
cache: 'pip'
cache-dependency-path: '**/requirements*.txt'
- name: Install Pyright
run: |
python -W ignore -m pip install pyright~=1.1.291
- name: Get Base Completeness
run: |
git checkout ${{ github.base_ref }}
pip install . -U
pyright --verifytypes telegram --ignoreexternal --outputjson > base.json || true
- name: Get PR Completeness
run: |
git checkout ${{ github.head_ref }}
pip install . -U
pyright --verifytypes telegram --ignoreexternal --outputjson > pr.json || true
- name: Compare Completeness
uses: jannekem/run-python-script-action@v1
with:
script: |
import json
import os
base = float(
json.load(open("base.json", "rb"))["typeCompleteness"]["completenessScore"]
)
pr = float(
json.load(open("pr.json", "rb"))["typeCompleteness"]["completenessScore"]
)
if pr < (base - 0.1):
text = f"This PR decreases type completeness by {round(base - pr, 3)} ❌"
set_summary(text)
error(text)
exit(1)
elif pr > (base + 0.1):
text = f"This PR increases type completeness by {round(pr - base, 3)} ✨"
set_summary(text)
print(text)
else:
text = f"This PR does not change type completeness by more than 0.1 ✅"
set_summary(text)
print(text)

View file

@ -565,6 +565,11 @@ def autodoc_process_bases(app, name, obj, option, bases: list):
# let's use a string representation of the object # let's use a string representation of the object
base = str(base) base = str(base)
# Special case for abstract context managers which are wrongly resoled for some reason
if base.startswith("typing.AbstractAsyncContextManager"):
bases[idx] = ":class:`contextlib.AbstractAsyncContextManager`"
continue
# Special case because base classes are in std lib: # Special case because base classes are in std lib:
if "StringEnum" in base == "<enum 'StringEnum'>": if "StringEnum" in base == "<enum 'StringEnum'>":
bases[idx] = ":class:`enum.Enum`" bases[idx] = ":class:`enum.Enum`"

View file

@ -5,7 +5,7 @@ telegram.ext.filters Module
The classes in `filters.py` are sorted alphabetically such that :bysource: still is readable The classes in `filters.py` are sorted alphabetically such that :bysource: still is readable
.. automodule:: telegram.ext.filters .. automodule:: telegram.ext.filters
:inherited-members: :inherited-members: BaseFilter, MessageFilter, UpdateFilter
:members: :members:
:show-inheritance: :show-inheritance:
:member-order: bysource :member-order: bysource

View file

@ -343,7 +343,7 @@ from ._writeaccessallowed import WriteAccessAllowed
#: :obj:`str`: The version of the `python-telegram-bot` library as string. #: :obj:`str`: The version of the `python-telegram-bot` library as string.
#: To get detailed information about the version number, please use :data:`__version_info__` #: To get detailed information about the version number, please use :data:`__version_info__`
#: instead. #: instead.
__version__ = _version.__version__ __version__: str = _version.__version__
#: :class:`typing.NamedTuple`: A tuple containing the five components of the version number: #: :class:`typing.NamedTuple`: A tuple containing the five components of the version number:
#: `major`, `minor`, `micro`, `releaselevel`, and `serial`. #: `major`, `minor`, `micro`, `releaselevel`, and `serial`.
#: All values except `releaselevel` are integers. #: All values except `releaselevel` are integers.
@ -352,13 +352,13 @@ __version__ = _version.__version__
#: ``__version_info__.major`` and so on. #: ``__version_info__.major`` and so on.
#: #:
#: .. versionadded:: 20.0 #: .. versionadded:: 20.0
__version_info__ = _version.__version_info__ __version_info__: _version.Version = _version.__version_info__
#: :obj:`str`: Shortcut for :const:`telegram.constants.BOT_API_VERSION`. #: :obj:`str`: Shortcut for :const:`telegram.constants.BOT_API_VERSION`.
#: #:
#: .. versionchanged:: 20.0 #: .. versionchanged:: 20.0
#: This constant was previously named ``bot_api_version``. #: This constant was previously named ``bot_api_version``.
__bot_api_version__ = _version.__bot_api_version__ __bot_api_version__: str = _version.__bot_api_version__
#: :class:`typing.NamedTuple`: Shortcut for :const:`telegram.constants.BOT_API_VERSION_INFO`. #: :class:`typing.NamedTuple`: Shortcut for :const:`telegram.constants.BOT_API_VERSION_INFO`.
#: #:
#: .. versionadded:: 20.0 #: .. versionadded:: 20.0
__bot_api_version_info__ = _version.__bot_api_version_info__ __bot_api_version_info__: constants._BotAPIVersion = _version.__bot_api_version_info__

View file

@ -36,6 +36,7 @@ def _git_revision() -> Optional[str]:
def print_ver_info() -> None: # skipcq: PY-D0003 def print_ver_info() -> None: # skipcq: PY-D0003
"""Prints version information for python-telegram-bot, the Bot API and Python."""
git_revision = _git_revision() git_revision = _git_revision()
print(f"python-telegram-bot {telegram_ver}" + (f" ({git_revision})" if git_revision else "")) print(f"python-telegram-bot {telegram_ver}" + (f" ({git_revision})" if git_revision else ""))
print(f"Bot API {BOT_API_VERSION}") print(f"Bot API {BOT_API_VERSION}")
@ -44,6 +45,7 @@ def print_ver_info() -> None: # skipcq: PY-D0003
def main() -> None: # skipcq: PY-D0003 def main() -> None: # skipcq: PY-D0003
"""Prints version information for python-telegram-bot, the Bot API and Python."""
print_ver_info() print_ver_info()

View file

@ -23,12 +23,12 @@ import copy
import functools import functools
import logging import logging
import pickle import pickle
from contextlib import AbstractAsyncContextManager
from datetime import datetime from datetime import datetime
from types import TracebackType from types import TracebackType
from typing import ( from typing import (
TYPE_CHECKING, TYPE_CHECKING,
Any, Any,
AsyncContextManager,
Callable, Callable,
Dict, Dict,
List, List,
@ -114,7 +114,7 @@ if TYPE_CHECKING:
BT = TypeVar("BT", bound="Bot") BT = TypeVar("BT", bound="Bot")
class Bot(TelegramObject, AbstractAsyncContextManager): class Bot(TelegramObject, AsyncContextManager["Bot"]):
"""This object represents a Telegram Bot. """This object represents a Telegram Bot.
Instances of this class can be used as asyncio context managers, where Instances of this class can be used as asyncio context managers, where
@ -229,13 +229,13 @@ class Bot(TelegramObject, AbstractAsyncContextManager):
super().__init__(api_kwargs=None) super().__init__(api_kwargs=None)
if not token: if not token:
raise InvalidToken("You must pass the token you received from https://t.me/Botfather!") raise InvalidToken("You must pass the token you received from https://t.me/Botfather!")
self._token = token self._token: str = token
self._base_url = base_url + self._token self._base_url: str = base_url + self._token
self._base_file_url = base_file_url + self._token self._base_file_url: str = base_file_url + self._token
self._local_mode = local_mode self._local_mode: bool = local_mode
self._bot_user: Optional[User] = None self._bot_user: Optional[User] = None
self._private_key = None self._private_key: Optional[bytes] = None
self._logger = logging.getLogger(__name__) self._logger = logging.getLogger(__name__)
self._initialized = False self._initialized = False
@ -312,7 +312,7 @@ class Bot(TelegramObject, AbstractAsyncContextManager):
""" """
raise pickle.PicklingError("Bot objects cannot be pickled!") raise pickle.PicklingError("Bot objects cannot be pickled!")
def __deepcopy__(self, memodict: dict) -> NoReturn: def __deepcopy__(self, memodict: Dict[int, object]) -> NoReturn:
"""Customizes how :func:`copy.deepcopy` processes objects of this type. Bots can not """Customizes how :func:`copy.deepcopy` processes objects of this type. Bots can not
be deepcopied and this method will always raise an exception. be deepcopied and this method will always raise an exception.

View file

@ -54,8 +54,8 @@ class BotCommand(TelegramObject):
def __init__(self, command: str, description: str, *, api_kwargs: JSONDict = None): def __init__(self, command: str, description: str, *, api_kwargs: JSONDict = None):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
self.command = command self.command: str = command
self.description = description self.description: str = description
self._id_attrs = (self.command, self.description) self._id_attrs = (self.command, self.description)

View file

@ -77,7 +77,7 @@ class BotCommandScope(TelegramObject):
def __init__(self, type: str, *, api_kwargs: JSONDict = None): def __init__(self, type: str, *, api_kwargs: JSONDict = None):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
self.type = type self.type: str = type
self._id_attrs = (self.type,) self._id_attrs = (self.type,)
self._freeze() self._freeze()
@ -200,7 +200,7 @@ class BotCommandScopeChat(BotCommandScope):
def __init__(self, chat_id: Union[str, int], *, api_kwargs: JSONDict = None): def __init__(self, chat_id: Union[str, int], *, api_kwargs: JSONDict = None):
super().__init__(type=BotCommandScope.CHAT, api_kwargs=api_kwargs) super().__init__(type=BotCommandScope.CHAT, api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
self.chat_id = ( self.chat_id: Union[str, int] = (
chat_id if isinstance(chat_id, str) and chat_id.startswith("@") else int(chat_id) chat_id if isinstance(chat_id, str) and chat_id.startswith("@") else int(chat_id)
) )
self._id_attrs = (self.type, self.chat_id) self._id_attrs = (self.type, self.chat_id)
@ -227,7 +227,7 @@ class BotCommandScopeChatAdministrators(BotCommandScope):
def __init__(self, chat_id: Union[str, int], *, api_kwargs: JSONDict = None): def __init__(self, chat_id: Union[str, int], *, api_kwargs: JSONDict = None):
super().__init__(type=BotCommandScope.CHAT_ADMINISTRATORS, api_kwargs=api_kwargs) super().__init__(type=BotCommandScope.CHAT_ADMINISTRATORS, api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
self.chat_id = ( self.chat_id: Union[str, int] = (
chat_id if isinstance(chat_id, str) and chat_id.startswith("@") else int(chat_id) chat_id if isinstance(chat_id, str) and chat_id.startswith("@") else int(chat_id)
) )
self._id_attrs = (self.type, self.chat_id) self._id_attrs = (self.type, self.chat_id)
@ -257,8 +257,8 @@ class BotCommandScopeChatMember(BotCommandScope):
def __init__(self, chat_id: Union[str, int], user_id: int, *, api_kwargs: JSONDict = None): def __init__(self, chat_id: Union[str, int], user_id: int, *, api_kwargs: JSONDict = None):
super().__init__(type=BotCommandScope.CHAT_MEMBER, api_kwargs=api_kwargs) super().__init__(type=BotCommandScope.CHAT_MEMBER, api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
self.chat_id = ( self.chat_id: Union[str, int] = (
chat_id if isinstance(chat_id, str) and chat_id.startswith("@") else int(chat_id) chat_id if isinstance(chat_id, str) and chat_id.startswith("@") else int(chat_id)
) )
self.user_id = user_id self.user_id: int = user_id
self._id_attrs = (self.type, self.chat_id, self.user_id) self._id_attrs = (self.type, self.chat_id, self.user_id)

View file

@ -127,14 +127,14 @@ class CallbackQuery(TelegramObject):
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
# Required # Required
self.id = id # pylint: disable=invalid-name self.id: str = id # pylint: disable=invalid-name
self.from_user = from_user self.from_user: User = from_user
self.chat_instance = chat_instance self.chat_instance: str = chat_instance
# Optionals # Optionals
self.message = message self.message: Optional[Message] = message
self.data = data self.data: Optional[str] = data
self.inline_message_id = inline_message_id self.inline_message_id: Optional[str] = inline_message_id
self.game_short_name = game_short_name self.game_short_name: Optional[str] = game_short_name
self._id_attrs = (self.id,) self._id_attrs = (self.id,)

View file

@ -352,37 +352,39 @@ class Chat(TelegramObject):
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
# Required # Required
self.id = id # pylint: disable=invalid-name self.id: int = id # pylint: disable=invalid-name
self.type = enum.get_member(constants.ChatType, type, type) self.type: str = enum.get_member(constants.ChatType, type, type)
# Optionals # Optionals
self.title = title self.title: Optional[str] = title
self.username = username self.username: Optional[str] = username
self.first_name = first_name self.first_name: Optional[str] = first_name
self.last_name = last_name self.last_name: Optional[str] = last_name
self.photo = photo self.photo: Optional[ChatPhoto] = photo
self.bio = bio self.bio: Optional[str] = bio
self.has_private_forwards = has_private_forwards self.has_private_forwards: Optional[bool] = has_private_forwards
self.description = description self.description: Optional[str] = description
self.invite_link = invite_link self.invite_link: Optional[str] = invite_link
self.pinned_message = pinned_message self.pinned_message: Optional[Message] = pinned_message
self.permissions = permissions self.permissions: Optional[ChatPermissions] = permissions
self.slow_mode_delay = slow_mode_delay self.slow_mode_delay: Optional[int] = slow_mode_delay
self.message_auto_delete_time = ( self.message_auto_delete_time: Optional[int] = (
int(message_auto_delete_time) if message_auto_delete_time is not None else None int(message_auto_delete_time) if message_auto_delete_time is not None else None
) )
self.has_protected_content = has_protected_content self.has_protected_content: Optional[bool] = has_protected_content
self.sticker_set_name = sticker_set_name self.sticker_set_name: Optional[str] = sticker_set_name
self.can_set_sticker_set = can_set_sticker_set self.can_set_sticker_set: Optional[bool] = can_set_sticker_set
self.linked_chat_id = linked_chat_id self.linked_chat_id: Optional[int] = linked_chat_id
self.location = location self.location: Optional[ChatLocation] = location
self.join_to_send_messages = join_to_send_messages self.join_to_send_messages: Optional[bool] = join_to_send_messages
self.join_by_request = join_by_request self.join_by_request: Optional[bool] = join_by_request
self.has_restricted_voice_and_video_messages = has_restricted_voice_and_video_messages self.has_restricted_voice_and_video_messages: Optional[
self.is_forum = is_forum bool
self.active_usernames = parse_sequence_arg(active_usernames) ] = has_restricted_voice_and_video_messages
self.emoji_status_custom_emoji_id = emoji_status_custom_emoji_id self.is_forum: Optional[bool] = is_forum
self.has_aggressive_anti_spam_enabled = has_aggressive_anti_spam_enabled self.active_usernames: Tuple[str, ...] = parse_sequence_arg(active_usernames)
self.has_hidden_members = has_hidden_members self.emoji_status_custom_emoji_id: Optional[str] = emoji_status_custom_emoji_id
self.has_aggressive_anti_spam_enabled: Optional[bool] = has_aggressive_anti_spam_enabled
self.has_hidden_members: Optional[bool] = has_hidden_members
self._id_attrs = (self.id,) self._id_attrs = (self.id,)

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the class which represents a Telegram ChatAdministratorRights.""" """This module contains the class which represents a Telegram ChatAdministratorRights."""
from typing import Optional
from telegram._telegramobject import TelegramObject from telegram._telegramobject import TelegramObject
from telegram._utils.types import JSONDict from telegram._utils.types import JSONDict
@ -138,19 +139,19 @@ class ChatAdministratorRights(TelegramObject):
) -> None: ) -> None:
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
# Required # Required
self.is_anonymous = is_anonymous self.is_anonymous: bool = is_anonymous
self.can_manage_chat = can_manage_chat self.can_manage_chat: bool = can_manage_chat
self.can_delete_messages = can_delete_messages self.can_delete_messages: bool = can_delete_messages
self.can_manage_video_chats = can_manage_video_chats self.can_manage_video_chats: bool = can_manage_video_chats
self.can_restrict_members = can_restrict_members self.can_restrict_members: bool = can_restrict_members
self.can_promote_members = can_promote_members self.can_promote_members: bool = can_promote_members
self.can_change_info = can_change_info self.can_change_info: bool = can_change_info
self.can_invite_users = can_invite_users self.can_invite_users: bool = can_invite_users
# Optionals # Optionals
self.can_post_messages = can_post_messages self.can_post_messages: Optional[bool] = can_post_messages
self.can_edit_messages = can_edit_messages self.can_edit_messages: Optional[bool] = can_edit_messages
self.can_pin_messages = can_pin_messages self.can_pin_messages: Optional[bool] = can_pin_messages
self.can_manage_topics = can_manage_topics self.can_manage_topics: Optional[bool] = can_manage_topics
self._id_attrs = ( self._id_attrs = (
self.is_anonymous, self.is_anonymous,

View file

@ -121,17 +121,17 @@ class ChatInviteLink(TelegramObject):
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
# Required # Required
self.invite_link = invite_link self.invite_link: str = invite_link
self.creator = creator self.creator: User = creator
self.creates_join_request = creates_join_request self.creates_join_request: bool = creates_join_request
self.is_primary = is_primary self.is_primary: bool = is_primary
self.is_revoked = is_revoked self.is_revoked: bool = is_revoked
# Optionals # Optionals
self.expire_date = expire_date self.expire_date: Optional[datetime.datetime] = expire_date
self.member_limit = member_limit self.member_limit: Optional[int] = member_limit
self.name = name self.name: Optional[str] = name
self.pending_join_request_count = ( self.pending_join_request_count: Optional[int] = (
int(pending_join_request_count) if pending_join_request_count is not None else None int(pending_join_request_count) if pending_join_request_count is not None else None
) )
self._id_attrs = ( self._id_attrs = (

View file

@ -78,13 +78,13 @@ class ChatJoinRequest(TelegramObject):
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
# Required # Required
self.chat = chat self.chat: Chat = chat
self.from_user = from_user self.from_user: User = from_user
self.date = date self.date: datetime.datetime = date
# Optionals # Optionals
self.bio = bio self.bio: Optional[str] = bio
self.invite_link = invite_link self.invite_link: Optional[ChatInviteLink] = invite_link
self._id_attrs = (self.chat, self.from_user, self.date) self._id_attrs = (self.chat, self.from_user, self.date)

View file

@ -60,8 +60,8 @@ class ChatLocation(TelegramObject):
api_kwargs: JSONDict = None, api_kwargs: JSONDict = None,
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
self.location = location self.location: Location = location
self.address = address self.address: str = address
self._id_attrs = (self.location,) self._id_attrs = (self.location,)

View file

@ -96,8 +96,8 @@ class ChatMember(TelegramObject):
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
# Required by all subclasses # Required by all subclasses
self.user = user self.user: User = user
self.status = status self.status: str = status
self._id_attrs = (self.user, self.status) self._id_attrs = (self.user, self.status)
@ -165,8 +165,8 @@ class ChatMemberOwner(ChatMember):
): ):
super().__init__(status=ChatMember.OWNER, user=user, api_kwargs=api_kwargs) super().__init__(status=ChatMember.OWNER, user=user, api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
self.is_anonymous = is_anonymous self.is_anonymous: bool = is_anonymous
self.custom_title = custom_title self.custom_title: Optional[str] = custom_title
class ChatMemberAdministrator(ChatMember): class ChatMemberAdministrator(ChatMember):
@ -302,20 +302,20 @@ class ChatMemberAdministrator(ChatMember):
): ):
super().__init__(status=ChatMember.ADMINISTRATOR, user=user, api_kwargs=api_kwargs) super().__init__(status=ChatMember.ADMINISTRATOR, user=user, api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
self.can_be_edited = can_be_edited self.can_be_edited: bool = can_be_edited
self.is_anonymous = is_anonymous self.is_anonymous: bool = is_anonymous
self.can_manage_chat = can_manage_chat self.can_manage_chat: bool = can_manage_chat
self.can_delete_messages = can_delete_messages self.can_delete_messages: bool = can_delete_messages
self.can_manage_video_chats = can_manage_video_chats self.can_manage_video_chats: bool = can_manage_video_chats
self.can_restrict_members = can_restrict_members self.can_restrict_members: bool = can_restrict_members
self.can_promote_members = can_promote_members self.can_promote_members: bool = can_promote_members
self.can_change_info = can_change_info self.can_change_info: bool = can_change_info
self.can_invite_users = can_invite_users self.can_invite_users: bool = can_invite_users
self.can_post_messages = can_post_messages self.can_post_messages: Optional[bool] = can_post_messages
self.can_edit_messages = can_edit_messages self.can_edit_messages: Optional[bool] = can_edit_messages
self.can_pin_messages = can_pin_messages self.can_pin_messages: Optional[bool] = can_pin_messages
self.can_manage_topics = can_manage_topics self.can_manage_topics: Optional[bool] = can_manage_topics
self.custom_title = custom_title self.custom_title: Optional[str] = custom_title
class ChatMemberMember(ChatMember): class ChatMemberMember(ChatMember):
@ -448,17 +448,17 @@ class ChatMemberRestricted(ChatMember):
): ):
super().__init__(status=ChatMember.RESTRICTED, user=user, api_kwargs=api_kwargs) super().__init__(status=ChatMember.RESTRICTED, user=user, api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
self.is_member = is_member self.is_member: bool = is_member
self.can_change_info = can_change_info self.can_change_info: bool = can_change_info
self.can_invite_users = can_invite_users self.can_invite_users: bool = can_invite_users
self.can_pin_messages = can_pin_messages self.can_pin_messages: bool = can_pin_messages
self.can_send_messages = can_send_messages self.can_send_messages: bool = can_send_messages
self.can_send_media_messages = can_send_media_messages self.can_send_media_messages: bool = can_send_media_messages
self.can_send_polls = can_send_polls self.can_send_polls: bool = can_send_polls
self.can_send_other_messages = can_send_other_messages self.can_send_other_messages: bool = can_send_other_messages
self.can_add_web_page_previews = can_add_web_page_previews self.can_add_web_page_previews: bool = can_add_web_page_previews
self.can_manage_topics = can_manage_topics self.can_manage_topics: bool = can_manage_topics
self.until_date = until_date self.until_date: datetime.datetime = until_date
class ChatMemberLeft(ChatMember): class ChatMemberLeft(ChatMember):
@ -521,4 +521,4 @@ class ChatMemberBanned(ChatMember):
): ):
super().__init__(status=ChatMember.BANNED, user=user, api_kwargs=api_kwargs) super().__init__(status=ChatMember.BANNED, user=user, api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
self.until_date = until_date self.until_date: datetime.datetime = until_date

View file

@ -91,14 +91,14 @@ class ChatMemberUpdated(TelegramObject):
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
# Required # Required
self.chat = chat self.chat: Chat = chat
self.from_user = from_user self.from_user: User = from_user
self.date = date self.date: datetime.datetime = date
self.old_chat_member = old_chat_member self.old_chat_member: ChatMember = old_chat_member
self.new_chat_member = new_chat_member self.new_chat_member: ChatMember = new_chat_member
# Optionals # Optionals
self.invite_link = invite_link self.invite_link: Optional[ChatInviteLink] = invite_link
self._id_attrs = ( self._id_attrs = (
self.chat, self.chat,

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram ChatPermission.""" """This module contains an object that represents a Telegram ChatPermission."""
from typing import Optional
from telegram._telegramobject import TelegramObject from telegram._telegramobject import TelegramObject
from telegram._utils.types import JSONDict from telegram._utils.types import JSONDict
@ -120,15 +121,15 @@ class ChatPermissions(TelegramObject):
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
# Required # Required
self.can_send_messages = can_send_messages self.can_send_messages: Optional[bool] = can_send_messages
self.can_send_media_messages = can_send_media_messages self.can_send_media_messages: Optional[bool] = can_send_media_messages
self.can_send_polls = can_send_polls self.can_send_polls: Optional[bool] = can_send_polls
self.can_send_other_messages = can_send_other_messages self.can_send_other_messages: Optional[bool] = can_send_other_messages
self.can_add_web_page_previews = can_add_web_page_previews self.can_add_web_page_previews: Optional[bool] = can_add_web_page_previews
self.can_change_info = can_change_info self.can_change_info: Optional[bool] = can_change_info
self.can_invite_users = can_invite_users self.can_invite_users: Optional[bool] = can_invite_users
self.can_pin_messages = can_pin_messages self.can_pin_messages: Optional[bool] = can_pin_messages
self.can_manage_topics = can_manage_topics self.can_manage_topics: Optional[bool] = can_manage_topics
self._id_attrs = ( self._id_attrs = (
self.can_send_messages, self.can_send_messages,

View file

@ -80,12 +80,12 @@ class ChosenInlineResult(TelegramObject):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
# Required # Required
self.result_id = result_id self.result_id: str = result_id
self.from_user = from_user self.from_user: User = from_user
self.query = query self.query: str = query
# Optionals # Optionals
self.location = location self.location: Optional[Location] = location
self.inline_message_id = inline_message_id self.inline_message_id: Optional[str] = inline_message_id
self._id_attrs = (self.result_id,) self._id_attrs = (self.result_id,)

View file

@ -91,8 +91,8 @@ class Dice(TelegramObject):
def __init__(self, value: int, emoji: str, *, api_kwargs: JSONDict = None): def __init__(self, value: int, emoji: str, *, api_kwargs: JSONDict = None):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
self.value = value self.value: int = value
self.emoji = emoji self.emoji: str = emoji
self._id_attrs = (self.value, self.emoji) self._id_attrs = (self.value, self.emoji)

View file

@ -17,7 +17,7 @@
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""Common base class for media objects""" """Common base class for media objects"""
from typing import TYPE_CHECKING from typing import TYPE_CHECKING, Optional
from telegram._telegramobject import TelegramObject from telegram._telegramobject import TelegramObject
from telegram._utils.defaultvalue import DEFAULT_NONE from telegram._utils.defaultvalue import DEFAULT_NONE
@ -64,9 +64,9 @@ class _BaseMedium(TelegramObject):
# Required # Required
self.file_id: str = str(file_id) self.file_id: str = str(file_id)
self.file_unique_id = str(file_unique_id) self.file_unique_id: str = str(file_unique_id)
# Optionals # Optionals
self.file_size = file_size self.file_size: Optional[int] = file_size
self._id_attrs = (self.file_unique_id,) self._id_attrs = (self.file_unique_id,)

View file

@ -74,7 +74,7 @@ class _BaseThumbedMedium(_BaseMedium):
file_size=file_size, file_size=file_size,
api_kwargs=api_kwargs, api_kwargs=api_kwargs,
) )
self.thumb = thumb self.thumb: Optional[PhotoSize] = thumb
@classmethod @classmethod
def de_json( def de_json(

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram Animation.""" """This module contains an object that represents a Telegram Animation."""
from typing import Optional
from telegram._files._basethumbedmedium import _BaseThumbedMedium from telegram._files._basethumbedmedium import _BaseThumbedMedium
from telegram._files.photosize import PhotoSize from telegram._files.photosize import PhotoSize
@ -85,9 +86,9 @@ class Animation(_BaseThumbedMedium):
) )
with self._unfrozen(): with self._unfrozen():
# Required # Required
self.width = width self.width: int = width
self.height = height self.height: int = height
self.duration = duration self.duration: int = duration
# Optional # Optional
self.mime_type = mime_type self.mime_type: Optional[str] = mime_type
self.file_name = file_name self.file_name: Optional[str] = file_name

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram Audio.""" """This module contains an object that represents a Telegram Audio."""
from typing import Optional
from telegram._files._basethumbedmedium import _BaseThumbedMedium from telegram._files._basethumbedmedium import _BaseThumbedMedium
from telegram._files.photosize import PhotoSize from telegram._files.photosize import PhotoSize
@ -88,9 +89,9 @@ class Audio(_BaseThumbedMedium):
) )
with self._unfrozen(): with self._unfrozen():
# Required # Required
self.duration = duration self.duration: int = duration
# Optional # Optional
self.performer = performer self.performer: Optional[str] = performer
self.title = title self.title: Optional[str] = title
self.mime_type = mime_type self.mime_type: Optional[str] = mime_type
self.file_name = file_name self.file_name: Optional[str] = file_name

View file

@ -90,10 +90,10 @@ class ChatPhoto(TelegramObject):
api_kwargs: JSONDict = None, api_kwargs: JSONDict = None,
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
self.small_file_id = small_file_id self.small_file_id: str = small_file_id
self.small_file_unique_id = small_file_unique_id self.small_file_unique_id: str = small_file_unique_id
self.big_file_id = big_file_id self.big_file_id: str = big_file_id
self.big_file_unique_id = big_file_unique_id self.big_file_unique_id: str = big_file_unique_id
self._id_attrs = ( self._id_attrs = (
self.small_file_unique_id, self.small_file_unique_id,

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram Contact.""" """This module contains an object that represents a Telegram Contact."""
from typing import Optional
from telegram._telegramobject import TelegramObject from telegram._telegramobject import TelegramObject
from telegram._utils.types import JSONDict from telegram._utils.types import JSONDict
@ -58,12 +59,12 @@ class Contact(TelegramObject):
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
# Required # Required
self.phone_number = str(phone_number) self.phone_number: str = str(phone_number)
self.first_name = first_name self.first_name: str = first_name
# Optionals # Optionals
self.last_name = last_name self.last_name: Optional[str] = last_name
self.user_id = user_id self.user_id: Optional[int] = user_id
self.vcard = vcard self.vcard: Optional[str] = vcard
self._id_attrs = (self.phone_number,) self._id_attrs = (self.phone_number,)

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram Document.""" """This module contains an object that represents a Telegram Document."""
from typing import Optional
from telegram._files._basethumbedmedium import _BaseThumbedMedium from telegram._files._basethumbedmedium import _BaseThumbedMedium
from telegram._files.photosize import PhotoSize from telegram._files.photosize import PhotoSize
@ -74,5 +75,5 @@ class Document(_BaseThumbedMedium):
) )
with self._unfrozen(): with self._unfrozen():
# Optional # Optional
self.mime_type = mime_type self.mime_type: Optional[str] = mime_type
self.file_name = file_name self.file_name: Optional[str] = file_name

View file

@ -93,11 +93,11 @@ class File(TelegramObject):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
# Required # Required
self.file_id = str(file_id) self.file_id: str = str(file_id)
self.file_unique_id = str(file_unique_id) self.file_unique_id: str = str(file_unique_id)
# Optionals # Optionals
self.file_size = file_size self.file_size: Optional[int] = file_size
self.file_path = file_path self.file_path: Optional[str] = file_path
self._credentials: Optional["FileCredentials"] = None self._credentials: Optional["FileCredentials"] = None

View file

@ -71,7 +71,7 @@ class InputFile:
self, obj: Union[IO[bytes], bytes, str], filename: str = None, attach: bool = False self, obj: Union[IO[bytes], bytes, str], filename: str = None, attach: bool = False
): ):
if isinstance(obj, bytes): if isinstance(obj, bytes):
self.input_file_content = obj self.input_file_content: bytes = obj
elif isinstance(obj, str): elif isinstance(obj, str):
self.input_file_content = obj.encode("utf-8") self.input_file_content = obj.encode("utf-8")
else: else:
@ -81,11 +81,13 @@ class InputFile:
self.attach_name: Optional[str] = "attached" + uuid4().hex if attach else None self.attach_name: Optional[str] = "attached" + uuid4().hex if attach else None
if filename: if filename:
self.mimetype = mimetypes.guess_type(filename, strict=False)[0] or _DEFAULT_MIME_TYPE self.mimetype: str = (
mimetypes.guess_type(filename, strict=False)[0] or _DEFAULT_MIME_TYPE
)
else: else:
self.mimetype = _DEFAULT_MIME_TYPE self.mimetype = _DEFAULT_MIME_TYPE
self.filename = filename or self.mimetype.replace("/", ".") self.filename: str = filename or self.mimetype.replace("/", ".")
@property @property
def field_tuple(self) -> FieldTuple: def field_tuple(self) -> FieldTuple:

View file

@ -17,7 +17,7 @@
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""Base class for Telegram InputMedia Objects.""" """Base class for Telegram InputMedia Objects."""
from typing import Optional, Sequence, Union from typing import Optional, Sequence, Tuple, Union
from telegram._files.animation import Animation from telegram._files.animation import Animation
from telegram._files.audio import Audio from telegram._files.audio import Audio
@ -94,11 +94,11 @@ class InputMedia(TelegramObject):
api_kwargs: JSONDict = None, api_kwargs: JSONDict = None,
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
self.type = media_type self.type: str = media_type
self.media = media self.media: Union[str, InputFile, Animation, Audio, Document, PhotoSize, Video] = media
self.caption = caption self.caption: Optional[str] = caption
self.caption_entities = parse_sequence_arg(caption_entities) self.caption_entities: Tuple[MessageEntity, ...] = parse_sequence_arg(caption_entities)
self.parse_mode = parse_mode self.parse_mode: ODVInput[str] = parse_mode
self._freeze() self._freeze()
@ -214,11 +214,11 @@ class InputMediaAnimation(InputMedia):
api_kwargs=api_kwargs, api_kwargs=api_kwargs,
) )
with self._unfrozen(): with self._unfrozen():
self.thumb = self._parse_thumb_input(thumb) self.thumb: Optional[Union[str, InputFile]] = self._parse_thumb_input(thumb)
self.width = width self.width: Optional[int] = width
self.height = height self.height: Optional[int] = height
self.duration = duration self.duration: Optional[int] = duration
self.has_spoiler = has_spoiler self.has_spoiler: Optional[bool] = has_spoiler
class InputMediaPhoto(InputMedia): class InputMediaPhoto(InputMedia):
@ -296,7 +296,7 @@ class InputMediaPhoto(InputMedia):
) )
with self._unfrozen(): with self._unfrozen():
self.has_spoiler = has_spoiler self.has_spoiler: Optional[bool] = has_spoiler
class InputMediaVideo(InputMedia): class InputMediaVideo(InputMedia):
@ -411,12 +411,12 @@ class InputMediaVideo(InputMedia):
api_kwargs=api_kwargs, api_kwargs=api_kwargs,
) )
with self._unfrozen(): with self._unfrozen():
self.width = width self.width: Optional[int] = width
self.height = height self.height: Optional[int] = height
self.duration = duration self.duration: Optional[int] = duration
self.thumb = self._parse_thumb_input(thumb) self.thumb: Optional[Union[str, InputFile]] = self._parse_thumb_input(thumb)
self.supports_streaming = supports_streaming self.supports_streaming: Optional[bool] = supports_streaming
self.has_spoiler = has_spoiler self.has_spoiler: Optional[bool] = has_spoiler
class InputMediaAudio(InputMedia): class InputMediaAudio(InputMedia):
@ -516,10 +516,10 @@ class InputMediaAudio(InputMedia):
api_kwargs=api_kwargs, api_kwargs=api_kwargs,
) )
with self._unfrozen(): with self._unfrozen():
self.thumb = self._parse_thumb_input(thumb) self.thumb: Optional[Union[str, InputFile]] = self._parse_thumb_input(thumb)
self.duration = duration self.duration: Optional[int] = duration
self.title = title self.title: Optional[str] = title
self.performer = performer self.performer: Optional[str] = performer
class InputMediaDocument(InputMedia): class InputMediaDocument(InputMedia):
@ -603,5 +603,5 @@ class InputMediaDocument(InputMedia):
api_kwargs=api_kwargs, api_kwargs=api_kwargs,
) )
with self._unfrozen(): with self._unfrozen():
self.thumb = self._parse_thumb_input(thumb) self.thumb: Optional[Union[str, InputFile]] = self._parse_thumb_input(thumb)
self.disable_content_type_detection = disable_content_type_detection self.disable_content_type_detection: Optional[bool] = disable_content_type_detection

View file

@ -18,7 +18,7 @@
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram Location.""" """This module contains an object that represents a Telegram Location."""
from typing import ClassVar from typing import ClassVar, Optional
from telegram import constants from telegram import constants
from telegram._telegramobject import TelegramObject from telegram._telegramobject import TelegramObject
@ -81,14 +81,14 @@ class Location(TelegramObject):
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
# Required # Required
self.longitude = longitude self.longitude: float = longitude
self.latitude = latitude self.latitude: float = latitude
# Optionals # Optionals
self.horizontal_accuracy = horizontal_accuracy self.horizontal_accuracy: Optional[float] = horizontal_accuracy
self.live_period = live_period self.live_period: Optional[int] = live_period
self.heading = heading self.heading: Optional[int] = heading
self.proximity_alert_radius = ( self.proximity_alert_radius: Optional[int] = (
int(proximity_alert_radius) if proximity_alert_radius else None int(proximity_alert_radius) if proximity_alert_radius else None
) )

View file

@ -71,5 +71,5 @@ class PhotoSize(_BaseMedium):
) )
with self._unfrozen(): with self._unfrozen():
# Required # Required
self.width = width self.width: int = width
self.height = height self.height: int = height

View file

@ -17,7 +17,7 @@
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains objects that represent stickers.""" """This module contains objects that represent stickers."""
from typing import TYPE_CHECKING, ClassVar, Optional, Sequence from typing import TYPE_CHECKING, ClassVar, Optional, Sequence, Tuple
from telegram import constants from telegram import constants
from telegram._files._basethumbedmedium import _BaseThumbedMedium from telegram._files._basethumbedmedium import _BaseThumbedMedium
@ -152,17 +152,17 @@ class Sticker(_BaseThumbedMedium):
) )
with self._unfrozen(): with self._unfrozen():
# Required # Required
self.width = width self.width: int = width
self.height = height self.height: int = height
self.is_animated = is_animated self.is_animated: bool = is_animated
self.is_video = is_video self.is_video: bool = is_video
self.type = type self.type: str = type
# Optional # Optional
self.emoji = emoji self.emoji: Optional[str] = emoji
self.set_name = set_name self.set_name: Optional[str] = set_name
self.mask_position = mask_position self.mask_position: Optional[MaskPosition] = mask_position
self.premium_animation = premium_animation self.premium_animation: Optional[File] = premium_animation
self.custom_emoji_id = custom_emoji_id self.custom_emoji_id: Optional[str] = custom_emoji_id
REGULAR: ClassVar[str] = constants.StickerType.REGULAR REGULAR: ClassVar[str] = constants.StickerType.REGULAR
""":const:`telegram.constants.StickerType.REGULAR`""" """:const:`telegram.constants.StickerType.REGULAR`"""
@ -265,14 +265,14 @@ class StickerSet(TelegramObject):
api_kwargs: JSONDict = None, api_kwargs: JSONDict = None,
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
self.name = name self.name: str = name
self.title = title self.title: str = title
self.is_animated = is_animated self.is_animated: bool = is_animated
self.is_video = is_video self.is_video: bool = is_video
self.stickers = parse_sequence_arg(stickers) self.stickers: Tuple[Sticker, ...] = parse_sequence_arg(stickers)
self.sticker_type = sticker_type self.sticker_type: str = sticker_type
# Optional # Optional
self.thumb = thumb self.thumb: Optional[PhotoSize] = thumb
self._id_attrs = (self.name,) self._id_attrs = (self.name,)
@ -348,10 +348,10 @@ class MaskPosition(TelegramObject):
api_kwargs: JSONDict = None, api_kwargs: JSONDict = None,
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
self.point = point self.point: str = point
self.x_shift = x_shift self.x_shift: float = x_shift
self.y_shift = y_shift self.y_shift: float = y_shift
self.scale = scale self.scale: float = scale
self._id_attrs = (self.point, self.x_shift, self.y_shift, self.scale) self._id_attrs = (self.point, self.x_shift, self.y_shift, self.scale)

View file

@ -89,14 +89,14 @@ class Venue(TelegramObject):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
# Required # Required
self.location = location self.location: Location = location
self.title = title self.title: str = title
self.address = address self.address: str = address
# Optionals # Optionals
self.foursquare_id = foursquare_id self.foursquare_id: Optional[str] = foursquare_id
self.foursquare_type = foursquare_type self.foursquare_type: Optional[str] = foursquare_type
self.google_place_id = google_place_id self.google_place_id: Optional[str] = google_place_id
self.google_place_type = google_place_type self.google_place_type: Optional[str] = google_place_type
self._id_attrs = (self.location, self.title) self._id_attrs = (self.location, self.title)

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram Video.""" """This module contains an object that represents a Telegram Video."""
from typing import Optional
from telegram._files._basethumbedmedium import _BaseThumbedMedium from telegram._files._basethumbedmedium import _BaseThumbedMedium
from telegram._files.photosize import PhotoSize from telegram._files.photosize import PhotoSize
@ -84,9 +85,9 @@ class Video(_BaseThumbedMedium):
) )
with self._unfrozen(): with self._unfrozen():
# Required # Required
self.width = width self.width: int = width
self.height = height self.height: int = height
self.duration = duration self.duration: int = duration
# Optional # Optional
self.mime_type = mime_type self.mime_type: Optional[str] = mime_type
self.file_name = file_name self.file_name: Optional[str] = file_name

View file

@ -77,5 +77,5 @@ class VideoNote(_BaseThumbedMedium):
) )
with self._unfrozen(): with self._unfrozen():
# Required # Required
self.length = length self.length: int = length
self.duration = duration self.duration: int = duration

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram Voice.""" """This module contains an object that represents a Telegram Voice."""
from typing import Optional
from telegram._files._basemedium import _BaseMedium from telegram._files._basemedium import _BaseMedium
from telegram._utils.types import JSONDict from telegram._utils.types import JSONDict
@ -70,6 +71,6 @@ class Voice(_BaseMedium):
) )
with self._unfrozen(): with self._unfrozen():
# Required # Required
self.duration = duration self.duration: int = duration
# Optional # Optional
self.mime_type = mime_type self.mime_type: Optional[str] = mime_type

View file

@ -18,7 +18,7 @@
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram ForceReply.""" """This module contains an object that represents a Telegram ForceReply."""
from typing import ClassVar from typing import ClassVar, Optional
from telegram import constants from telegram import constants
from telegram._telegramobject import TelegramObject from telegram._telegramobject import TelegramObject
@ -85,9 +85,9 @@ class ForceReply(TelegramObject):
api_kwargs: JSONDict = None, api_kwargs: JSONDict = None,
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
self.force_reply = True self.force_reply: bool = True
self.selective = selective self.selective: Optional[bool] = selective
self.input_field_placeholder = input_field_placeholder self.input_field_placeholder: Optional[str] = input_field_placeholder
self._id_attrs = (self.selective,) self._id_attrs = (self.selective,)

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains objects related to Telegram forum topics.""" """This module contains objects related to Telegram forum topics."""
from typing import Optional
from telegram._telegramobject import TelegramObject from telegram._telegramobject import TelegramObject
from telegram._utils.types import JSONDict from telegram._utils.types import JSONDict
@ -59,10 +60,10 @@ class ForumTopic(TelegramObject):
api_kwargs: JSONDict = None, api_kwargs: JSONDict = None,
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
self.message_thread_id = message_thread_id self.message_thread_id: int = message_thread_id
self.name = name self.name: str = name
self.icon_color = icon_color self.icon_color: int = icon_color
self.icon_custom_emoji_id = icon_custom_emoji_id self.icon_custom_emoji_id: Optional[str] = icon_custom_emoji_id
self._id_attrs = (self.message_thread_id, self.name, self.icon_color) self._id_attrs = (self.message_thread_id, self.name, self.icon_color)
@ -103,9 +104,9 @@ class ForumTopicCreated(TelegramObject):
api_kwargs: JSONDict = None, api_kwargs: JSONDict = None,
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
self.name = name self.name: str = name
self.icon_color = icon_color self.icon_color: int = icon_color
self.icon_custom_emoji_id = icon_custom_emoji_id self.icon_custom_emoji_id: Optional[str] = icon_custom_emoji_id
self._id_attrs = (self.name, self.icon_color) self._id_attrs = (self.name, self.icon_color)
@ -174,8 +175,8 @@ class ForumTopicEdited(TelegramObject):
api_kwargs: JSONDict = None, api_kwargs: JSONDict = None,
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
self.name = name self.name: Optional[str] = name
self.icon_custom_emoji_id = icon_custom_emoji_id self.icon_custom_emoji_id: Optional[str] = icon_custom_emoji_id
self._id_attrs = (self.name, self.icon_custom_emoji_id) self._id_attrs = (self.name, self.icon_custom_emoji_id)

View file

@ -18,7 +18,7 @@
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram Game.""" """This module contains an object that represents a Telegram Game."""
import sys import sys
from typing import TYPE_CHECKING, Dict, List, Optional, Sequence from typing import TYPE_CHECKING, Dict, List, Optional, Sequence, Tuple
from telegram._files.animation import Animation from telegram._files.animation import Animation
from telegram._files.photosize import PhotoSize from telegram._files.photosize import PhotoSize
@ -110,13 +110,13 @@ class Game(TelegramObject):
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
# Required # Required
self.title = title self.title: str = title
self.description = description self.description: str = description
self.photo = parse_sequence_arg(photo) self.photo: Tuple[PhotoSize, ...] = parse_sequence_arg(photo)
# Optionals # Optionals
self.text = text self.text: Optional[str] = text
self.text_entities = parse_sequence_arg(text_entities) self.text_entities: Tuple[MessageEntity, ...] = parse_sequence_arg(text_entities)
self.animation = animation self.animation: Optional[Animation] = animation
self._id_attrs = (self.title, self.description, self.photo) self._id_attrs = (self.title, self.description, self.photo)

View file

@ -50,9 +50,9 @@ class GameHighScore(TelegramObject):
def __init__(self, position: int, user: User, score: int, *, api_kwargs: JSONDict = None): def __init__(self, position: int, user: User, score: int, *, api_kwargs: JSONDict = None):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
self.position = position self.position: int = position
self.user = user self.user: User = user
self.score = score self.score: int = score
self._id_attrs = (self.position, self.user, self.score) self._id_attrs = (self.position, self.user, self.score)

View file

@ -196,17 +196,17 @@ class InlineKeyboardButton(TelegramObject):
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
# Required # Required
self.text = text self.text: str = text
# Optionals # Optionals
self.url = url self.url: Optional[str] = url
self.login_url = login_url self.login_url: Optional[LoginUrl] = login_url
self.callback_data = callback_data self.callback_data: Optional[Union[str, object]] = callback_data
self.switch_inline_query = switch_inline_query self.switch_inline_query: Optional[str] = switch_inline_query
self.switch_inline_query_current_chat = switch_inline_query_current_chat self.switch_inline_query_current_chat: Optional[str] = switch_inline_query_current_chat
self.callback_game = callback_game self.callback_game: Optional[CallbackGame] = callback_game
self.pay = pay self.pay: Optional[bool] = pay
self.web_app = web_app self.web_app: Optional[WebAppInfo] = web_app
self._id_attrs = () self._id_attrs = ()
self._set_id_attrs() self._set_id_attrs()

View file

@ -17,7 +17,7 @@
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram InlineKeyboardMarkup.""" """This module contains an object that represents a Telegram InlineKeyboardMarkup."""
from typing import TYPE_CHECKING, Optional, Sequence from typing import TYPE_CHECKING, Optional, Sequence, Tuple
from telegram._inline.inlinekeyboardbutton import InlineKeyboardButton from telegram._inline.inlinekeyboardbutton import InlineKeyboardButton
from telegram._telegramobject import TelegramObject from telegram._telegramobject import TelegramObject
@ -72,7 +72,9 @@ class InlineKeyboardMarkup(TelegramObject):
"InlineKeyboardButtons" "InlineKeyboardButtons"
) )
# Required # Required
self.inline_keyboard = tuple(tuple(row) for row in inline_keyboard) self.inline_keyboard: Tuple[Tuple[InlineKeyboardButton, ...], ...] = tuple(
tuple(row) for row in inline_keyboard
)
self._id_attrs = (self.inline_keyboard,) self._id_attrs = (self.inline_keyboard,)

View file

@ -100,14 +100,14 @@ class InlineQuery(TelegramObject):
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
# Required # Required
self.id = id # pylint: disable=invalid-name self.id: str = id # pylint: disable=invalid-name
self.from_user = from_user self.from_user: User = from_user
self.query = query self.query: str = query
self.offset = offset self.offset: str = offset
# Optional # Optional
self.location = location self.location: Optional[Location] = location
self.chat_type = chat_type self.chat_type: Optional[str] = chat_type
self._id_attrs = (self.id,) self._id_attrs = (self.id,)

View file

@ -59,8 +59,8 @@ class InlineQueryResult(TelegramObject):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
# Required # Required
self.type = type self.type: str = type
self.id = str(id) # pylint: disable=invalid-name self.id: str = str(id) # pylint: disable=invalid-name
self._id_attrs = (self.id,) self._id_attrs = (self.id,)

View file

@ -18,7 +18,7 @@
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the classes that represent Telegram InlineQueryResultArticle.""" """This module contains the classes that represent Telegram InlineQueryResultArticle."""
from typing import TYPE_CHECKING from typing import TYPE_CHECKING, Optional
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from telegram._inline.inlinequeryresult import InlineQueryResult from telegram._inline.inlinequeryresult import InlineQueryResult
@ -103,14 +103,14 @@ class InlineQueryResultArticle(InlineQueryResult):
# Required # Required
super().__init__(InlineQueryResultType.ARTICLE, id, api_kwargs=api_kwargs) super().__init__(InlineQueryResultType.ARTICLE, id, api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
self.title = title self.title: str = title
self.input_message_content = input_message_content self.input_message_content: InputMessageContent = input_message_content
# Optional # Optional
self.reply_markup = reply_markup self.reply_markup: Optional[InlineKeyboardMarkup] = reply_markup
self.url = url self.url: Optional[str] = url
self.hide_url = hide_url self.hide_url: Optional[bool] = hide_url
self.description = description self.description: Optional[str] = description
self.thumb_url = thumb_url self.thumb_url: Optional[str] = thumb_url
self.thumb_width = thumb_width self.thumb_width: Optional[int] = thumb_width
self.thumb_height = thumb_height self.thumb_height: Optional[int] = thumb_height

View file

@ -17,7 +17,7 @@
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the classes that represent Telegram InlineQueryResultAudio.""" """This module contains the classes that represent Telegram InlineQueryResultAudio."""
from typing import TYPE_CHECKING, Sequence from typing import TYPE_CHECKING, Optional, Sequence, Tuple
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from telegram._inline.inlinequeryresult import InlineQueryResult from telegram._inline.inlinequeryresult import InlineQueryResult
@ -117,14 +117,14 @@ class InlineQueryResultAudio(InlineQueryResult):
# Required # Required
super().__init__(InlineQueryResultType.AUDIO, id, api_kwargs=api_kwargs) super().__init__(InlineQueryResultType.AUDIO, id, api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
self.audio_url = audio_url self.audio_url: str = audio_url
self.title = title self.title: str = title
# Optionals # Optionals
self.performer = performer self.performer: Optional[str] = performer
self.audio_duration = audio_duration self.audio_duration: Optional[int] = audio_duration
self.caption = caption self.caption: Optional[str] = caption
self.parse_mode = parse_mode self.parse_mode: ODVInput[str] = parse_mode
self.caption_entities = parse_sequence_arg(caption_entities) self.caption_entities: Tuple[MessageEntity, ...] = parse_sequence_arg(caption_entities)
self.reply_markup = reply_markup self.reply_markup: Optional[InlineKeyboardMarkup] = reply_markup
self.input_message_content = input_message_content self.input_message_content: Optional[InputMessageContent] = input_message_content

View file

@ -17,7 +17,7 @@
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the classes that represent Telegram InlineQueryResultCachedAudio.""" """This module contains the classes that represent Telegram InlineQueryResultCachedAudio."""
from typing import TYPE_CHECKING, Sequence from typing import TYPE_CHECKING, Optional, Sequence, Tuple
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from telegram._inline.inlinequeryresult import InlineQueryResult from telegram._inline.inlinequeryresult import InlineQueryResult
@ -105,11 +105,11 @@ class InlineQueryResultCachedAudio(InlineQueryResult):
# Required # Required
super().__init__(InlineQueryResultType.AUDIO, id, api_kwargs=api_kwargs) super().__init__(InlineQueryResultType.AUDIO, id, api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
self.audio_file_id = audio_file_id self.audio_file_id: str = audio_file_id
# Optionals # Optionals
self.caption = caption self.caption: Optional[str] = caption
self.parse_mode = parse_mode self.parse_mode: ODVInput[str] = parse_mode
self.caption_entities = parse_sequence_arg(caption_entities) self.caption_entities: Tuple[MessageEntity, ...] = parse_sequence_arg(caption_entities)
self.reply_markup = reply_markup self.reply_markup: Optional[InlineKeyboardMarkup] = reply_markup
self.input_message_content = input_message_content self.input_message_content: Optional[InputMessageContent] = input_message_content

View file

@ -17,7 +17,7 @@
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the classes that represent Telegram InlineQueryResultCachedDocument.""" """This module contains the classes that represent Telegram InlineQueryResultCachedDocument."""
from typing import TYPE_CHECKING, Sequence from typing import TYPE_CHECKING, Optional, Sequence, Tuple
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from telegram._inline.inlinequeryresult import InlineQueryResult from telegram._inline.inlinequeryresult import InlineQueryResult
@ -113,13 +113,13 @@ class InlineQueryResultCachedDocument(InlineQueryResult):
# Required # Required
super().__init__(InlineQueryResultType.DOCUMENT, id, api_kwargs=api_kwargs) super().__init__(InlineQueryResultType.DOCUMENT, id, api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
self.title = title self.title: str = title
self.document_file_id = document_file_id self.document_file_id: str = document_file_id
# Optionals # Optionals
self.description = description self.description: Optional[str] = description
self.caption = caption self.caption: Optional[str] = caption
self.parse_mode = parse_mode self.parse_mode: ODVInput[str] = parse_mode
self.caption_entities = parse_sequence_arg(caption_entities) self.caption_entities: Tuple[MessageEntity, ...] = parse_sequence_arg(caption_entities)
self.reply_markup = reply_markup self.reply_markup: Optional[InlineKeyboardMarkup] = reply_markup
self.input_message_content = input_message_content self.input_message_content: Optional[InputMessageContent] = input_message_content

View file

@ -17,7 +17,7 @@
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the classes that represent Telegram InlineQueryResultCachedGif.""" """This module contains the classes that represent Telegram InlineQueryResultCachedGif."""
from typing import TYPE_CHECKING, Sequence from typing import TYPE_CHECKING, Optional, Sequence, Tuple
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from telegram._inline.inlinequeryresult import InlineQueryResult from telegram._inline.inlinequeryresult import InlineQueryResult
@ -110,12 +110,12 @@ class InlineQueryResultCachedGif(InlineQueryResult):
# Required # Required
super().__init__(InlineQueryResultType.GIF, id, api_kwargs=api_kwargs) super().__init__(InlineQueryResultType.GIF, id, api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
self.gif_file_id = gif_file_id self.gif_file_id: str = gif_file_id
# Optionals # Optionals
self.title = title self.title: Optional[str] = title
self.caption = caption self.caption: Optional[str] = caption
self.parse_mode = parse_mode self.parse_mode: ODVInput[str] = parse_mode
self.caption_entities = parse_sequence_arg(caption_entities) self.caption_entities: Tuple[MessageEntity, ...] = parse_sequence_arg(caption_entities)
self.reply_markup = reply_markup self.reply_markup: Optional[InlineKeyboardMarkup] = reply_markup
self.input_message_content = input_message_content self.input_message_content: Optional[InputMessageContent] = input_message_content

View file

@ -17,7 +17,7 @@
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the classes that represent Telegram InlineQueryResultMpeg4Gif.""" """This module contains the classes that represent Telegram InlineQueryResultMpeg4Gif."""
from typing import TYPE_CHECKING, Sequence from typing import TYPE_CHECKING, Optional, Sequence, Tuple
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from telegram._inline.inlinequeryresult import InlineQueryResult from telegram._inline.inlinequeryresult import InlineQueryResult
@ -110,12 +110,12 @@ class InlineQueryResultCachedMpeg4Gif(InlineQueryResult):
# Required # Required
super().__init__(InlineQueryResultType.MPEG4GIF, id, api_kwargs=api_kwargs) super().__init__(InlineQueryResultType.MPEG4GIF, id, api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
self.mpeg4_file_id = mpeg4_file_id self.mpeg4_file_id: str = mpeg4_file_id
# Optionals # Optionals
self.title = title self.title: Optional[str] = title
self.caption = caption self.caption: Optional[str] = caption
self.parse_mode = parse_mode self.parse_mode: ODVInput[str] = parse_mode
self.caption_entities = parse_sequence_arg(caption_entities) self.caption_entities: Tuple[MessageEntity, ...] = parse_sequence_arg(caption_entities)
self.reply_markup = reply_markup self.reply_markup: Optional[InlineKeyboardMarkup] = reply_markup
self.input_message_content = input_message_content self.input_message_content: Optional[InputMessageContent] = input_message_content

View file

@ -17,7 +17,7 @@
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the classes that represent Telegram InlineQueryResultPhoto""" """This module contains the classes that represent Telegram InlineQueryResultPhoto"""
from typing import TYPE_CHECKING, Sequence from typing import TYPE_CHECKING, Optional, Sequence, Tuple
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from telegram._inline.inlinequeryresult import InlineQueryResult from telegram._inline.inlinequeryresult import InlineQueryResult
@ -114,13 +114,13 @@ class InlineQueryResultCachedPhoto(InlineQueryResult):
# Required # Required
super().__init__(InlineQueryResultType.PHOTO, id, api_kwargs=api_kwargs) super().__init__(InlineQueryResultType.PHOTO, id, api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
self.photo_file_id = photo_file_id self.photo_file_id: str = photo_file_id
# Optionals # Optionals
self.title = title self.title: Optional[str] = title
self.description = description self.description: Optional[str] = description
self.caption = caption self.caption: Optional[str] = caption
self.parse_mode = parse_mode self.parse_mode: ODVInput[str] = parse_mode
self.caption_entities = parse_sequence_arg(caption_entities) self.caption_entities: Tuple[MessageEntity, ...] = parse_sequence_arg(caption_entities)
self.reply_markup = reply_markup self.reply_markup: Optional[InlineKeyboardMarkup] = reply_markup
self.input_message_content = input_message_content self.input_message_content: Optional[InputMessageContent] = input_message_content

View file

@ -18,7 +18,7 @@
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the classes that represent Telegram InlineQueryResultCachedSticker.""" """This module contains the classes that represent Telegram InlineQueryResultCachedSticker."""
from typing import TYPE_CHECKING from typing import TYPE_CHECKING, Optional
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from telegram._inline.inlinequeryresult import InlineQueryResult from telegram._inline.inlinequeryresult import InlineQueryResult
@ -74,8 +74,8 @@ class InlineQueryResultCachedSticker(InlineQueryResult):
# Required # Required
super().__init__(InlineQueryResultType.STICKER, id, api_kwargs=api_kwargs) super().__init__(InlineQueryResultType.STICKER, id, api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
self.sticker_file_id = sticker_file_id self.sticker_file_id: str = sticker_file_id
# Optionals # Optionals
self.reply_markup = reply_markup self.reply_markup: Optional[InlineKeyboardMarkup] = reply_markup
self.input_message_content = input_message_content self.input_message_content: Optional[InputMessageContent] = input_message_content

View file

@ -17,7 +17,7 @@
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the classes that represent Telegram InlineQueryResultCachedVideo.""" """This module contains the classes that represent Telegram InlineQueryResultCachedVideo."""
from typing import TYPE_CHECKING, Sequence from typing import TYPE_CHECKING, Optional, Sequence, Tuple
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from telegram._inline.inlinequeryresult import InlineQueryResult from telegram._inline.inlinequeryresult import InlineQueryResult
@ -110,13 +110,13 @@ class InlineQueryResultCachedVideo(InlineQueryResult):
# Required # Required
super().__init__(InlineQueryResultType.VIDEO, id, api_kwargs=api_kwargs) super().__init__(InlineQueryResultType.VIDEO, id, api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
self.video_file_id = video_file_id self.video_file_id: str = video_file_id
self.title = title self.title: str = title
# Optionals # Optionals
self.description = description self.description: Optional[str] = description
self.caption = caption self.caption: Optional[str] = caption
self.parse_mode = parse_mode self.parse_mode: ODVInput[str] = parse_mode
self.caption_entities = parse_sequence_arg(caption_entities) self.caption_entities: Tuple[MessageEntity, ...] = parse_sequence_arg(caption_entities)
self.reply_markup = reply_markup self.reply_markup: Optional[InlineKeyboardMarkup] = reply_markup
self.input_message_content = input_message_content self.input_message_content: Optional[InputMessageContent] = input_message_content

View file

@ -17,7 +17,7 @@
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the classes that represent Telegram InlineQueryResultCachedVoice.""" """This module contains the classes that represent Telegram InlineQueryResultCachedVoice."""
from typing import TYPE_CHECKING, Sequence from typing import TYPE_CHECKING, Optional, Sequence, Tuple
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from telegram._inline.inlinequeryresult import InlineQueryResult from telegram._inline.inlinequeryresult import InlineQueryResult
@ -109,12 +109,12 @@ class InlineQueryResultCachedVoice(InlineQueryResult):
# Required # Required
super().__init__(InlineQueryResultType.VOICE, id, api_kwargs=api_kwargs) super().__init__(InlineQueryResultType.VOICE, id, api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
self.voice_file_id = voice_file_id self.voice_file_id: str = voice_file_id
self.title = title self.title: str = title
# Optionals # Optionals
self.caption = caption self.caption: Optional[str] = caption
self.parse_mode = parse_mode self.parse_mode: ODVInput[str] = parse_mode
self.caption_entities = parse_sequence_arg(caption_entities) self.caption_entities: Tuple[MessageEntity, ...] = parse_sequence_arg(caption_entities)
self.reply_markup = reply_markup self.reply_markup: Optional[InlineKeyboardMarkup] = reply_markup
self.input_message_content = input_message_content self.input_message_content: Optional[InputMessageContent] = input_message_content

View file

@ -18,7 +18,7 @@
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the classes that represent Telegram InlineQueryResultContact.""" """This module contains the classes that represent Telegram InlineQueryResultContact."""
from typing import TYPE_CHECKING from typing import TYPE_CHECKING, Optional
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from telegram._inline.inlinequeryresult import InlineQueryResult from telegram._inline.inlinequeryresult import InlineQueryResult
@ -102,14 +102,14 @@ class InlineQueryResultContact(InlineQueryResult):
# Required # Required
super().__init__(InlineQueryResultType.CONTACT, id, api_kwargs=api_kwargs) super().__init__(InlineQueryResultType.CONTACT, id, api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
self.phone_number = phone_number self.phone_number: str = phone_number
self.first_name = first_name self.first_name: str = first_name
# Optionals # Optionals
self.last_name = last_name self.last_name: Optional[str] = last_name
self.vcard = vcard self.vcard: Optional[str] = vcard
self.reply_markup = reply_markup self.reply_markup: Optional[InlineKeyboardMarkup] = reply_markup
self.input_message_content = input_message_content self.input_message_content: Optional[InputMessageContent] = input_message_content
self.thumb_url = thumb_url self.thumb_url: Optional[str] = thumb_url
self.thumb_width = thumb_width self.thumb_width: Optional[int] = thumb_width
self.thumb_height = thumb_height self.thumb_height: Optional[int] = thumb_height

View file

@ -17,7 +17,7 @@
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the classes that represent Telegram InlineQueryResultDocument""" """This module contains the classes that represent Telegram InlineQueryResultDocument"""
from typing import TYPE_CHECKING, Sequence from typing import TYPE_CHECKING, Optional, Sequence, Tuple
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from telegram._inline.inlinequeryresult import InlineQueryResult from telegram._inline.inlinequeryresult import InlineQueryResult
@ -132,17 +132,17 @@ class InlineQueryResultDocument(InlineQueryResult):
# Required # Required
super().__init__(InlineQueryResultType.DOCUMENT, id, api_kwargs=api_kwargs) super().__init__(InlineQueryResultType.DOCUMENT, id, api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
self.document_url = document_url self.document_url: str = document_url
self.title = title self.title: str = title
self.mime_type = mime_type self.mime_type: str = mime_type
# Optionals # Optionals
self.caption = caption self.caption: Optional[str] = caption
self.parse_mode = parse_mode self.parse_mode: ODVInput[str] = parse_mode
self.caption_entities = parse_sequence_arg(caption_entities) self.caption_entities: Tuple[MessageEntity, ...] = parse_sequence_arg(caption_entities)
self.description = description self.description: Optional[str] = description
self.reply_markup = reply_markup self.reply_markup: Optional[InlineKeyboardMarkup] = reply_markup
self.input_message_content = input_message_content self.input_message_content: Optional[InputMessageContent] = input_message_content
self.thumb_url = thumb_url self.thumb_url: Optional[str] = thumb_url
self.thumb_width = thumb_width self.thumb_width: Optional[int] = thumb_width
self.thumb_height = thumb_height self.thumb_height: Optional[int] = thumb_height

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the classes that represent Telegram InlineQueryResultGame.""" """This module contains the classes that represent Telegram InlineQueryResultGame."""
from typing import Optional
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from telegram._inline.inlinequeryresult import InlineQueryResult from telegram._inline.inlinequeryresult import InlineQueryResult
@ -59,7 +60,7 @@ class InlineQueryResultGame(InlineQueryResult):
# Required # Required
super().__init__(InlineQueryResultType.GAME, id, api_kwargs=api_kwargs) super().__init__(InlineQueryResultType.GAME, id, api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
self.id = id self.id: str = id
self.game_short_name = game_short_name self.game_short_name: str = game_short_name
self.reply_markup = reply_markup self.reply_markup: Optional[InlineKeyboardMarkup] = reply_markup

View file

@ -17,7 +17,7 @@
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the classes that represent Telegram InlineQueryResultGif.""" """This module contains the classes that represent Telegram InlineQueryResultGif."""
from typing import TYPE_CHECKING, Sequence from typing import TYPE_CHECKING, Optional, Sequence, Tuple
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from telegram._inline.inlinequeryresult import InlineQueryResult from telegram._inline.inlinequeryresult import InlineQueryResult
@ -134,17 +134,17 @@ class InlineQueryResultGif(InlineQueryResult):
# Required # Required
super().__init__(InlineQueryResultType.GIF, id, api_kwargs=api_kwargs) super().__init__(InlineQueryResultType.GIF, id, api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
self.gif_url = gif_url self.gif_url: str = gif_url
self.thumb_url = thumb_url self.thumb_url: str = thumb_url
# Optionals # Optionals
self.gif_width = gif_width self.gif_width: Optional[int] = gif_width
self.gif_height = gif_height self.gif_height: Optional[int] = gif_height
self.gif_duration = gif_duration self.gif_duration: Optional[int] = gif_duration
self.title = title self.title: Optional[str] = title
self.caption = caption self.caption: Optional[str] = caption
self.parse_mode = parse_mode self.parse_mode: ODVInput[str] = parse_mode
self.caption_entities = parse_sequence_arg(caption_entities) self.caption_entities: Tuple[MessageEntity, ...] = parse_sequence_arg(caption_entities)
self.reply_markup = reply_markup self.reply_markup: Optional[InlineKeyboardMarkup] = reply_markup
self.input_message_content = input_message_content self.input_message_content: Optional[InputMessageContent] = input_message_content
self.thumb_mime_type = thumb_mime_type self.thumb_mime_type: Optional[str] = thumb_mime_type

View file

@ -18,7 +18,7 @@
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the classes that represent Telegram InlineQueryResultLocation.""" """This module contains the classes that represent Telegram InlineQueryResultLocation."""
from typing import TYPE_CHECKING, ClassVar from typing import TYPE_CHECKING, ClassVar, Optional
from telegram import constants from telegram import constants
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
@ -136,20 +136,20 @@ class InlineQueryResultLocation(InlineQueryResult):
# Required # Required
super().__init__(constants.InlineQueryResultType.LOCATION, id, api_kwargs=api_kwargs) super().__init__(constants.InlineQueryResultType.LOCATION, id, api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
self.latitude = latitude self.latitude: float = latitude
self.longitude = longitude self.longitude: float = longitude
self.title = title self.title: str = title
# Optionals # Optionals
self.live_period = live_period self.live_period: Optional[int] = live_period
self.reply_markup = reply_markup self.reply_markup: Optional[InlineKeyboardMarkup] = reply_markup
self.input_message_content = input_message_content self.input_message_content: Optional[InputMessageContent] = input_message_content
self.thumb_url = thumb_url self.thumb_url: Optional[str] = thumb_url
self.thumb_width = thumb_width self.thumb_width: Optional[int] = thumb_width
self.thumb_height = thumb_height self.thumb_height: Optional[int] = thumb_height
self.horizontal_accuracy = horizontal_accuracy self.horizontal_accuracy: Optional[float] = horizontal_accuracy
self.heading = heading self.heading: Optional[int] = heading
self.proximity_alert_radius = ( self.proximity_alert_radius: Optional[int] = (
int(proximity_alert_radius) if proximity_alert_radius else None int(proximity_alert_radius) if proximity_alert_radius else None
) )

View file

@ -17,7 +17,7 @@
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the classes that represent Telegram InlineQueryResultMpeg4Gif.""" """This module contains the classes that represent Telegram InlineQueryResultMpeg4Gif."""
from typing import TYPE_CHECKING, Sequence from typing import TYPE_CHECKING, Optional, Sequence, Tuple
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from telegram._inline.inlinequeryresult import InlineQueryResult from telegram._inline.inlinequeryresult import InlineQueryResult
@ -137,17 +137,17 @@ class InlineQueryResultMpeg4Gif(InlineQueryResult):
# Required # Required
super().__init__(InlineQueryResultType.MPEG4GIF, id, api_kwargs=api_kwargs) super().__init__(InlineQueryResultType.MPEG4GIF, id, api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
self.mpeg4_url = mpeg4_url self.mpeg4_url: str = mpeg4_url
self.thumb_url = thumb_url self.thumb_url: str = thumb_url
# Optional # Optional
self.mpeg4_width = mpeg4_width self.mpeg4_width: Optional[int] = mpeg4_width
self.mpeg4_height = mpeg4_height self.mpeg4_height: Optional[int] = mpeg4_height
self.mpeg4_duration = mpeg4_duration self.mpeg4_duration: Optional[int] = mpeg4_duration
self.title = title self.title: Optional[str] = title
self.caption = caption self.caption: Optional[str] = caption
self.parse_mode = parse_mode self.parse_mode: ODVInput[str] = parse_mode
self.caption_entities = parse_sequence_arg(caption_entities) self.caption_entities: Tuple[MessageEntity, ...] = parse_sequence_arg(caption_entities)
self.reply_markup = reply_markup self.reply_markup: Optional[InlineKeyboardMarkup] = reply_markup
self.input_message_content = input_message_content self.input_message_content: Optional[InputMessageContent] = input_message_content
self.thumb_mime_type = thumb_mime_type self.thumb_mime_type: Optional[str] = thumb_mime_type

View file

@ -17,7 +17,7 @@
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the classes that represent Telegram InlineQueryResultPhoto.""" """This module contains the classes that represent Telegram InlineQueryResultPhoto."""
from typing import TYPE_CHECKING, Sequence from typing import TYPE_CHECKING, Optional, Sequence, Tuple
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from telegram._inline.inlinequeryresult import InlineQueryResult from telegram._inline.inlinequeryresult import InlineQueryResult
@ -127,16 +127,16 @@ class InlineQueryResultPhoto(InlineQueryResult):
# Required # Required
super().__init__(InlineQueryResultType.PHOTO, id, api_kwargs=api_kwargs) super().__init__(InlineQueryResultType.PHOTO, id, api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
self.photo_url = photo_url self.photo_url: str = photo_url
self.thumb_url = thumb_url self.thumb_url: str = thumb_url
# Optionals # Optionals
self.photo_width = photo_width self.photo_width: Optional[int] = photo_width
self.photo_height = photo_height self.photo_height: Optional[int] = photo_height
self.title = title self.title: Optional[str] = title
self.description = description self.description: Optional[str] = description
self.caption = caption self.caption: Optional[str] = caption
self.parse_mode = parse_mode self.parse_mode: ODVInput[str] = parse_mode
self.caption_entities = parse_sequence_arg(caption_entities) self.caption_entities: Tuple[MessageEntity, ...] = parse_sequence_arg(caption_entities)
self.reply_markup = reply_markup self.reply_markup: Optional[InlineKeyboardMarkup] = reply_markup
self.input_message_content = input_message_content self.input_message_content: Optional[InputMessageContent] = input_message_content

View file

@ -18,7 +18,7 @@
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the classes that represent Telegram InlineQueryResultVenue.""" """This module contains the classes that represent Telegram InlineQueryResultVenue."""
from typing import TYPE_CHECKING from typing import TYPE_CHECKING, Optional
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from telegram._inline.inlinequeryresult import InlineQueryResult from telegram._inline.inlinequeryresult import InlineQueryResult
@ -129,18 +129,18 @@ class InlineQueryResultVenue(InlineQueryResult):
# Required # Required
super().__init__(InlineQueryResultType.VENUE, id, api_kwargs=api_kwargs) super().__init__(InlineQueryResultType.VENUE, id, api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
self.latitude = latitude self.latitude: float = latitude
self.longitude = longitude self.longitude: float = longitude
self.title = title self.title: str = title
self.address = address self.address: str = address
# Optional # Optional
self.foursquare_id = foursquare_id self.foursquare_id: Optional[str] = foursquare_id
self.foursquare_type = foursquare_type self.foursquare_type: Optional[str] = foursquare_type
self.google_place_id = google_place_id self.google_place_id: Optional[str] = google_place_id
self.google_place_type = google_place_type self.google_place_type: Optional[str] = google_place_type
self.reply_markup = reply_markup self.reply_markup: Optional[InlineKeyboardMarkup] = reply_markup
self.input_message_content = input_message_content self.input_message_content: Optional[InputMessageContent] = input_message_content
self.thumb_url = thumb_url self.thumb_url: Optional[str] = thumb_url
self.thumb_width = thumb_width self.thumb_width: Optional[int] = thumb_width
self.thumb_height = thumb_height self.thumb_height: Optional[int] = thumb_height

View file

@ -17,7 +17,7 @@
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the classes that represent Telegram InlineQueryResultVideo.""" """This module contains the classes that represent Telegram InlineQueryResultVideo."""
from typing import TYPE_CHECKING, Sequence from typing import TYPE_CHECKING, Optional, Sequence, Tuple
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from telegram._inline.inlinequeryresult import InlineQueryResult from telegram._inline.inlinequeryresult import InlineQueryResult
@ -145,18 +145,18 @@ class InlineQueryResultVideo(InlineQueryResult):
# Required # Required
super().__init__(InlineQueryResultType.VIDEO, id, api_kwargs=api_kwargs) super().__init__(InlineQueryResultType.VIDEO, id, api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
self.video_url = video_url self.video_url: str = video_url
self.mime_type = mime_type self.mime_type: str = mime_type
self.thumb_url = thumb_url self.thumb_url: str = thumb_url
self.title = title self.title: str = title
# Optional # Optional
self.caption = caption self.caption: Optional[str] = caption
self.parse_mode = parse_mode self.parse_mode: ODVInput[str] = parse_mode
self.caption_entities = parse_sequence_arg(caption_entities) self.caption_entities: Tuple[MessageEntity, ...] = parse_sequence_arg(caption_entities)
self.video_width = video_width self.video_width: Optional[int] = video_width
self.video_height = video_height self.video_height: Optional[int] = video_height
self.video_duration = video_duration self.video_duration: Optional[int] = video_duration
self.description = description self.description: Optional[str] = description
self.reply_markup = reply_markup self.reply_markup: Optional[InlineKeyboardMarkup] = reply_markup
self.input_message_content = input_message_content self.input_message_content: Optional[InputMessageContent] = input_message_content

View file

@ -17,7 +17,7 @@
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the classes that represent Telegram InlineQueryResultVoice.""" """This module contains the classes that represent Telegram InlineQueryResultVoice."""
from typing import TYPE_CHECKING, Sequence from typing import TYPE_CHECKING, Optional, Sequence, Tuple
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from telegram._inline.inlinequeryresult import InlineQueryResult from telegram._inline.inlinequeryresult import InlineQueryResult
@ -115,13 +115,13 @@ class InlineQueryResultVoice(InlineQueryResult):
# Required # Required
super().__init__(InlineQueryResultType.VOICE, id, api_kwargs=api_kwargs) super().__init__(InlineQueryResultType.VOICE, id, api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
self.voice_url = voice_url self.voice_url: str = voice_url
self.title = title self.title: str = title
# Optional # Optional
self.voice_duration = voice_duration self.voice_duration: Optional[int] = voice_duration
self.caption = caption self.caption: Optional[str] = caption
self.parse_mode = parse_mode self.parse_mode: ODVInput[str] = parse_mode
self.caption_entities = parse_sequence_arg(caption_entities) self.caption_entities: Tuple[MessageEntity, ...] = parse_sequence_arg(caption_entities)
self.reply_markup = reply_markup self.reply_markup: Optional[InlineKeyboardMarkup] = reply_markup
self.input_message_content = input_message_content self.input_message_content: Optional[InputMessageContent] = input_message_content

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the classes that represent Telegram InputContactMessageContent.""" """This module contains the classes that represent Telegram InputContactMessageContent."""
from typing import Optional
from telegram._inline.inputmessagecontent import InputMessageContent from telegram._inline.inputmessagecontent import InputMessageContent
from telegram._utils.types import JSONDict from telegram._utils.types import JSONDict
@ -58,10 +59,10 @@ class InputContactMessageContent(InputMessageContent):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
# Required # Required
self.phone_number = phone_number self.phone_number: str = phone_number
self.first_name = first_name self.first_name: str = first_name
# Optionals # Optionals
self.last_name = last_name self.last_name: Optional[str] = last_name
self.vcard = vcard self.vcard: Optional[str] = vcard
self._id_attrs = (self.phone_number,) self._id_attrs = (self.phone_number,)

View file

@ -17,7 +17,7 @@
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains a class that represents a Telegram InputInvoiceMessageContent.""" """This module contains a class that represents a Telegram InputInvoiceMessageContent."""
from typing import TYPE_CHECKING, Optional, Sequence from typing import TYPE_CHECKING, Optional, Sequence, Tuple
from telegram._inline.inputmessagecontent import InputMessageContent from telegram._inline.inputmessagecontent import InputMessageContent
from telegram._payment.labeledprice import LabeledPrice from telegram._payment.labeledprice import LabeledPrice
@ -213,27 +213,27 @@ class InputInvoiceMessageContent(InputMessageContent):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
# Required # Required
self.title = title self.title: str = title
self.description = description self.description: str = description
self.payload = payload self.payload: str = payload
self.provider_token = provider_token self.provider_token: str = provider_token
self.currency = currency self.currency: str = currency
self.prices = parse_sequence_arg(prices) self.prices: Tuple[LabeledPrice, ...] = parse_sequence_arg(prices)
# Optionals # Optionals
self.max_tip_amount = max_tip_amount self.max_tip_amount: Optional[int] = max_tip_amount
self.suggested_tip_amounts = parse_sequence_arg(suggested_tip_amounts) self.suggested_tip_amounts: Tuple[int, ...] = parse_sequence_arg(suggested_tip_amounts)
self.provider_data = provider_data self.provider_data: Optional[str] = provider_data
self.photo_url = photo_url self.photo_url: Optional[str] = photo_url
self.photo_size = photo_size self.photo_size: Optional[int] = photo_size
self.photo_width = photo_width self.photo_width: Optional[int] = photo_width
self.photo_height = photo_height self.photo_height: Optional[int] = photo_height
self.need_name = need_name self.need_name: Optional[bool] = need_name
self.need_phone_number = need_phone_number self.need_phone_number: Optional[bool] = need_phone_number
self.need_email = need_email self.need_email: Optional[bool] = need_email
self.need_shipping_address = need_shipping_address self.need_shipping_address: Optional[bool] = need_shipping_address
self.send_phone_number_to_provider = send_phone_number_to_provider self.send_phone_number_to_provider: Optional[bool] = send_phone_number_to_provider
self.send_email_to_provider = send_email_to_provider self.send_email_to_provider: Optional[bool] = send_email_to_provider
self.is_flexible = is_flexible self.is_flexible: Optional[bool] = is_flexible
self._id_attrs = ( self._id_attrs = (
self.title, self.title,

View file

@ -18,7 +18,7 @@
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the classes that represent Telegram InputLocationMessageContent.""" """This module contains the classes that represent Telegram InputLocationMessageContent."""
from typing import ClassVar from typing import ClassVar, Optional
from telegram import constants from telegram import constants
from telegram._inline.inputmessagecontent import InputMessageContent from telegram._inline.inputmessagecontent import InputMessageContent
@ -93,14 +93,14 @@ class InputLocationMessageContent(InputMessageContent):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
# Required # Required
self.latitude = latitude self.latitude: float = latitude
self.longitude = longitude self.longitude: float = longitude
# Optionals # Optionals
self.live_period = live_period self.live_period: Optional[int] = live_period
self.horizontal_accuracy = horizontal_accuracy self.horizontal_accuracy: Optional[float] = horizontal_accuracy
self.heading = heading self.heading: Optional[int] = heading
self.proximity_alert_radius = ( self.proximity_alert_radius: Optional[int] = (
int(proximity_alert_radius) if proximity_alert_radius else None int(proximity_alert_radius) if proximity_alert_radius else None
) )

View file

@ -17,7 +17,7 @@
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the classes that represent Telegram InputTextMessageContent.""" """This module contains the classes that represent Telegram InputTextMessageContent."""
from typing import Sequence from typing import Sequence, Tuple
from telegram._inline.inputmessagecontent import InputMessageContent from telegram._inline.inputmessagecontent import InputMessageContent
from telegram._messageentity import MessageEntity from telegram._messageentity import MessageEntity
@ -81,10 +81,10 @@ class InputTextMessageContent(InputMessageContent):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
# Required # Required
self.message_text = message_text self.message_text: str = message_text
# Optionals # Optionals
self.parse_mode = parse_mode self.parse_mode: ODVInput[str] = parse_mode
self.entities = parse_sequence_arg(entities) self.entities: Tuple[MessageEntity, ...] = parse_sequence_arg(entities)
self.disable_web_page_preview = disable_web_page_preview self.disable_web_page_preview: ODVInput[bool] = disable_web_page_preview
self._id_attrs = (self.message_text,) self._id_attrs = (self.message_text,)

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the classes that represent Telegram InputVenueMessageContent.""" """This module contains the classes that represent Telegram InputVenueMessageContent."""
from typing import Optional
from telegram._inline.inputmessagecontent import InputMessageContent from telegram._inline.inputmessagecontent import InputMessageContent
from telegram._utils.types import JSONDict from telegram._utils.types import JSONDict
@ -90,15 +91,15 @@ class InputVenueMessageContent(InputMessageContent):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
# Required # Required
self.latitude = latitude self.latitude: float = latitude
self.longitude = longitude self.longitude: float = longitude
self.title = title self.title: str = title
self.address = address self.address: str = address
# Optionals # Optionals
self.foursquare_id = foursquare_id self.foursquare_id: Optional[str] = foursquare_id
self.foursquare_type = foursquare_type self.foursquare_type: Optional[str] = foursquare_type
self.google_place_id = google_place_id self.google_place_id: Optional[str] = google_place_id
self.google_place_type = google_place_type self.google_place_type: Optional[str] = google_place_type
self._id_attrs = ( self._id_attrs = (
self.latitude, self.latitude,

View file

@ -99,12 +99,12 @@ class KeyboardButton(TelegramObject):
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
# Required # Required
self.text = text self.text: str = text
# Optionals # Optionals
self.request_contact = request_contact self.request_contact: Optional[bool] = request_contact
self.request_location = request_location self.request_location: Optional[bool] = request_location
self.request_poll = request_poll self.request_poll: Optional[KeyboardButtonPollType] = request_poll
self.web_app = web_app self.web_app: Optional[WebAppInfo] = web_app
self._id_attrs = ( self._id_attrs = (
self.text, self.text,

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a type of a Telegram Poll.""" """This module contains an object that represents a type of a Telegram Poll."""
from typing import Optional
from telegram._telegramobject import TelegramObject from telegram._telegramobject import TelegramObject
from telegram._utils.types import JSONDict from telegram._utils.types import JSONDict
@ -50,7 +51,7 @@ class KeyboardButtonPollType(TelegramObject):
self, type: str = None, *, api_kwargs: JSONDict = None # skipcq: PYL-W0622 self, type: str = None, *, api_kwargs: JSONDict = None # skipcq: PYL-W0622
): # pylint: disable=redefined-builtin ): # pylint: disable=redefined-builtin
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
self.type = type self.type: Optional[str] = type
self._id_attrs = (self.type,) self._id_attrs = (self.type,)

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram LoginUrl.""" """This module contains an object that represents a Telegram LoginUrl."""
from typing import Optional
from telegram._telegramobject import TelegramObject from telegram._telegramobject import TelegramObject
from telegram._utils.types import JSONDict from telegram._utils.types import JSONDict
@ -93,11 +94,11 @@ class LoginUrl(TelegramObject):
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
# Required # Required
self.url = url self.url: str = url
# Optional # Optional
self.forward_text = forward_text self.forward_text: Optional[bool] = forward_text
self.bot_username = bot_username self.bot_username: Optional[str] = bot_username
self.request_write_access = request_write_access self.request_write_access: Optional[bool] = request_write_access
self._id_attrs = (self.url,) self._id_attrs = (self.url,)

View file

@ -58,7 +58,7 @@ class MenuButton(TelegramObject):
self, type: str, *, api_kwargs: JSONDict = None # skipcq: PYL-W0622 self, type: str, *, api_kwargs: JSONDict = None # skipcq: PYL-W0622
): # pylint: disable=redefined-builtin ): # pylint: disable=redefined-builtin
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
self.type = type self.type: str = type
self._id_attrs = (self.type,) self._id_attrs = (self.type,)
@ -150,8 +150,8 @@ class MenuButtonWebApp(MenuButton):
def __init__(self, text: str, web_app: WebAppInfo, *, api_kwargs: JSONDict = None): def __init__(self, text: str, web_app: WebAppInfo, *, api_kwargs: JSONDict = None):
super().__init__(type=constants.MenuButtonType.WEB_APP, api_kwargs=api_kwargs) super().__init__(type=constants.MenuButtonType.WEB_APP, api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
self.text = text self.text: str = text
self.web_app = web_app self.web_app: WebAppInfo = web_app
self._id_attrs = (self.type, self.text, self.web_app) self._id_attrs = (self.type, self.text, self.web_app)

View file

@ -699,76 +699,86 @@ class Message(TelegramObject):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
# Required # Required
self.message_id = message_id self.message_id: int = message_id
# Optionals # Optionals
self.from_user = from_user self.from_user: Optional[User] = from_user
self.sender_chat = sender_chat self.sender_chat: Optional[Chat] = sender_chat
self.date = date self.date: datetime.datetime = date
self.chat = chat self.chat: Chat = chat
self.forward_from = forward_from self.forward_from: Optional[User] = forward_from
self.forward_from_chat = forward_from_chat self.forward_from_chat: Optional[Chat] = forward_from_chat
self.forward_date = forward_date self.forward_date: Optional[datetime.datetime] = forward_date
self.is_automatic_forward = is_automatic_forward self.is_automatic_forward: Optional[bool] = is_automatic_forward
self.reply_to_message = reply_to_message self.reply_to_message: Optional[Message] = reply_to_message
self.edit_date = edit_date self.edit_date: Optional[datetime.datetime] = edit_date
self.has_protected_content = has_protected_content self.has_protected_content: Optional[bool] = has_protected_content
self.text = text self.text: Optional[str] = text
self.entities = parse_sequence_arg(entities) self.entities: Tuple["MessageEntity", ...] = parse_sequence_arg(entities)
self.caption_entities = parse_sequence_arg(caption_entities) self.caption_entities: Tuple["MessageEntity", ...] = parse_sequence_arg(caption_entities)
self.audio = audio self.audio: Optional[Audio] = audio
self.game = game self.game: Optional[Game] = game
self.document = document self.document: Optional[Document] = document
self.photo = parse_sequence_arg(photo) self.photo: Tuple[PhotoSize, ...] = parse_sequence_arg(photo)
self.sticker = sticker self.sticker: Optional[Sticker] = sticker
self.video = video self.video: Optional[Video] = video
self.voice = voice self.voice: Optional[Voice] = voice
self.video_note = video_note self.video_note: Optional[VideoNote] = video_note
self.caption = caption self.caption: Optional[str] = caption
self.contact = contact self.contact: Optional[Contact] = contact
self.location = location self.location: Optional[Location] = location
self.venue = venue self.venue: Optional[Venue] = venue
self.new_chat_members = parse_sequence_arg(new_chat_members) self.new_chat_members: Tuple[User, ...] = parse_sequence_arg(new_chat_members)
self.left_chat_member = left_chat_member self.left_chat_member: Optional[User] = left_chat_member
self.new_chat_title = new_chat_title self.new_chat_title: Optional[str] = new_chat_title
self.new_chat_photo = parse_sequence_arg(new_chat_photo) self.new_chat_photo: Tuple[PhotoSize, ...] = parse_sequence_arg(new_chat_photo)
self.delete_chat_photo = bool(delete_chat_photo) self.delete_chat_photo: Optional[bool] = bool(delete_chat_photo)
self.group_chat_created = bool(group_chat_created) self.group_chat_created: Optional[bool] = bool(group_chat_created)
self.supergroup_chat_created = bool(supergroup_chat_created) self.supergroup_chat_created: Optional[bool] = bool(supergroup_chat_created)
self.migrate_to_chat_id = migrate_to_chat_id self.migrate_to_chat_id: Optional[int] = migrate_to_chat_id
self.migrate_from_chat_id = migrate_from_chat_id self.migrate_from_chat_id: Optional[int] = migrate_from_chat_id
self.channel_chat_created = bool(channel_chat_created) self.channel_chat_created: Optional[bool] = bool(channel_chat_created)
self.message_auto_delete_timer_changed = message_auto_delete_timer_changed self.message_auto_delete_timer_changed: Optional[
self.pinned_message = pinned_message MessageAutoDeleteTimerChanged
self.forward_from_message_id = forward_from_message_id ] = message_auto_delete_timer_changed
self.invoice = invoice self.pinned_message: Optional[Message] = pinned_message
self.successful_payment = successful_payment self.forward_from_message_id: Optional[int] = forward_from_message_id
self.connected_website = connected_website self.invoice: Optional[Invoice] = invoice
self.forward_signature = forward_signature self.successful_payment: Optional[SuccessfulPayment] = successful_payment
self.forward_sender_name = forward_sender_name self.connected_website: Optional[str] = connected_website
self.author_signature = author_signature self.forward_signature: Optional[str] = forward_signature
self.media_group_id = media_group_id self.forward_sender_name: Optional[str] = forward_sender_name
self.animation = animation self.author_signature: Optional[str] = author_signature
self.passport_data = passport_data self.media_group_id: Optional[str] = media_group_id
self.poll = poll self.animation: Optional[Animation] = animation
self.dice = dice self.passport_data: Optional[PassportData] = passport_data
self.via_bot = via_bot self.poll: Optional[Poll] = poll
self.proximity_alert_triggered = proximity_alert_triggered self.dice: Optional[Dice] = dice
self.video_chat_scheduled = video_chat_scheduled self.via_bot: Optional[User] = via_bot
self.video_chat_started = video_chat_started self.proximity_alert_triggered: Optional[
self.video_chat_ended = video_chat_ended ProximityAlertTriggered
self.video_chat_participants_invited = video_chat_participants_invited ] = proximity_alert_triggered
self.reply_markup = reply_markup self.video_chat_scheduled: Optional[VideoChatScheduled] = video_chat_scheduled
self.web_app_data = web_app_data self.video_chat_started: Optional[VideoChatStarted] = video_chat_started
self.is_topic_message = is_topic_message self.video_chat_ended: Optional[VideoChatEnded] = video_chat_ended
self.message_thread_id = message_thread_id self.video_chat_participants_invited: Optional[
self.forum_topic_created = forum_topic_created VideoChatParticipantsInvited
self.forum_topic_closed = forum_topic_closed ] = video_chat_participants_invited
self.forum_topic_reopened = forum_topic_reopened self.reply_markup: Optional[InlineKeyboardMarkup] = reply_markup
self.forum_topic_edited = forum_topic_edited self.web_app_data: Optional[WebAppData] = web_app_data
self.general_forum_topic_hidden = general_forum_topic_hidden self.is_topic_message: Optional[bool] = is_topic_message
self.general_forum_topic_unhidden = general_forum_topic_unhidden self.message_thread_id: Optional[int] = message_thread_id
self.write_access_allowed = write_access_allowed self.forum_topic_created: Optional[ForumTopicCreated] = forum_topic_created
self.has_media_spoiler = has_media_spoiler self.forum_topic_closed: Optional[ForumTopicClosed] = forum_topic_closed
self.forum_topic_reopened: Optional[ForumTopicReopened] = forum_topic_reopened
self.forum_topic_edited: Optional[ForumTopicEdited] = forum_topic_edited
self.general_forum_topic_hidden: Optional[
GeneralForumTopicHidden
] = general_forum_topic_hidden
self.general_forum_topic_unhidden: Optional[
GeneralForumTopicUnhidden
] = general_forum_topic_unhidden
self.write_access_allowed: Optional[WriteAccessAllowed] = write_access_allowed
self.has_media_spoiler: Optional[bool] = has_media_spoiler
self._effective_attachment = DEFAULT_NONE self._effective_attachment = DEFAULT_NONE

View file

@ -51,7 +51,7 @@ class MessageAutoDeleteTimerChanged(TelegramObject):
api_kwargs: JSONDict = None, api_kwargs: JSONDict = None,
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
self.message_auto_delete_time = message_auto_delete_time self.message_auto_delete_time: int = message_auto_delete_time
self._id_attrs = (self.message_auto_delete_time,) self._id_attrs = (self.message_auto_delete_time,)

View file

@ -105,14 +105,14 @@ class MessageEntity(TelegramObject):
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
# Required # Required
self.type = enum.get_member(constants.MessageEntityType, type, type) self.type: str = enum.get_member(constants.MessageEntityType, type, type)
self.offset = offset self.offset: int = offset
self.length = length self.length: int = length
# Optionals # Optionals
self.url = url self.url: Optional[str] = url
self.user = user self.user: Optional[User] = user
self.language = language self.language: Optional[str] = language
self.custom_emoji_id = custom_emoji_id self.custom_emoji_id: Optional[str] = custom_emoji_id
self._id_attrs = (self.type, self.offset, self.length) self._id_attrs = (self.type, self.offset, self.length)

View file

@ -39,7 +39,7 @@ class MessageId(TelegramObject):
def __init__(self, message_id: int, *, api_kwargs: JSONDict = None): def __init__(self, message_id: int, *, api_kwargs: JSONDict = None):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
self.message_id = message_id self.message_id: int = message_id
self._id_attrs = (self.message_id,) self._id_attrs = (self.message_id,)

View file

@ -19,7 +19,7 @@
# pylint: disable=missing-module-docstring, redefined-builtin # pylint: disable=missing-module-docstring, redefined-builtin
import json import json
from base64 import b64decode from base64 import b64decode
from typing import TYPE_CHECKING, Optional, Sequence, no_type_check from typing import TYPE_CHECKING, Optional, Sequence, Tuple, no_type_check
try: try:
from cryptography.hazmat.backends import default_backend from cryptography.hazmat.backends import default_backend
@ -147,9 +147,9 @@ class EncryptedCredentials(TelegramObject):
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
# Required # Required
self.data = data self.data: str = data
self.hash = hash self.hash: str = hash
self.secret = secret self.secret: str = secret
self._id_attrs = (self.data, self.hash, self.secret) self._id_attrs = (self.data, self.hash, self.secret)
@ -226,8 +226,8 @@ class Credentials(TelegramObject):
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
# Required # Required
self.secure_data = secure_data self.secure_data: SecureData = secure_data
self.nonce = nonce self.nonce: str = nonce
self._freeze() self._freeze()
@ -327,17 +327,17 @@ class SecureData(TelegramObject):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
# Optionals # Optionals
self.temporary_registration = temporary_registration self.temporary_registration: Optional[SecureValue] = temporary_registration
self.passport_registration = passport_registration self.passport_registration: Optional[SecureValue] = passport_registration
self.rental_agreement = rental_agreement self.rental_agreement: Optional[SecureValue] = rental_agreement
self.bank_statement = bank_statement self.bank_statement: Optional[SecureValue] = bank_statement
self.utility_bill = utility_bill self.utility_bill: Optional[SecureValue] = utility_bill
self.address = address self.address: Optional[SecureValue] = address
self.identity_card = identity_card self.identity_card: Optional[SecureValue] = identity_card
self.driver_license = driver_license self.driver_license: Optional[SecureValue] = driver_license
self.internal_passport = internal_passport self.internal_passport: Optional[SecureValue] = internal_passport
self.passport = passport self.passport: Optional[SecureValue] = passport
self.personal_details = personal_details self.personal_details: Optional[SecureValue] = personal_details
self._freeze() self._freeze()
@ -438,12 +438,12 @@ class SecureValue(TelegramObject):
api_kwargs: JSONDict = None, api_kwargs: JSONDict = None,
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
self.data = data self.data: Optional[DataCredentials] = data
self.front_side = front_side self.front_side: Optional[FileCredentials] = front_side
self.reverse_side = reverse_side self.reverse_side: Optional[FileCredentials] = reverse_side
self.selfie = selfie self.selfie: Optional[FileCredentials] = selfie
self.files = parse_sequence_arg(files) self.files: Tuple["FileCredentials", ...] = parse_sequence_arg(files)
self.translation = parse_sequence_arg(translation) self.translation: Tuple["FileCredentials", ...] = parse_sequence_arg(translation)
self._freeze() self._freeze()
@ -475,12 +475,12 @@ class _CredentialsBase(TelegramObject):
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
self.hash = hash self.hash: str = hash
self.secret = secret self.secret: str = secret
# Aliases just to be sure # Aliases just to be sure
self.file_hash = self.hash self.file_hash: str = self.hash
self.data_hash = self.hash self.data_hash: str = self.hash
class DataCredentials(_CredentialsBase): class DataCredentials(_CredentialsBase):

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
# pylint: disable=missing-module-docstring # pylint: disable=missing-module-docstring
from typing import Optional
from telegram._telegramobject import TelegramObject from telegram._telegramobject import TelegramObject
from telegram._utils.types import JSONDict from telegram._utils.types import JSONDict
@ -89,16 +90,16 @@ class PersonalDetails(TelegramObject):
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
# Required # Required
self.first_name = first_name self.first_name: str = first_name
self.last_name = last_name self.last_name: str = last_name
self.middle_name = middle_name self.middle_name: Optional[str] = middle_name
self.birth_date = birth_date self.birth_date: str = birth_date
self.gender = gender self.gender: str = gender
self.country_code = country_code self.country_code: str = country_code
self.residence_country_code = residence_country_code self.residence_country_code: str = residence_country_code
self.first_name_native = first_name_native self.first_name_native: Optional[str] = first_name_native
self.last_name_native = last_name_native self.last_name_native: Optional[str] = last_name_native
self.middle_name_native = middle_name_native self.middle_name_native: Optional[str] = middle_name_native
self._freeze() self._freeze()
@ -146,12 +147,12 @@ class ResidentialAddress(TelegramObject):
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
# Required # Required
self.street_line1 = street_line1 self.street_line1: str = street_line1
self.street_line2 = street_line2 self.street_line2: str = street_line2
self.city = city self.city: str = city
self.state = state self.state: str = state
self.country_code = country_code self.country_code: str = country_code
self.post_code = post_code self.post_code: str = post_code
self._freeze() self._freeze()
@ -179,7 +180,7 @@ class IdDocumentData(TelegramObject):
api_kwargs: JSONDict = None, api_kwargs: JSONDict = None,
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
self.document_no = document_no self.document_no: str = document_no
self.expiry_date = expiry_date self.expiry_date: str = expiry_date
self._freeze() self._freeze()

View file

@ -18,7 +18,7 @@
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram EncryptedPassportElement.""" """This module contains an object that represents a Telegram EncryptedPassportElement."""
from base64 import b64decode from base64 import b64decode
from typing import TYPE_CHECKING, Optional, Sequence from typing import TYPE_CHECKING, Optional, Sequence, Tuple
from telegram._passport.credentials import decrypt_json from telegram._passport.credentials import decrypt_json
from telegram._passport.data import IdDocumentData, PersonalDetails, ResidentialAddress from telegram._passport.data import IdDocumentData, PersonalDetails, ResidentialAddress
@ -166,17 +166,17 @@ class EncryptedPassportElement(TelegramObject):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
# Required # Required
self.type = type self.type: str = type
# Optionals # Optionals
self.data = data self.data: Optional[PersonalDetails] = data
self.phone_number = phone_number self.phone_number: Optional[str] = phone_number
self.email = email self.email: Optional[str] = email
self.files = parse_sequence_arg(files) self.files: Tuple[PassportFile, ...] = parse_sequence_arg(files)
self.front_side = front_side self.front_side: Optional[PassportFile] = front_side
self.reverse_side = reverse_side self.reverse_side: Optional[PassportFile] = reverse_side
self.selfie = selfie self.selfie: Optional[PassportFile] = selfie
self.translation = parse_sequence_arg(translation) self.translation: Tuple[PassportFile, ...] = parse_sequence_arg(translation)
self.hash = hash self.hash: str = hash
self._id_attrs = ( self._id_attrs = (
self.type, self.type,

View file

@ -72,8 +72,8 @@ class PassportData(TelegramObject):
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
self.data = parse_sequence_arg(data) self.data: Tuple[EncryptedPassportElement, ...] = parse_sequence_arg(data)
self.credentials = credentials self.credentials: EncryptedCredentials = credentials
self._decrypted_data: Optional[Tuple[EncryptedPassportElement]] = None self._decrypted_data: Optional[Tuple[EncryptedPassportElement]] = None
self._id_attrs = tuple([x.type for x in data] + [credentials.hash]) self._id_attrs = tuple([x.type for x in data] + [credentials.hash])

View file

@ -49,9 +49,9 @@ class PassportElementError(TelegramObject):
def __init__(self, source: str, type: str, message: str, *, api_kwargs: JSONDict = None): def __init__(self, source: str, type: str, message: str, *, api_kwargs: JSONDict = None):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
# Required # Required
self.source = str(source) self.source: str = str(source)
self.type = str(type) self.type: str = str(type)
self.message = str(message) self.message: str = str(message)
self._id_attrs = (self.source, self.type) self._id_attrs = (self.source, self.type)
@ -99,8 +99,8 @@ class PassportElementErrorDataField(PassportElementError):
# Required # Required
super().__init__("data", type, message, api_kwargs=api_kwargs) super().__init__("data", type, message, api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
self.field_name = field_name self.field_name: str = field_name
self.data_hash = data_hash self.data_hash: str = data_hash
self._id_attrs = ( self._id_attrs = (
self.source, self.source,
@ -142,7 +142,7 @@ class PassportElementErrorFile(PassportElementError):
# Required # Required
super().__init__("file", type, message, api_kwargs=api_kwargs) super().__init__("file", type, message, api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
self.file_hash = file_hash self.file_hash: str = file_hash
self._id_attrs = (self.source, self.type, self.file_hash, self.message) self._id_attrs = (self.source, self.type, self.file_hash, self.message)
@ -178,7 +178,7 @@ class PassportElementErrorFiles(PassportElementError):
# Required # Required
super().__init__("files", type, message, api_kwargs=api_kwargs) super().__init__("files", type, message, api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
self.file_hashes = file_hashes self.file_hashes: str = file_hashes
self._id_attrs = (self.source, self.type, self.message) + tuple(file_hashes) self._id_attrs = (self.source, self.type, self.message) + tuple(file_hashes)
@ -214,7 +214,7 @@ class PassportElementErrorFrontSide(PassportElementError):
# Required # Required
super().__init__("front_side", type, message, api_kwargs=api_kwargs) super().__init__("front_side", type, message, api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
self.file_hash = file_hash self.file_hash: str = file_hash
self._id_attrs = (self.source, self.type, self.file_hash, self.message) self._id_attrs = (self.source, self.type, self.file_hash, self.message)
@ -250,7 +250,7 @@ class PassportElementErrorReverseSide(PassportElementError):
# Required # Required
super().__init__("reverse_side", type, message, api_kwargs=api_kwargs) super().__init__("reverse_side", type, message, api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
self.file_hash = file_hash self.file_hash: str = file_hash
self._id_attrs = (self.source, self.type, self.file_hash, self.message) self._id_attrs = (self.source, self.type, self.file_hash, self.message)
@ -284,7 +284,7 @@ class PassportElementErrorSelfie(PassportElementError):
# Required # Required
super().__init__("selfie", type, message, api_kwargs=api_kwargs) super().__init__("selfie", type, message, api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
self.file_hash = file_hash self.file_hash: str = file_hash
self._id_attrs = (self.source, self.type, self.file_hash, self.message) self._id_attrs = (self.source, self.type, self.file_hash, self.message)
@ -322,7 +322,7 @@ class PassportElementErrorTranslationFile(PassportElementError):
# Required # Required
super().__init__("translation_file", type, message, api_kwargs=api_kwargs) super().__init__("translation_file", type, message, api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
self.file_hash = file_hash self.file_hash: str = file_hash
self._id_attrs = (self.source, self.type, self.file_hash, self.message) self._id_attrs = (self.source, self.type, self.file_hash, self.message)
@ -360,7 +360,7 @@ class PassportElementErrorTranslationFiles(PassportElementError):
# Required # Required
super().__init__("translation_files", type, message, api_kwargs=api_kwargs) super().__init__("translation_files", type, message, api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
self.file_hashes = file_hashes self.file_hashes: str = file_hashes
self._id_attrs = (self.source, self.type, self.message) + tuple(file_hashes) self._id_attrs = (self.source, self.type, self.message) + tuple(file_hashes)
@ -392,6 +392,6 @@ class PassportElementErrorUnspecified(PassportElementError):
# Required # Required
super().__init__("unspecified", type, message, api_kwargs=api_kwargs) super().__init__("unspecified", type, message, api_kwargs=api_kwargs)
with self._unfrozen(): with self._unfrozen():
self.element_hash = element_hash self.element_hash: str = element_hash
self._id_attrs = (self.source, self.type, self.element_hash, self.message) self._id_attrs = (self.source, self.type, self.element_hash, self.message)

View file

@ -78,13 +78,13 @@ class PassportFile(TelegramObject):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
# Required # Required
self.file_id = file_id self.file_id: str = file_id
self.file_unique_id = file_unique_id self.file_unique_id: str = file_unique_id
self.file_size = file_size self.file_size: int = file_size
self.file_date = file_date self.file_date: int = file_date
# Optionals # Optionals
self._credentials = credentials self._credentials: Optional[FileCredentials] = credentials
self._id_attrs = (self.file_unique_id,) self._id_attrs = (self.file_unique_id,)

View file

@ -79,11 +79,11 @@ class Invoice(TelegramObject):
api_kwargs: JSONDict = None, api_kwargs: JSONDict = None,
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
self.title = title self.title: str = title
self.description = description self.description: str = description
self.start_parameter = start_parameter self.start_parameter: str = start_parameter
self.currency = currency self.currency: str = currency
self.total_amount = total_amount self.total_amount: int = total_amount
self._id_attrs = ( self._id_attrs = (
self.title, self.title,

View file

@ -55,8 +55,8 @@ class LabeledPrice(TelegramObject):
def __init__(self, label: str, amount: int, *, api_kwargs: JSONDict = None): def __init__(self, label: str, amount: int, *, api_kwargs: JSONDict = None):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
self.label = label self.label: str = label
self.amount = amount self.amount: int = amount
self._id_attrs = (self.label, self.amount) self._id_attrs = (self.label, self.amount)

View file

@ -61,10 +61,10 @@ class OrderInfo(TelegramObject):
api_kwargs: JSONDict = None, api_kwargs: JSONDict = None,
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
self.name = name self.name: Optional[str] = name
self.phone_number = phone_number self.phone_number: Optional[str] = phone_number
self.email = email self.email: Optional[str] = email
self.shipping_address = shipping_address self.shipping_address: Optional[str] = shipping_address
self._id_attrs = (self.name, self.phone_number, self.email, self.shipping_address) self._id_attrs = (self.name, self.phone_number, self.email, self.shipping_address)

View file

@ -95,13 +95,13 @@ class PreCheckoutQuery(TelegramObject):
api_kwargs: JSONDict = None, api_kwargs: JSONDict = None,
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
self.id = id # pylint: disable=invalid-name self.id: str = id # pylint: disable=invalid-name
self.from_user = from_user self.from_user: User = from_user
self.currency = currency self.currency: str = currency
self.total_amount = total_amount self.total_amount: int = total_amount
self.invoice_payload = invoice_payload self.invoice_payload: str = invoice_payload
self.shipping_option_id = shipping_option_id self.shipping_option_id: Optional[str] = shipping_option_id
self.order_info = order_info self.order_info: Optional[OrderInfo] = order_info
self._id_attrs = (self.id,) self._id_attrs = (self.id,)

View file

@ -68,12 +68,12 @@ class ShippingAddress(TelegramObject):
api_kwargs: JSONDict = None, api_kwargs: JSONDict = None,
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
self.country_code = country_code self.country_code: str = country_code
self.state = state self.state: str = state
self.city = city self.city: str = city
self.street_line1 = street_line1 self.street_line1: str = street_line1
self.street_line2 = street_line2 self.street_line2: str = street_line2
self.post_code = post_code self.post_code: str = post_code
self._id_attrs = ( self._id_attrs = (
self.country_code, self.country_code,

View file

@ -17,7 +17,7 @@
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram ShippingOption.""" """This module contains an object that represents a Telegram ShippingOption."""
from typing import TYPE_CHECKING, Sequence from typing import TYPE_CHECKING, Sequence, Tuple
from telegram._telegramobject import TelegramObject from telegram._telegramobject import TelegramObject
from telegram._utils.argumentparsing import parse_sequence_arg from telegram._utils.argumentparsing import parse_sequence_arg
@ -66,9 +66,9 @@ class ShippingOption(TelegramObject):
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
self.id = id # pylint: disable=invalid-name self.id: str = id # pylint: disable=invalid-name
self.title = title self.title: str = title
self.prices = parse_sequence_arg(prices) self.prices: Tuple["LabeledPrice", ...] = parse_sequence_arg(prices)
self._id_attrs = (self.id,) self._id_attrs = (self.id,)

View file

@ -67,10 +67,10 @@ class ShippingQuery(TelegramObject):
api_kwargs: JSONDict = None, api_kwargs: JSONDict = None,
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
self.id = id # pylint: disable=invalid-name self.id: str = id # pylint: disable=invalid-name
self.from_user = from_user self.from_user: User = from_user
self.invoice_payload = invoice_payload self.invoice_payload: str = invoice_payload
self.shipping_address = shipping_address self.shipping_address: ShippingAddress = shipping_address
self._id_attrs = (self.id,) self._id_attrs = (self.id,)

View file

@ -90,13 +90,13 @@ class SuccessfulPayment(TelegramObject):
api_kwargs: JSONDict = None, api_kwargs: JSONDict = None,
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
self.currency = currency self.currency: str = currency
self.total_amount = total_amount self.total_amount: int = total_amount
self.invoice_payload = invoice_payload self.invoice_payload: str = invoice_payload
self.shipping_option_id = shipping_option_id self.shipping_option_id: Optional[str] = shipping_option_id
self.order_info = order_info self.order_info: Optional[OrderInfo] = order_info
self.telegram_payment_charge_id = telegram_payment_charge_id self.telegram_payment_charge_id: str = telegram_payment_charge_id
self.provider_payment_charge_id = provider_payment_charge_id self.provider_payment_charge_id: str = provider_payment_charge_id
self._id_attrs = (self.telegram_payment_charge_id, self.provider_payment_charge_id) self._id_attrs = (self.telegram_payment_charge_id, self.provider_payment_charge_id)

View file

@ -19,7 +19,7 @@
"""This module contains an object that represents a Telegram Poll.""" """This module contains an object that represents a Telegram Poll."""
import datetime import datetime
import sys import sys
from typing import TYPE_CHECKING, ClassVar, Dict, List, Optional, Sequence from typing import TYPE_CHECKING, ClassVar, Dict, List, Optional, Sequence, Tuple
from telegram import constants from telegram import constants
from telegram._messageentity import MessageEntity from telegram._messageentity import MessageEntity
@ -59,8 +59,8 @@ class PollOption(TelegramObject):
def __init__(self, text: str, voter_count: int, *, api_kwargs: JSONDict = None): def __init__(self, text: str, voter_count: int, *, api_kwargs: JSONDict = None):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
self.text = text self.text: str = text
self.voter_count = voter_count self.voter_count: int = voter_count
self._id_attrs = (self.text, self.voter_count) self._id_attrs = (self.text, self.voter_count)
@ -111,9 +111,9 @@ class PollAnswer(TelegramObject):
self, poll_id: str, user: User, option_ids: Sequence[int], *, api_kwargs: JSONDict = None self, poll_id: str, user: User, option_ids: Sequence[int], *, api_kwargs: JSONDict = None
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
self.poll_id = poll_id self.poll_id: str = poll_id
self.user = user self.user: User = user
self.option_ids = parse_sequence_arg(option_ids) self.option_ids: Tuple[int, ...] = parse_sequence_arg(option_ids)
self._id_attrs = (self.poll_id, self.user, tuple(self.option_ids)) self._id_attrs = (self.poll_id, self.user, tuple(self.option_ids))
@ -244,19 +244,21 @@ class Poll(TelegramObject):
api_kwargs: JSONDict = None, api_kwargs: JSONDict = None,
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
self.id = id # pylint: disable=invalid-name self.id: str = id # pylint: disable=invalid-name
self.question = question self.question: str = question
self.options = parse_sequence_arg(options) self.options: Tuple[PollOption, ...] = parse_sequence_arg(options)
self.total_voter_count = total_voter_count self.total_voter_count: int = total_voter_count
self.is_closed = is_closed self.is_closed: bool = is_closed
self.is_anonymous = is_anonymous self.is_anonymous: bool = is_anonymous
self.type = enum.get_member(constants.PollType, type, type) self.type: str = enum.get_member(constants.PollType, type, type)
self.allows_multiple_answers = allows_multiple_answers self.allows_multiple_answers: bool = allows_multiple_answers
self.correct_option_id = correct_option_id self.correct_option_id: Optional[int] = correct_option_id
self.explanation = explanation self.explanation: Optional[str] = explanation
self.explanation_entities = parse_sequence_arg(explanation_entities) self.explanation_entities: Tuple[MessageEntity, ...] = parse_sequence_arg(
self.open_period = open_period explanation_entities
self.close_date = close_date )
self.open_period: Optional[int] = open_period
self.close_date: Optional[datetime.datetime] = close_date
self._id_attrs = (self.id,) self._id_attrs = (self.id,)

View file

@ -53,9 +53,9 @@ class ProximityAlertTriggered(TelegramObject):
self, traveler: User, watcher: User, distance: int, *, api_kwargs: JSONDict = None self, traveler: User, watcher: User, distance: int, *, api_kwargs: JSONDict = None
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
self.traveler = traveler self.traveler: User = traveler
self.watcher = watcher self.watcher: User = watcher
self.distance = distance self.distance: int = distance
self._id_attrs = (self.traveler, self.watcher, self.distance) self._id_attrs = (self.traveler, self.watcher, self.distance)

View file

@ -18,7 +18,7 @@
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram ReplyKeyboardMarkup.""" """This module contains an object that represents a Telegram ReplyKeyboardMarkup."""
from typing import ClassVar, Sequence, Union from typing import ClassVar, Optional, Sequence, Tuple, Union
from telegram import constants from telegram import constants
from telegram._keyboardbutton import KeyboardButton from telegram._keyboardbutton import KeyboardButton
@ -138,17 +138,17 @@ class ReplyKeyboardMarkup(TelegramObject):
) )
# Required # Required
self.keyboard = tuple( self.keyboard: Tuple[Tuple[KeyboardButton, ...], ...] = tuple(
tuple(KeyboardButton(button) if isinstance(button, str) else button for button in row) tuple(KeyboardButton(button) if isinstance(button, str) else button for button in row)
for row in keyboard for row in keyboard
) )
# Optionals # Optionals
self.resize_keyboard = resize_keyboard self.resize_keyboard: Optional[bool] = resize_keyboard
self.one_time_keyboard = one_time_keyboard self.one_time_keyboard: Optional[bool] = one_time_keyboard
self.selective = selective self.selective: Optional[bool] = selective
self.input_field_placeholder = input_field_placeholder self.input_field_placeholder: Optional[str] = input_field_placeholder
self.is_persistent = is_persistent self.is_persistent: Optional[bool] = is_persistent
self._id_attrs = (self.keyboard,) self._id_attrs = (self.keyboard,)

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram ReplyKeyboardRemove.""" """This module contains an object that represents a Telegram ReplyKeyboardRemove."""
from typing import Optional
from telegram._telegramobject import TelegramObject from telegram._telegramobject import TelegramObject
from telegram._utils.types import JSONDict from telegram._utils.types import JSONDict
@ -64,8 +65,8 @@ class ReplyKeyboardRemove(TelegramObject):
def __init__(self, selective: bool = None, *, api_kwargs: JSONDict = None): def __init__(self, selective: bool = None, *, api_kwargs: JSONDict = None):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
# Required # Required
self.remove_keyboard = True self.remove_keyboard: bool = True
# Optionals # Optionals
self.selective = selective self.selective: Optional[bool] = selective
self._freeze() self._freeze()

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram Sent Web App Message.""" """This module contains an object that represents a Telegram Sent Web App Message."""
from typing import Optional
from telegram._telegramobject import TelegramObject from telegram._telegramobject import TelegramObject
from telegram._utils.types import JSONDict from telegram._utils.types import JSONDict
@ -46,7 +47,7 @@ class SentWebAppMessage(TelegramObject):
def __init__(self, inline_message_id: str = None, *, api_kwargs: JSONDict = None): def __init__(self, inline_message_id: str = None, *, api_kwargs: JSONDict = None):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
# Optionals # Optionals
self.inline_message_id = inline_message_id self.inline_message_id: Optional[str] = inline_message_id
self._id_attrs = (self.inline_message_id,) self._id_attrs = (self.inline_message_id,)

View file

@ -38,6 +38,7 @@ from typing import (
Type, Type,
TypeVar, TypeVar,
Union, Union,
cast,
) )
from telegram._utils.datetime import to_timestamp from telegram._utils.datetime import to_timestamp
@ -259,7 +260,7 @@ class TelegramObject:
out["api_kwargs"] = dict(self.api_kwargs) out["api_kwargs"] = dict(self.api_kwargs)
return out return out
def __setstate__(self, state: dict) -> None: def __setstate__(self, state: Dict[str, object]) -> None:
""" """
Overrides :meth:`object.__setstate__` to customize the unpickling process of objects of Overrides :meth:`object.__setstate__` to customize the unpickling process of objects of
this type. Modifies the object in-place. this type. Modifies the object in-place.
@ -283,7 +284,7 @@ class TelegramObject:
setattr(self, "_bot", None) setattr(self, "_bot", None)
# get api_kwargs first because we may need to add entries to it (see try-except below) # get api_kwargs first because we may need to add entries to it (see try-except below)
api_kwargs = state.pop("api_kwargs", {}) api_kwargs = cast(Dict[str, object], state.pop("api_kwargs", {}))
# get _frozen before the loop to avoid setting it to True in the loop # get _frozen before the loop to avoid setting it to True in the loop
frozen = state.pop("_frozen", False) frozen = state.pop("_frozen", False)
@ -307,7 +308,7 @@ class TelegramObject:
if frozen: if frozen:
self._freeze() self._freeze()
def __deepcopy__(self: Tele_co, memodict: dict) -> Tele_co: def __deepcopy__(self: Tele_co, memodict: Dict[int, object]) -> Tele_co:
""" """
Customizes how :func:`copy.deepcopy` processes objects of this type. Customizes how :func:`copy.deepcopy` processes objects of this type.
The only difference to the default implementation is that the :class:`telegram.Bot` The only difference to the default implementation is that the :class:`telegram.Bot`

View file

@ -254,22 +254,22 @@ class Update(TelegramObject):
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
# Required # Required
self.update_id = update_id self.update_id: int = update_id
# Optionals # Optionals
self.message = message self.message: Optional[Message] = message
self.edited_message = edited_message self.edited_message: Optional[Message] = edited_message
self.inline_query = inline_query self.inline_query: Optional[InlineQuery] = inline_query
self.chosen_inline_result = chosen_inline_result self.chosen_inline_result: Optional[ChosenInlineResult] = chosen_inline_result
self.callback_query = callback_query self.callback_query: Optional[CallbackQuery] = callback_query
self.shipping_query = shipping_query self.shipping_query: Optional[ShippingQuery] = shipping_query
self.pre_checkout_query = pre_checkout_query self.pre_checkout_query: Optional[PreCheckoutQuery] = pre_checkout_query
self.channel_post = channel_post self.channel_post: Optional[Message] = channel_post
self.edited_channel_post = edited_channel_post self.edited_channel_post: Optional[Message] = edited_channel_post
self.poll = poll self.poll: Optional[Poll] = poll
self.poll_answer = poll_answer self.poll_answer: Optional[PollAnswer] = poll_answer
self.my_chat_member = my_chat_member self.my_chat_member: Optional[ChatMemberUpdated] = my_chat_member
self.chat_member = chat_member self.chat_member: Optional[ChatMemberUpdated] = chat_member
self.chat_join_request = chat_join_request self.chat_join_request: Optional[ChatJoinRequest] = chat_join_request
self._effective_user: Optional["User"] = None self._effective_user: Optional["User"] = None
self._effective_chat: Optional["Chat"] = None self._effective_chat: Optional["Chat"] = None

View file

@ -143,18 +143,18 @@ class User(TelegramObject):
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
# Required # Required
self.id = id # pylint: disable=invalid-name self.id: int = id # pylint: disable=invalid-name
self.first_name = first_name self.first_name: str = first_name
self.is_bot = is_bot self.is_bot: bool = is_bot
# Optionals # Optionals
self.last_name = last_name self.last_name: Optional[str] = last_name
self.username = username self.username: Optional[str] = username
self.language_code = language_code self.language_code: Optional[str] = language_code
self.can_join_groups = can_join_groups self.can_join_groups: Optional[bool] = can_join_groups
self.can_read_all_group_messages = can_read_all_group_messages self.can_read_all_group_messages: Optional[bool] = can_read_all_group_messages
self.supports_inline_queries = supports_inline_queries self.supports_inline_queries: Optional[bool] = supports_inline_queries
self.is_premium = is_premium self.is_premium: Optional[bool] = is_premium
self.added_to_attachment_menu = added_to_attachment_menu self.added_to_attachment_menu: Optional[bool] = added_to_attachment_menu
self._id_attrs = (self.id,) self._id_attrs = (self.id,)

View file

@ -17,7 +17,7 @@
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram UserProfilePhotos.""" """This module contains an object that represents a Telegram UserProfilePhotos."""
from typing import TYPE_CHECKING, Optional, Sequence from typing import TYPE_CHECKING, Optional, Sequence, Tuple
from telegram._files.photosize import PhotoSize from telegram._files.photosize import PhotoSize
from telegram._telegramobject import TelegramObject from telegram._telegramobject import TelegramObject
@ -62,8 +62,8 @@ class UserProfilePhotos(TelegramObject):
): ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
# Required # Required
self.total_count = total_count self.total_count: int = total_count
self.photos = tuple(tuple(sizes) for sizes in photos) self.photos: Tuple[Tuple[PhotoSize, ...], ...] = tuple(tuple(sizes) for sizes in photos)
self._id_attrs = (self.total_count, self.photos) self._id_attrs = (self.total_count, self.photos)

Some files were not shown because too many files have changed in this diff Show more