Use Explicit Optionals (#3692)

Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
This commit is contained in:
MiguelX413 2023-05-18 05:57:59 +00:00 committed by GitHub
parent e432c296a9
commit 99fd4432db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
146 changed files with 2798 additions and 2637 deletions

View file

@ -77,6 +77,7 @@ The following wonderful people contributed directly or indirectly to this projec
- `Matheus Lemos <https://github.com/mlemosf>`_
- `Michael Dix <https://github.com/Eisberge>`_
- `Michael Elovskikh <https://github.com/wronglink>`_
- `Miguel C. R. <https://github.com/MiguelX413>`_
- `miles <https://github.com/miles170>`_
- `Mischa Krüger <https://github.com/Makman2>`_
- `naveenvhegde <https://github.com/naveenvhegde>`_

View file

@ -57,7 +57,12 @@ class ChatData:
class CustomContext(CallbackContext[ExtBot, dict, ChatData, dict]):
"""Custom class for context."""
def __init__(self, application: Application, chat_id: int = None, user_id: int = None):
def __init__(
self,
application: Application,
chat_id: Optional[int] = None,
user_id: Optional[int] = None,
):
super().__init__(application=application, chat_id=chat_id, user_id=user_id)
self._message_id: Optional[int] = None

View file

@ -64,7 +64,6 @@ disallow_untyped_defs = True
disallow_incomplete_defs = True
disallow_untyped_decorators = True
show_error_codes = True
implicit_optional = True
# For some files, it's easier to just disable strict-optional all together instead of
# cluttering the code with `# type: ignore`s or stuff like

File diff suppressed because it is too large Load diff

View file

@ -18,7 +18,7 @@
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram Bot Command."""
from typing import ClassVar
from typing import ClassVar, Optional
from telegram import constants
from telegram._telegramobject import TelegramObject
@ -52,7 +52,7 @@ class BotCommand(TelegramObject):
__slots__ = ("description", "command")
def __init__(self, command: str, description: str, *, api_kwargs: JSONDict = None):
def __init__(self, command: str, description: str, *, api_kwargs: Optional[JSONDict] = None):
super().__init__(api_kwargs=api_kwargs)
self.command: str = command
self.description: str = description

View file

@ -75,7 +75,7 @@ class BotCommandScope(TelegramObject):
CHAT_MEMBER: ClassVar[str] = constants.BotCommandScopeType.CHAT_MEMBER
""":const:`telegram.constants.BotCommandScopeType.CHAT_MEMBER`"""
def __init__(self, type: str, *, api_kwargs: JSONDict = None):
def __init__(self, type: str, *, api_kwargs: Optional[JSONDict] = None):
super().__init__(api_kwargs=api_kwargs)
self.type: str = type
self._id_attrs = (self.type,)
@ -128,7 +128,7 @@ class BotCommandScopeDefault(BotCommandScope):
__slots__ = ()
def __init__(self, *, api_kwargs: JSONDict = None):
def __init__(self, *, api_kwargs: Optional[JSONDict] = None):
super().__init__(type=BotCommandScope.DEFAULT, api_kwargs=api_kwargs)
self._freeze()
@ -144,7 +144,7 @@ class BotCommandScopeAllPrivateChats(BotCommandScope):
__slots__ = ()
def __init__(self, *, api_kwargs: JSONDict = None):
def __init__(self, *, api_kwargs: Optional[JSONDict] = None):
super().__init__(type=BotCommandScope.ALL_PRIVATE_CHATS, api_kwargs=api_kwargs)
self._freeze()
@ -159,7 +159,7 @@ class BotCommandScopeAllGroupChats(BotCommandScope):
__slots__ = ()
def __init__(self, *, api_kwargs: JSONDict = None):
def __init__(self, *, api_kwargs: Optional[JSONDict] = None):
super().__init__(type=BotCommandScope.ALL_GROUP_CHATS, api_kwargs=api_kwargs)
self._freeze()
@ -174,7 +174,7 @@ class BotCommandScopeAllChatAdministrators(BotCommandScope):
__slots__ = ()
def __init__(self, *, api_kwargs: JSONDict = None):
def __init__(self, *, api_kwargs: Optional[JSONDict] = None):
super().__init__(type=BotCommandScope.ALL_CHAT_ADMINISTRATORS, api_kwargs=api_kwargs)
self._freeze()
@ -197,7 +197,7 @@ class BotCommandScopeChat(BotCommandScope):
__slots__ = ("chat_id",)
def __init__(self, chat_id: Union[str, int], *, api_kwargs: JSONDict = None):
def __init__(self, chat_id: Union[str, int], *, api_kwargs: Optional[JSONDict] = None):
super().__init__(type=BotCommandScope.CHAT, api_kwargs=api_kwargs)
with self._unfrozen():
self.chat_id: Union[str, int] = (
@ -224,7 +224,7 @@ class BotCommandScopeChatAdministrators(BotCommandScope):
__slots__ = ("chat_id",)
def __init__(self, chat_id: Union[str, int], *, api_kwargs: JSONDict = None):
def __init__(self, chat_id: Union[str, int], *, api_kwargs: Optional[JSONDict] = None):
super().__init__(type=BotCommandScope.CHAT_ADMINISTRATORS, api_kwargs=api_kwargs)
with self._unfrozen():
self.chat_id: Union[str, int] = (
@ -254,7 +254,9 @@ class BotCommandScopeChatMember(BotCommandScope):
__slots__ = ("chat_id", "user_id")
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: Optional[JSONDict] = None
):
super().__init__(type=BotCommandScope.CHAT_MEMBER, api_kwargs=api_kwargs)
with self._unfrozen():
self.chat_id: Union[str, int] = (

View file

@ -17,6 +17,8 @@
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains two objects that represent a Telegram bots (short) description."""
from typing import Optional
from telegram._telegramobject import TelegramObject
from telegram._utils.types import JSONDict
@ -39,7 +41,7 @@ class BotDescription(TelegramObject):
__slots__ = ("description",)
def __init__(self, description: str, *, api_kwargs: JSONDict = None):
def __init__(self, description: str, *, api_kwargs: Optional[JSONDict] = None):
super().__init__(api_kwargs=api_kwargs)
self.description: str = description
@ -66,7 +68,7 @@ class BotShortDescription(TelegramObject):
__slots__ = ("short_description",)
def __init__(self, short_description: str, *, api_kwargs: JSONDict = None):
def __init__(self, short_description: str, *, api_kwargs: Optional[JSONDict] = None):
super().__init__(api_kwargs=api_kwargs)
self.short_description: str = short_description

View file

@ -17,7 +17,7 @@
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represent a Telegram bots name."""
from typing import ClassVar
from typing import ClassVar, Optional
from telegram import constants
from telegram._telegramobject import TelegramObject
@ -42,7 +42,7 @@ class BotName(TelegramObject):
__slots__ = ("name",)
def __init__(self, name: str, *, api_kwargs: JSONDict = None):
def __init__(self, name: str, *, api_kwargs: Optional[JSONDict] = None):
super().__init__(api_kwargs=api_kwargs)
self.name: str = name

View file

@ -118,12 +118,12 @@ class CallbackQuery(TelegramObject):
id: str,
from_user: User,
chat_instance: str,
message: Message = None,
data: str = None,
inline_message_id: str = None,
game_short_name: str = None,
message: Optional[Message] = None,
data: Optional[str] = None,
inline_message_id: Optional[str] = None,
game_short_name: Optional[str] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
# Required
@ -155,16 +155,16 @@ class CallbackQuery(TelegramObject):
async def answer(
self,
text: str = None,
show_alert: bool = None,
url: str = None,
cache_time: int = None,
text: Optional[str] = None,
show_alert: Optional[bool] = None,
url: Optional[str] = None,
cache_time: Optional[int] = None,
*,
read_timeout: ODVInput[float] = DEFAULT_NONE,
write_timeout: ODVInput[float] = DEFAULT_NONE,
connect_timeout: ODVInput[float] = DEFAULT_NONE,
pool_timeout: ODVInput[float] = DEFAULT_NONE,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
) -> bool:
"""Shortcut for::
@ -195,14 +195,14 @@ class CallbackQuery(TelegramObject):
text: str,
parse_mode: ODVInput[str] = DEFAULT_NONE,
disable_web_page_preview: ODVInput[bool] = DEFAULT_NONE,
reply_markup: "InlineKeyboardMarkup" = None,
entities: Sequence["MessageEntity"] = None,
reply_markup: Optional["InlineKeyboardMarkup"] = None,
entities: Optional[Sequence["MessageEntity"]] = None,
*,
read_timeout: ODVInput[float] = DEFAULT_NONE,
write_timeout: ODVInput[float] = DEFAULT_NONE,
connect_timeout: ODVInput[float] = DEFAULT_NONE,
pool_timeout: ODVInput[float] = DEFAULT_NONE,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
) -> Union[Message, bool]:
"""Shortcut for either::
@ -253,16 +253,16 @@ class CallbackQuery(TelegramObject):
async def edit_message_caption(
self,
caption: str = None,
reply_markup: "InlineKeyboardMarkup" = None,
caption: Optional[str] = None,
reply_markup: Optional["InlineKeyboardMarkup"] = None,
parse_mode: ODVInput[str] = DEFAULT_NONE,
caption_entities: Sequence["MessageEntity"] = None,
caption_entities: Optional[Sequence["MessageEntity"]] = None,
*,
read_timeout: ODVInput[float] = DEFAULT_NONE,
write_timeout: ODVInput[float] = DEFAULT_NONE,
connect_timeout: ODVInput[float] = DEFAULT_NONE,
pool_timeout: ODVInput[float] = DEFAULT_NONE,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
) -> Union[Message, bool]:
"""Shortcut for either::
@ -317,7 +317,7 @@ class CallbackQuery(TelegramObject):
write_timeout: ODVInput[float] = DEFAULT_NONE,
connect_timeout: ODVInput[float] = DEFAULT_NONE,
pool_timeout: ODVInput[float] = DEFAULT_NONE,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
) -> Union[Message, bool]:
"""Shortcut for either::
@ -362,13 +362,13 @@ class CallbackQuery(TelegramObject):
async def edit_message_media(
self,
media: "InputMedia",
reply_markup: "InlineKeyboardMarkup" = None,
reply_markup: Optional["InlineKeyboardMarkup"] = None,
*,
read_timeout: ODVInput[float] = DEFAULT_NONE,
write_timeout: ODVInput[float] = DEFAULT_NONE,
connect_timeout: ODVInput[float] = DEFAULT_NONE,
pool_timeout: ODVInput[float] = DEFAULT_NONE,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
) -> Union[Message, bool]:
"""Shortcut for either::
@ -413,19 +413,19 @@ class CallbackQuery(TelegramObject):
async def edit_message_live_location(
self,
latitude: float = None,
longitude: float = None,
reply_markup: "InlineKeyboardMarkup" = None,
horizontal_accuracy: float = None,
heading: int = None,
proximity_alert_radius: int = None,
latitude: Optional[float] = None,
longitude: Optional[float] = None,
reply_markup: Optional["InlineKeyboardMarkup"] = None,
horizontal_accuracy: Optional[float] = None,
heading: Optional[int] = None,
proximity_alert_radius: Optional[int] = None,
*,
location: Location = None,
location: Optional[Location] = None,
read_timeout: ODVInput[float] = DEFAULT_NONE,
write_timeout: ODVInput[float] = DEFAULT_NONE,
connect_timeout: ODVInput[float] = DEFAULT_NONE,
pool_timeout: ODVInput[float] = DEFAULT_NONE,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
) -> Union[Message, bool]:
"""Shortcut for either::
@ -481,13 +481,13 @@ class CallbackQuery(TelegramObject):
async def stop_message_live_location(
self,
reply_markup: "InlineKeyboardMarkup" = None,
reply_markup: Optional["InlineKeyboardMarkup"] = None,
*,
read_timeout: ODVInput[float] = DEFAULT_NONE,
write_timeout: ODVInput[float] = DEFAULT_NONE,
connect_timeout: ODVInput[float] = DEFAULT_NONE,
pool_timeout: ODVInput[float] = DEFAULT_NONE,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
) -> Union[Message, bool]:
"""Shortcut for either::
@ -533,14 +533,14 @@ class CallbackQuery(TelegramObject):
self,
user_id: Union[int, str],
score: int,
force: bool = None,
disable_edit_message: bool = None,
force: Optional[bool] = None,
disable_edit_message: Optional[bool] = None,
*,
read_timeout: ODVInput[float] = DEFAULT_NONE,
write_timeout: ODVInput[float] = DEFAULT_NONE,
connect_timeout: ODVInput[float] = DEFAULT_NONE,
pool_timeout: ODVInput[float] = DEFAULT_NONE,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
) -> Union[Message, bool]:
"""Shortcut for either::
@ -595,7 +595,7 @@ class CallbackQuery(TelegramObject):
write_timeout: ODVInput[float] = DEFAULT_NONE,
connect_timeout: ODVInput[float] = DEFAULT_NONE,
pool_timeout: ODVInput[float] = DEFAULT_NONE,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
) -> Tuple["GameHighScore", ...]:
"""Shortcut for either::
@ -643,7 +643,7 @@ class CallbackQuery(TelegramObject):
write_timeout: ODVInput[float] = DEFAULT_NONE,
connect_timeout: ODVInput[float] = DEFAULT_NONE,
pool_timeout: ODVInput[float] = DEFAULT_NONE,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
) -> bool:
"""Shortcut for::
@ -671,7 +671,7 @@ class CallbackQuery(TelegramObject):
write_timeout: ODVInput[float] = DEFAULT_NONE,
connect_timeout: ODVInput[float] = DEFAULT_NONE,
pool_timeout: ODVInput[float] = DEFAULT_NONE,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
) -> bool:
"""Shortcut for::
@ -699,7 +699,7 @@ class CallbackQuery(TelegramObject):
write_timeout: ODVInput[float] = DEFAULT_NONE,
connect_timeout: ODVInput[float] = DEFAULT_NONE,
pool_timeout: ODVInput[float] = DEFAULT_NONE,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
) -> bool:
"""Shortcut for::
@ -722,21 +722,21 @@ class CallbackQuery(TelegramObject):
async def copy_message(
self,
chat_id: Union[int, str],
caption: str = None,
caption: Optional[str] = None,
parse_mode: ODVInput[str] = DEFAULT_NONE,
caption_entities: Sequence["MessageEntity"] = None,
caption_entities: Optional[Sequence["MessageEntity"]] = None,
disable_notification: DVInput[bool] = DEFAULT_NONE,
reply_to_message_id: int = None,
reply_to_message_id: Optional[int] = None,
allow_sending_without_reply: DVInput[bool] = DEFAULT_NONE,
reply_markup: ReplyMarkup = None,
reply_markup: Optional[ReplyMarkup] = None,
protect_content: ODVInput[bool] = DEFAULT_NONE,
message_thread_id: int = None,
message_thread_id: Optional[int] = None,
*,
read_timeout: ODVInput[float] = DEFAULT_NONE,
write_timeout: ODVInput[float] = DEFAULT_NONE,
connect_timeout: ODVInput[float] = DEFAULT_NONE,
pool_timeout: ODVInput[float] = DEFAULT_NONE,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
) -> "MessageId":
"""Shortcut for::

File diff suppressed because it is too large Load diff

View file

@ -127,12 +127,12 @@ class ChatAdministratorRights(TelegramObject):
can_promote_members: bool,
can_change_info: bool,
can_invite_users: bool,
can_post_messages: bool = None,
can_edit_messages: bool = None,
can_pin_messages: bool = None,
can_manage_topics: bool = None,
can_post_messages: Optional[bool] = None,
can_edit_messages: Optional[bool] = None,
can_pin_messages: Optional[bool] = None,
can_manage_topics: Optional[bool] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
) -> None:
super().__init__(api_kwargs=api_kwargs)
# Required

View file

@ -118,12 +118,12 @@ class ChatInviteLink(TelegramObject):
creates_join_request: bool,
is_primary: bool,
is_revoked: bool,
expire_date: datetime.datetime = None,
member_limit: int = None,
name: str = None,
pending_join_request_count: int = None,
expire_date: Optional[datetime.datetime] = None,
member_limit: Optional[int] = None,
name: Optional[str] = None,
pending_join_request_count: Optional[int] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
# Required

View file

@ -102,10 +102,10 @@ class ChatJoinRequest(TelegramObject):
from_user: User,
date: datetime.datetime,
user_chat_id: int,
bio: str = None,
invite_link: ChatInviteLink = None,
bio: Optional[str] = None,
invite_link: Optional[ChatInviteLink] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
# Required
@ -147,7 +147,7 @@ class ChatJoinRequest(TelegramObject):
write_timeout: ODVInput[float] = DEFAULT_NONE,
connect_timeout: ODVInput[float] = DEFAULT_NONE,
pool_timeout: ODVInput[float] = DEFAULT_NONE,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
) -> bool:
"""Shortcut for::
@ -179,7 +179,7 @@ class ChatJoinRequest(TelegramObject):
write_timeout: ODVInput[float] = DEFAULT_NONE,
connect_timeout: ODVInput[float] = DEFAULT_NONE,
pool_timeout: ODVInput[float] = DEFAULT_NONE,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
) -> bool:
"""Shortcut for::

View file

@ -57,7 +57,7 @@ class ChatLocation(TelegramObject):
location: Location,
address: str,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
self.location: Location = location

View file

@ -92,7 +92,7 @@ class ChatMember(TelegramObject):
user: User,
status: str,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
# Required by all subclasses
@ -162,9 +162,9 @@ class ChatMemberOwner(ChatMember):
self,
user: User,
is_anonymous: bool,
custom_title: str = None,
custom_title: Optional[str] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(status=ChatMember.OWNER, user=user, api_kwargs=api_kwargs)
with self._unfrozen():
@ -295,13 +295,13 @@ class ChatMemberAdministrator(ChatMember):
can_promote_members: bool,
can_change_info: bool,
can_invite_users: bool,
can_post_messages: bool = None,
can_edit_messages: bool = None,
can_pin_messages: bool = None,
can_manage_topics: bool = None,
custom_title: str = None,
can_post_messages: Optional[bool] = None,
can_edit_messages: Optional[bool] = None,
can_pin_messages: Optional[bool] = None,
can_manage_topics: Optional[bool] = None,
custom_title: Optional[str] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(status=ChatMember.ADMINISTRATOR, user=user, api_kwargs=api_kwargs)
with self._unfrozen():
@ -344,7 +344,7 @@ class ChatMemberMember(ChatMember):
self,
user: User,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(status=ChatMember.MEMBER, user=user, api_kwargs=api_kwargs)
self._freeze()
@ -511,7 +511,7 @@ class ChatMemberRestricted(ChatMember):
can_send_video_notes: bool,
can_send_voice_notes: bool,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(status=ChatMember.RESTRICTED, user=user, api_kwargs=api_kwargs)
with self._unfrozen():
@ -556,7 +556,7 @@ class ChatMemberLeft(ChatMember):
self,
user: User,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(status=ChatMember.LEFT, user=user, api_kwargs=api_kwargs)
self._freeze()
@ -596,7 +596,7 @@ class ChatMemberBanned(ChatMember):
user: User,
until_date: datetime.datetime,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(status=ChatMember.BANNED, user=user, api_kwargs=api_kwargs)
with self._unfrozen():

View file

@ -100,10 +100,10 @@ class ChatMemberUpdated(TelegramObject):
date: datetime.datetime,
old_chat_member: ChatMember,
new_chat_member: ChatMember,
invite_link: ChatInviteLink = None,
via_chat_folder_invite_link: bool = None,
invite_link: Optional[ChatInviteLink] = None,
via_chat_folder_invite_link: Optional[bool] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
# Required

View file

@ -166,23 +166,23 @@ class ChatPermissions(TelegramObject):
def __init__(
self,
can_send_messages: bool = None,
can_send_media_messages: bool = None,
can_send_polls: bool = None,
can_send_other_messages: bool = None,
can_add_web_page_previews: bool = None,
can_change_info: bool = None,
can_invite_users: bool = None,
can_pin_messages: bool = None,
can_manage_topics: bool = None,
can_send_audios: bool = None,
can_send_documents: bool = None,
can_send_photos: bool = None,
can_send_videos: bool = None,
can_send_video_notes: bool = None,
can_send_voice_notes: bool = None,
can_send_messages: Optional[bool] = None,
can_send_media_messages: Optional[bool] = None,
can_send_polls: Optional[bool] = None,
can_send_other_messages: Optional[bool] = None,
can_add_web_page_previews: Optional[bool] = None,
can_change_info: Optional[bool] = None,
can_invite_users: Optional[bool] = None,
can_pin_messages: Optional[bool] = None,
can_manage_topics: Optional[bool] = None,
can_send_audios: Optional[bool] = None,
can_send_documents: Optional[bool] = None,
can_send_photos: Optional[bool] = None,
can_send_videos: Optional[bool] = None,
can_send_video_notes: Optional[bool] = None,
can_send_voice_notes: Optional[bool] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
# Required

View file

@ -72,10 +72,10 @@ class ChosenInlineResult(TelegramObject):
result_id: str,
from_user: User,
query: str,
location: Location = None,
inline_message_id: str = None,
location: Optional[Location] = None,
inline_message_id: Optional[str] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)

View file

@ -17,7 +17,7 @@
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram Dice."""
from typing import ClassVar, List
from typing import ClassVar, List, Optional
from telegram import constants
from telegram._telegramobject import TelegramObject
@ -89,7 +89,7 @@ class Dice(TelegramObject):
__slots__ = ("emoji", "value")
def __init__(self, value: int, emoji: str, *, api_kwargs: JSONDict = None):
def __init__(self, value: int, emoji: str, *, api_kwargs: Optional[JSONDict] = None):
super().__init__(api_kwargs=api_kwargs)
self.value: int = value
self.emoji: str = emoji

View file

@ -56,9 +56,9 @@ class _BaseMedium(TelegramObject):
self,
file_id: str,
file_unique_id: str,
file_size: int = None,
file_size: Optional[int] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
@ -77,7 +77,7 @@ class _BaseMedium(TelegramObject):
write_timeout: ODVInput[float] = DEFAULT_NONE,
connect_timeout: ODVInput[float] = DEFAULT_NONE,
pool_timeout: ODVInput[float] = DEFAULT_NONE,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
) -> "File":
"""Convenience wrapper over :meth:`telegram.Bot.get_file`

View file

@ -74,11 +74,11 @@ class _BaseThumbedMedium(_BaseMedium):
self,
file_id: str,
file_unique_id: str,
file_size: int = None,
thumb: PhotoSize = None,
thumbnail: PhotoSize = None,
file_size: Optional[int] = None,
thumb: Optional[PhotoSize] = None,
thumbnail: Optional[PhotoSize] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(
file_id=file_id,

View file

@ -79,13 +79,13 @@ class Animation(_BaseThumbedMedium):
width: int,
height: int,
duration: int,
thumb: PhotoSize = None,
file_name: str = None,
mime_type: str = None,
file_size: int = None,
thumbnail: PhotoSize = None,
thumb: Optional[PhotoSize] = None,
file_name: Optional[str] = None,
mime_type: Optional[str] = None,
file_size: Optional[int] = None,
thumbnail: Optional[PhotoSize] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(
file_id=file_id,

View file

@ -80,15 +80,15 @@ class Audio(_BaseThumbedMedium):
file_id: str,
file_unique_id: str,
duration: int,
performer: str = None,
title: str = None,
mime_type: str = None,
file_size: int = None,
thumb: PhotoSize = None,
file_name: str = None,
thumbnail: PhotoSize = None,
performer: Optional[str] = None,
title: Optional[str] = None,
mime_type: Optional[str] = None,
file_size: Optional[int] = None,
thumb: Optional[PhotoSize] = None,
file_name: Optional[str] = None,
thumbnail: Optional[PhotoSize] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(
file_id=file_id,

View file

@ -17,7 +17,7 @@
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram ChatPhoto."""
from typing import TYPE_CHECKING, ClassVar
from typing import TYPE_CHECKING, ClassVar, Optional
from telegram import constants
from telegram._telegramobject import TelegramObject
@ -87,7 +87,7 @@ class ChatPhoto(TelegramObject):
big_file_id: str,
big_file_unique_id: str,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
self.small_file_id: str = small_file_id
@ -109,7 +109,7 @@ class ChatPhoto(TelegramObject):
write_timeout: ODVInput[float] = DEFAULT_NONE,
connect_timeout: ODVInput[float] = DEFAULT_NONE,
pool_timeout: ODVInput[float] = DEFAULT_NONE,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
) -> "File":
"""Convenience wrapper over :meth:`telegram.Bot.get_file` for getting the small
(:tg-const:`telegram.ChatPhoto.SIZE_SMALL` x :tg-const:`telegram.ChatPhoto.SIZE_SMALL`)
@ -140,7 +140,7 @@ class ChatPhoto(TelegramObject):
write_timeout: ODVInput[float] = DEFAULT_NONE,
connect_timeout: ODVInput[float] = DEFAULT_NONE,
pool_timeout: ODVInput[float] = DEFAULT_NONE,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
) -> "File":
"""Convenience wrapper over :meth:`telegram.Bot.get_file` for getting the
big (:tg-const:`telegram.ChatPhoto.SIZE_BIG` x :tg-const:`telegram.ChatPhoto.SIZE_BIG`)

View file

@ -51,11 +51,11 @@ class Contact(TelegramObject):
self,
phone_number: str,
first_name: str,
last_name: str = None,
user_id: int = None,
vcard: str = None,
last_name: Optional[str] = None,
user_id: Optional[int] = None,
vcard: Optional[str] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
# Required

View file

@ -67,13 +67,13 @@ class Document(_BaseThumbedMedium):
self,
file_id: str,
file_unique_id: str,
thumb: PhotoSize = None,
file_name: str = None,
mime_type: str = None,
file_size: int = None,
thumbnail: PhotoSize = None,
thumb: Optional[PhotoSize] = None,
file_name: Optional[str] = None,
mime_type: Optional[str] = None,
file_size: Optional[int] = None,
thumbnail: Optional[PhotoSize] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(
file_id=file_id,

View file

@ -85,10 +85,10 @@ class File(TelegramObject):
self,
file_id: str,
file_unique_id: str,
file_size: int = None,
file_path: str = None,
file_size: Optional[int] = None,
file_path: Optional[str] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
@ -119,7 +119,7 @@ class File(TelegramObject):
async def download_to_drive(
self,
custom_path: FilePathInput = None,
custom_path: Optional[FilePathInput] = None,
*,
read_timeout: ODVInput[float] = DEFAULT_NONE,
write_timeout: ODVInput[float] = DEFAULT_NONE,
@ -270,7 +270,7 @@ class File(TelegramObject):
async def download_as_bytearray(
self,
buf: bytearray = None,
buf: Optional[bytearray] = None,
*,
read_timeout: ODVInput[float] = DEFAULT_NONE,
write_timeout: ODVInput[float] = DEFAULT_NONE,

View file

@ -66,7 +66,10 @@ class InputFile:
__slots__ = ("filename", "attach_name", "input_file_content", "mimetype")
def __init__(
self, obj: Union[IO[bytes], bytes, str], filename: str = None, attach: bool = False
self,
obj: Union[IO[bytes], bytes, str],
filename: Optional[str] = None,
attach: bool = False,
):
if isinstance(obj, bytes):
self.input_file_content: bytes = obj

View file

@ -91,11 +91,11 @@ class InputMedia(TelegramObject):
self,
media_type: str,
media: Union[str, InputFile, MediaType],
caption: str = None,
caption_entities: Sequence[MessageEntity] = None,
caption: Optional[str] = None,
caption_entities: Optional[Sequence[MessageEntity]] = None,
parse_mode: ODVInput[str] = DEFAULT_NONE,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
self.type: str = media_type
@ -196,18 +196,18 @@ class InputMediaAnimation(InputMedia):
def __init__(
self,
media: Union[FileInput, Animation],
thumb: FileInput = None,
caption: str = None,
thumb: Optional[FileInput] = None,
caption: Optional[str] = None,
parse_mode: ODVInput[str] = DEFAULT_NONE,
width: int = None,
height: int = None,
duration: int = None,
caption_entities: Sequence[MessageEntity] = None,
filename: str = None,
has_spoiler: bool = None,
thumbnail: FileInput = None,
width: Optional[int] = None,
height: Optional[int] = None,
duration: Optional[int] = None,
caption_entities: Optional[Sequence[MessageEntity]] = None,
filename: Optional[str] = None,
has_spoiler: Optional[bool] = None,
thumbnail: Optional[FileInput] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
if isinstance(media, Animation):
width = media.width if width is None else width
@ -304,13 +304,13 @@ class InputMediaPhoto(InputMedia):
def __init__(
self,
media: Union[FileInput, PhotoSize],
caption: str = None,
caption: Optional[str] = None,
parse_mode: ODVInput[str] = DEFAULT_NONE,
caption_entities: Sequence[MessageEntity] = None,
filename: str = None,
has_spoiler: bool = None,
caption_entities: Optional[Sequence[MessageEntity]] = None,
filename: Optional[str] = None,
has_spoiler: Optional[bool] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
# We use local_mode=True because we don't have access to the actual setting and want
# things to work in local mode.
@ -423,19 +423,19 @@ class InputMediaVideo(InputMedia):
def __init__(
self,
media: Union[FileInput, Video],
caption: str = None,
width: int = None,
height: int = None,
duration: int = None,
supports_streaming: bool = None,
caption: Optional[str] = None,
width: Optional[int] = None,
height: Optional[int] = None,
duration: Optional[int] = None,
supports_streaming: Optional[bool] = None,
parse_mode: ODVInput[str] = DEFAULT_NONE,
thumb: FileInput = None,
caption_entities: Sequence[MessageEntity] = None,
filename: str = None,
has_spoiler: bool = None,
thumbnail: FileInput = None,
thumb: Optional[FileInput] = None,
caption_entities: Optional[Sequence[MessageEntity]] = None,
filename: Optional[str] = None,
has_spoiler: Optional[bool] = None,
thumbnail: Optional[FileInput] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
if isinstance(media, Video):
width = width if width is not None else media.width
@ -555,17 +555,17 @@ class InputMediaAudio(InputMedia):
def __init__(
self,
media: Union[FileInput, Audio],
thumb: FileInput = None,
caption: str = None,
thumb: Optional[FileInput] = None,
caption: Optional[str] = None,
parse_mode: ODVInput[str] = DEFAULT_NONE,
duration: int = None,
performer: str = None,
title: str = None,
caption_entities: Sequence[MessageEntity] = None,
filename: str = None,
thumbnail: FileInput = None,
duration: Optional[int] = None,
performer: Optional[str] = None,
title: Optional[str] = None,
caption_entities: Optional[Sequence[MessageEntity]] = None,
filename: Optional[str] = None,
thumbnail: Optional[FileInput] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
if isinstance(media, Audio):
duration = media.duration if duration is None else duration
@ -675,15 +675,15 @@ class InputMediaDocument(InputMedia):
def __init__(
self,
media: Union[FileInput, Document],
thumb: FileInput = None,
caption: str = None,
thumb: Optional[FileInput] = None,
caption: Optional[str] = None,
parse_mode: ODVInput[str] = DEFAULT_NONE,
disable_content_type_detection: bool = None,
caption_entities: Sequence[MessageEntity] = None,
filename: str = None,
thumbnail: FileInput = None,
disable_content_type_detection: Optional[bool] = None,
caption_entities: Optional[Sequence[MessageEntity]] = None,
filename: Optional[str] = None,
thumbnail: Optional[FileInput] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
# We use local_mode=True because we don't have access to the actual setting and want
# things to work in local mode.

View file

@ -74,10 +74,10 @@ class InputSticker(TelegramObject):
self,
sticker: FileInput,
emoji_list: Sequence[str],
mask_position: MaskPosition = None,
keywords: Sequence[str] = None,
mask_position: Optional[MaskPosition] = None,
keywords: Optional[Sequence[str]] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)

View file

@ -72,12 +72,12 @@ class Location(TelegramObject):
self,
longitude: float,
latitude: float,
horizontal_accuracy: float = None,
live_period: int = None,
heading: int = None,
proximity_alert_radius: int = None,
horizontal_accuracy: Optional[float] = None,
live_period: Optional[int] = None,
heading: Optional[int] = None,
proximity_alert_radius: Optional[int] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
# Required

View file

@ -18,6 +18,8 @@
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram PhotoSize."""
from typing import Optional
from telegram._files._basemedium import _BaseMedium
from telegram._utils.types import JSONDict
@ -59,9 +61,9 @@ class PhotoSize(_BaseMedium):
file_unique_id: str,
width: int,
height: int,
file_size: int = None,
file_size: Optional[int] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(
file_id=file_id,

View file

@ -157,17 +157,17 @@ class Sticker(_BaseThumbedMedium):
is_animated: bool,
is_video: bool,
type: str, # pylint: disable=redefined-builtin
thumb: PhotoSize = None,
emoji: str = None,
file_size: int = None,
set_name: str = None,
mask_position: "MaskPosition" = None,
premium_animation: "File" = None,
custom_emoji_id: str = None,
thumbnail: PhotoSize = None,
needs_repainting: bool = None,
thumb: Optional[PhotoSize] = None,
emoji: Optional[str] = None,
file_size: Optional[int] = None,
set_name: Optional[str] = None,
mask_position: Optional["MaskPosition"] = None,
premium_animation: Optional["File"] = None,
custom_emoji_id: Optional[str] = None,
thumbnail: Optional[PhotoSize] = None,
needs_repainting: Optional[bool] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(
file_id=file_id,
@ -302,10 +302,10 @@ class StickerSet(TelegramObject):
stickers: Sequence[Sticker],
is_video: bool,
sticker_type: str,
thumb: PhotoSize = None,
thumbnail: PhotoSize = None,
thumb: Optional[PhotoSize] = None,
thumbnail: Optional[PhotoSize] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
self.name: str = name
@ -406,7 +406,7 @@ class MaskPosition(TelegramObject):
y_shift: float,
scale: float,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
self.point: str = point

View file

@ -79,12 +79,12 @@ class Venue(TelegramObject):
location: Location,
title: str,
address: str,
foursquare_id: str = None,
foursquare_type: str = None,
google_place_id: str = None,
google_place_type: str = None,
foursquare_id: Optional[str] = None,
foursquare_type: Optional[str] = None,
google_place_id: Optional[str] = None,
google_place_type: Optional[str] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)

View file

@ -76,13 +76,13 @@ class Video(_BaseThumbedMedium):
width: int,
height: int,
duration: int,
thumb: PhotoSize = None,
mime_type: str = None,
file_size: int = None,
file_name: str = None,
thumbnail: PhotoSize = None,
thumb: Optional[PhotoSize] = None,
mime_type: Optional[str] = None,
file_size: Optional[int] = None,
file_name: Optional[str] = None,
thumbnail: Optional[PhotoSize] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(
file_id=file_id,

View file

@ -18,6 +18,8 @@
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram VideoNote."""
from typing import Optional
from telegram._files._basethumbedmedium import _BaseThumbedMedium
from telegram._files.photosize import PhotoSize
from telegram._utils.types import JSONDict
@ -71,11 +73,11 @@ class VideoNote(_BaseThumbedMedium):
file_unique_id: str,
length: int,
duration: int,
thumb: PhotoSize = None,
file_size: int = None,
thumbnail: PhotoSize = None,
thumb: Optional[PhotoSize] = None,
file_size: Optional[int] = None,
thumbnail: Optional[PhotoSize] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(
file_id=file_id,

View file

@ -58,10 +58,10 @@ class Voice(_BaseMedium):
file_id: str,
file_unique_id: str,
duration: int,
mime_type: str = None,
file_size: int = None,
mime_type: Optional[str] = None,
file_size: Optional[int] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(
file_id=file_id,

View file

@ -79,10 +79,10 @@ class ForceReply(TelegramObject):
def __init__(
self,
selective: bool = None,
input_field_placeholder: str = None,
selective: Optional[bool] = None,
input_field_placeholder: Optional[str] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
self.force_reply: bool = True

View file

@ -55,9 +55,9 @@ class ForumTopic(TelegramObject):
message_thread_id: int,
name: str,
icon_color: int,
icon_custom_emoji_id: str = None,
icon_custom_emoji_id: Optional[str] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
self.message_thread_id: int = message_thread_id
@ -99,9 +99,9 @@ class ForumTopicCreated(TelegramObject):
self,
name: str,
icon_color: int,
icon_custom_emoji_id: str = None,
icon_custom_emoji_id: Optional[str] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
self.name: str = name
@ -123,7 +123,7 @@ class ForumTopicClosed(TelegramObject):
__slots__ = ()
def __init__(self, *, api_kwargs: JSONDict = None) -> None:
def __init__(self, *, api_kwargs: Optional[JSONDict] = None) -> None:
super().__init__(api_kwargs=api_kwargs)
self._freeze()
@ -139,7 +139,7 @@ class ForumTopicReopened(TelegramObject):
__slots__ = ()
def __init__(self, *, api_kwargs: JSONDict = None) -> None:
def __init__(self, *, api_kwargs: Optional[JSONDict] = None) -> None:
super().__init__(api_kwargs=api_kwargs)
self._freeze()
@ -169,10 +169,10 @@ class ForumTopicEdited(TelegramObject):
def __init__(
self,
name: str = None,
icon_custom_emoji_id: str = None,
name: Optional[str] = None,
icon_custom_emoji_id: Optional[str] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
self.name: Optional[str] = name
@ -193,7 +193,7 @@ class GeneralForumTopicHidden(TelegramObject):
__slots__ = ()
def __init__(self, *, api_kwargs: JSONDict = None):
def __init__(self, *, api_kwargs: Optional[JSONDict] = None):
super().__init__(api_kwargs=api_kwargs)
self._freeze()
@ -209,7 +209,7 @@ class GeneralForumTopicUnhidden(TelegramObject):
__slots__ = ()
def __init__(self, *, api_kwargs: JSONDict = None):
def __init__(self, *, api_kwargs: Optional[JSONDict] = None):
super().__init__(api_kwargs=api_kwargs)
self._freeze()

View file

@ -18,6 +18,8 @@
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram CallbackGame."""
from typing import Optional
from telegram._telegramobject import TelegramObject
from telegram._utils.types import JSONDict
@ -27,7 +29,7 @@ class CallbackGame(TelegramObject):
__slots__ = ()
def __init__(self, *, api_kwargs: JSONDict = None) -> None:
def __init__(self, *, api_kwargs: Optional[JSONDict] = None) -> None:
super().__init__(api_kwargs=api_kwargs)
self._freeze()

View file

@ -101,11 +101,11 @@ class Game(TelegramObject):
title: str,
description: str,
photo: Sequence[PhotoSize],
text: str = None,
text_entities: Sequence[MessageEntity] = None,
animation: Animation = None,
text: Optional[str] = None,
text_entities: Optional[Sequence[MessageEntity]] = None,
animation: Optional[Animation] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
# Required
@ -162,7 +162,7 @@ class Game(TelegramObject):
return entity_text.decode("utf-16-le")
def parse_text_entities(self, types: List[str] = None) -> Dict[MessageEntity, str]:
def parse_text_entities(self, types: Optional[List[str]] = None) -> Dict[MessageEntity, str]:
"""
Returns a :obj:`dict` that maps :class:`telegram.MessageEntity` to :obj:`str`.
It contains entities from this message filtered by their

View file

@ -48,7 +48,9 @@ class GameHighScore(TelegramObject):
__slots__ = ("position", "user", "score")
def __init__(self, position: int, user: User, score: int, *, api_kwargs: JSONDict = None):
def __init__(
self, position: int, user: User, score: int, *, api_kwargs: Optional[JSONDict] = None
):
super().__init__(api_kwargs=api_kwargs)
self.position: int = position
self.user: User = user

View file

@ -220,17 +220,17 @@ class InlineKeyboardButton(TelegramObject):
def __init__(
self,
text: str,
url: str = None,
callback_data: Union[str, object] = None,
switch_inline_query: str = None,
switch_inline_query_current_chat: str = None,
callback_game: CallbackGame = None,
pay: bool = None,
login_url: LoginUrl = None,
web_app: WebAppInfo = None,
switch_inline_query_chosen_chat: SwitchInlineQueryChosenChat = None,
url: Optional[str] = None,
callback_data: Optional[Union[str, object]] = None,
switch_inline_query: Optional[str] = None,
switch_inline_query_current_chat: Optional[str] = None,
callback_game: Optional[CallbackGame] = None,
pay: Optional[bool] = None,
login_url: Optional[LoginUrl] = None,
web_app: Optional[WebAppInfo] = None,
switch_inline_query_chosen_chat: Optional[SwitchInlineQueryChosenChat] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
# Required

View file

@ -72,7 +72,7 @@ class InlineKeyboardMarkup(TelegramObject):
self,
inline_keyboard: Sequence[Sequence[InlineKeyboardButton]],
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
if not check_keyboard_type(inline_keyboard):

View file

@ -104,10 +104,10 @@ class InlineQuery(TelegramObject):
from_user: User,
query: str,
offset: str,
location: Location = None,
chat_type: str = None,
location: Optional[Location] = None,
chat_type: Optional[str] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
# Required
@ -142,20 +142,20 @@ class InlineQuery(TelegramObject):
results: Union[
Sequence["InlineQueryResult"], Callable[[int], Optional[Sequence["InlineQueryResult"]]]
],
cache_time: int = None,
is_personal: bool = None,
next_offset: str = None,
switch_pm_text: str = None,
switch_pm_parameter: str = None,
button: InlineQueryResultsButton = None,
cache_time: Optional[int] = None,
is_personal: Optional[bool] = None,
next_offset: Optional[str] = None,
switch_pm_text: Optional[str] = None,
switch_pm_parameter: Optional[str] = None,
button: Optional[InlineQueryResultsButton] = None,
*,
current_offset: str = None,
current_offset: Optional[str] = None,
auto_pagination: bool = False,
read_timeout: ODVInput[float] = DEFAULT_NONE,
write_timeout: ODVInput[float] = DEFAULT_NONE,
connect_timeout: ODVInput[float] = DEFAULT_NONE,
pool_timeout: ODVInput[float] = DEFAULT_NONE,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
) -> bool:
"""Shortcut for::

View file

@ -19,7 +19,7 @@
# pylint: disable=redefined-builtin
"""This module contains the classes that represent Telegram InlineQueryResult."""
from typing import ClassVar
from typing import ClassVar, Optional
from telegram import constants
from telegram._telegramobject import TelegramObject
@ -55,7 +55,7 @@ class InlineQueryResult(TelegramObject):
__slots__ = ("type", "id")
def __init__(self, type: str, id: str, *, api_kwargs: JSONDict = None):
def __init__(self, type: str, id: str, *, api_kwargs: Optional[JSONDict] = None):
super().__init__(api_kwargs=api_kwargs)
# Required

View file

@ -117,18 +117,18 @@ class InlineQueryResultArticle(InlineQueryResult):
id: str, # pylint: disable=redefined-builtin
title: str,
input_message_content: "InputMessageContent",
reply_markup: InlineKeyboardMarkup = None,
url: str = None,
hide_url: bool = None,
description: str = None,
thumb_url: str = None,
thumb_width: int = None,
thumb_height: int = None,
thumbnail_url: str = None,
thumbnail_width: int = None,
thumbnail_height: int = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
url: Optional[str] = None,
hide_url: Optional[bool] = None,
description: Optional[str] = None,
thumb_url: Optional[str] = None,
thumb_width: Optional[int] = None,
thumb_height: Optional[int] = None,
thumbnail_url: Optional[str] = None,
thumbnail_width: Optional[int] = None,
thumbnail_height: Optional[int] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
# Required
super().__init__(InlineQueryResultType.ARTICLE, id, api_kwargs=api_kwargs)

View file

@ -103,15 +103,15 @@ class InlineQueryResultAudio(InlineQueryResult):
id: str, # pylint: disable=redefined-builtin
audio_url: str,
title: str,
performer: str = None,
audio_duration: int = None,
caption: str = None,
reply_markup: InlineKeyboardMarkup = None,
input_message_content: "InputMessageContent" = None,
performer: Optional[str] = None,
audio_duration: Optional[int] = None,
caption: Optional[str] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
input_message_content: Optional["InputMessageContent"] = None,
parse_mode: ODVInput[str] = DEFAULT_NONE,
caption_entities: Sequence[MessageEntity] = None,
caption_entities: Optional[Sequence[MessageEntity]] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
# Required
super().__init__(InlineQueryResultType.AUDIO, id, api_kwargs=api_kwargs)

View file

@ -94,13 +94,13 @@ class InlineQueryResultCachedAudio(InlineQueryResult):
self,
id: str, # pylint: disable=redefined-builtin
audio_file_id: str,
caption: str = None,
reply_markup: InlineKeyboardMarkup = None,
input_message_content: "InputMessageContent" = None,
caption: Optional[str] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
input_message_content: Optional["InputMessageContent"] = None,
parse_mode: ODVInput[str] = DEFAULT_NONE,
caption_entities: Sequence[MessageEntity] = None,
caption_entities: Optional[Sequence[MessageEntity]] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
# Required
super().__init__(InlineQueryResultType.AUDIO, id, api_kwargs=api_kwargs)

View file

@ -101,14 +101,14 @@ class InlineQueryResultCachedDocument(InlineQueryResult):
id: str, # pylint: disable=redefined-builtin
title: str,
document_file_id: str,
description: str = None,
caption: str = None,
reply_markup: InlineKeyboardMarkup = None,
input_message_content: "InputMessageContent" = None,
description: Optional[str] = None,
caption: Optional[str] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
input_message_content: Optional["InputMessageContent"] = None,
parse_mode: ODVInput[str] = DEFAULT_NONE,
caption_entities: Sequence[MessageEntity] = None,
caption_entities: Optional[Sequence[MessageEntity]] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
# Required
super().__init__(InlineQueryResultType.DOCUMENT, id, api_kwargs=api_kwargs)

View file

@ -98,14 +98,14 @@ class InlineQueryResultCachedGif(InlineQueryResult):
self,
id: str, # pylint: disable=redefined-builtin
gif_file_id: str,
title: str = None,
caption: str = None,
reply_markup: InlineKeyboardMarkup = None,
input_message_content: "InputMessageContent" = None,
title: Optional[str] = None,
caption: Optional[str] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
input_message_content: Optional["InputMessageContent"] = None,
parse_mode: ODVInput[str] = DEFAULT_NONE,
caption_entities: Sequence[MessageEntity] = None,
caption_entities: Optional[Sequence[MessageEntity]] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
# Required
super().__init__(InlineQueryResultType.GIF, id, api_kwargs=api_kwargs)

View file

@ -98,14 +98,14 @@ class InlineQueryResultCachedMpeg4Gif(InlineQueryResult):
self,
id: str, # pylint: disable=redefined-builtin
mpeg4_file_id: str,
title: str = None,
caption: str = None,
reply_markup: InlineKeyboardMarkup = None,
input_message_content: "InputMessageContent" = None,
title: Optional[str] = None,
caption: Optional[str] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
input_message_content: Optional["InputMessageContent"] = None,
parse_mode: ODVInput[str] = DEFAULT_NONE,
caption_entities: Sequence[MessageEntity] = None,
caption_entities: Optional[Sequence[MessageEntity]] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
# Required
super().__init__(InlineQueryResultType.MPEG4GIF, id, api_kwargs=api_kwargs)

View file

@ -101,15 +101,15 @@ class InlineQueryResultCachedPhoto(InlineQueryResult):
self,
id: str, # pylint: disable=redefined-builtin
photo_file_id: str,
title: str = None,
description: str = None,
caption: str = None,
reply_markup: InlineKeyboardMarkup = None,
input_message_content: "InputMessageContent" = None,
title: Optional[str] = None,
description: Optional[str] = None,
caption: Optional[str] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
input_message_content: Optional["InputMessageContent"] = None,
parse_mode: ODVInput[str] = DEFAULT_NONE,
caption_entities: Sequence[MessageEntity] = None,
caption_entities: Optional[Sequence[MessageEntity]] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
# Required
super().__init__(InlineQueryResultType.PHOTO, id, api_kwargs=api_kwargs)

View file

@ -66,10 +66,10 @@ class InlineQueryResultCachedSticker(InlineQueryResult):
self,
id: str, # pylint: disable=redefined-builtin
sticker_file_id: str,
reply_markup: InlineKeyboardMarkup = None,
input_message_content: "InputMessageContent" = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
input_message_content: Optional["InputMessageContent"] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
# Required
super().__init__(InlineQueryResultType.STICKER, id, api_kwargs=api_kwargs)

View file

@ -98,14 +98,14 @@ class InlineQueryResultCachedVideo(InlineQueryResult):
id: str, # pylint: disable=redefined-builtin
video_file_id: str,
title: str,
description: str = None,
caption: str = None,
reply_markup: InlineKeyboardMarkup = None,
input_message_content: "InputMessageContent" = None,
description: Optional[str] = None,
caption: Optional[str] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
input_message_content: Optional["InputMessageContent"] = None,
parse_mode: ODVInput[str] = DEFAULT_NONE,
caption_entities: Sequence[MessageEntity] = None,
caption_entities: Optional[Sequence[MessageEntity]] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
# Required
super().__init__(InlineQueryResultType.VIDEO, id, api_kwargs=api_kwargs)

View file

@ -98,13 +98,13 @@ class InlineQueryResultCachedVoice(InlineQueryResult):
id: str, # pylint: disable=redefined-builtin
voice_file_id: str,
title: str,
caption: str = None,
reply_markup: InlineKeyboardMarkup = None,
input_message_content: "InputMessageContent" = None,
caption: Optional[str] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
input_message_content: Optional["InputMessageContent"] = None,
parse_mode: ODVInput[str] = DEFAULT_NONE,
caption_entities: Sequence[MessageEntity] = None,
caption_entities: Optional[Sequence[MessageEntity]] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
# Required
super().__init__(InlineQueryResultType.VOICE, id, api_kwargs=api_kwargs)

View file

@ -117,18 +117,18 @@ class InlineQueryResultContact(InlineQueryResult):
id: str, # pylint: disable=redefined-builtin
phone_number: str,
first_name: str,
last_name: str = None,
reply_markup: InlineKeyboardMarkup = None,
input_message_content: "InputMessageContent" = None,
thumb_url: str = None,
thumb_width: int = None,
thumb_height: int = None,
vcard: str = None,
thumbnail_url: str = None,
thumbnail_width: int = None,
thumbnail_height: int = None,
last_name: Optional[str] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
input_message_content: Optional["InputMessageContent"] = None,
thumb_url: Optional[str] = None,
thumb_width: Optional[int] = None,
thumb_height: Optional[int] = None,
vcard: Optional[str] = None,
thumbnail_url: Optional[str] = None,
thumbnail_width: Optional[int] = None,
thumbnail_height: Optional[int] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
# Required
super().__init__(InlineQueryResultType.CONTACT, id, api_kwargs=api_kwargs)

View file

@ -146,20 +146,20 @@ class InlineQueryResultDocument(InlineQueryResult):
document_url: str,
title: str,
mime_type: str,
caption: str = None,
description: str = None,
reply_markup: InlineKeyboardMarkup = None,
input_message_content: "InputMessageContent" = None,
thumb_url: str = None,
thumb_width: int = None,
thumb_height: int = None,
caption: Optional[str] = None,
description: Optional[str] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
input_message_content: Optional["InputMessageContent"] = None,
thumb_url: Optional[str] = None,
thumb_width: Optional[int] = None,
thumb_height: Optional[int] = None,
parse_mode: ODVInput[str] = DEFAULT_NONE,
caption_entities: Sequence[MessageEntity] = None,
thumbnail_url: str = None,
thumbnail_width: int = None,
thumbnail_height: int = None,
caption_entities: Optional[Sequence[MessageEntity]] = None,
thumbnail_url: Optional[str] = None,
thumbnail_width: Optional[int] = None,
thumbnail_height: Optional[int] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
# Required
super().__init__(InlineQueryResultType.DOCUMENT, id, api_kwargs=api_kwargs)

View file

@ -53,9 +53,9 @@ class InlineQueryResultGame(InlineQueryResult):
self,
id: str, # pylint: disable=redefined-builtin
game_short_name: str,
reply_markup: InlineKeyboardMarkup = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
# Required
super().__init__(InlineQueryResultType.GAME, id, api_kwargs=api_kwargs)

View file

@ -151,22 +151,22 @@ class InlineQueryResultGif(InlineQueryResult):
# thumbnail_url is not optional in Telegram API, but we want to support thumb_url as well,
# so thumbnail_url may not be passed. We will raise ValueError manually if neither
# thumbnail_url nor thumb_url are passed
thumbnail_url: str = None,
gif_width: int = None,
gif_height: int = None,
title: str = None,
caption: str = None,
reply_markup: InlineKeyboardMarkup = None,
input_message_content: "InputMessageContent" = None,
gif_duration: int = None,
thumbnail_url: Optional[str] = None,
gif_width: Optional[int] = None,
gif_height: Optional[int] = None,
title: Optional[str] = None,
caption: Optional[str] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
input_message_content: Optional["InputMessageContent"] = None,
gif_duration: Optional[int] = None,
parse_mode: ODVInput[str] = DEFAULT_NONE,
thumb_mime_type: str = None,
caption_entities: Sequence[MessageEntity] = None,
thumbnail_mime_type: str = None,
thumb_mime_type: Optional[str] = None,
caption_entities: Optional[Sequence[MessageEntity]] = None,
thumbnail_mime_type: Optional[str] = None,
# thumb_url is not optional in Telegram API, but it is here, along with thumbnail_url.
thumb_url: str = None,
thumb_url: Optional[str] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
if not (thumbnail_url or thumb_url):
raise ValueError(

View file

@ -149,20 +149,20 @@ class InlineQueryResultLocation(InlineQueryResult):
latitude: float,
longitude: float,
title: str,
live_period: int = None,
reply_markup: InlineKeyboardMarkup = None,
input_message_content: "InputMessageContent" = None,
thumb_url: str = None,
thumb_width: int = None,
thumb_height: int = None,
horizontal_accuracy: float = None,
heading: int = None,
proximity_alert_radius: int = None,
thumbnail_url: str = None,
thumbnail_width: int = None,
thumbnail_height: int = None,
live_period: Optional[int] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
input_message_content: Optional["InputMessageContent"] = None,
thumb_url: Optional[str] = None,
thumb_width: Optional[int] = None,
thumb_height: Optional[int] = None,
horizontal_accuracy: Optional[float] = None,
heading: Optional[int] = None,
proximity_alert_radius: Optional[int] = None,
thumbnail_url: Optional[str] = None,
thumbnail_width: Optional[int] = None,
thumbnail_height: Optional[int] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
# Required
super().__init__(constants.InlineQueryResultType.LOCATION, id, api_kwargs=api_kwargs)

View file

@ -144,22 +144,22 @@ class InlineQueryResultMpeg4Gif(InlineQueryResult):
# thumbnail_url is not optional in Telegram API, but we want to support thumb_url as well,
# so thumbnail_url may not be passed. We will raise ValueError manually if neither
# thumbnail_url nor thumb_url are passed
thumbnail_url: str = None,
mpeg4_width: int = None,
mpeg4_height: int = None,
title: str = None,
caption: str = None,
reply_markup: InlineKeyboardMarkup = None,
input_message_content: "InputMessageContent" = None,
mpeg4_duration: int = None,
thumbnail_url: Optional[str] = None,
mpeg4_width: Optional[int] = None,
mpeg4_height: Optional[int] = None,
title: Optional[str] = None,
caption: Optional[str] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
input_message_content: Optional["InputMessageContent"] = None,
mpeg4_duration: Optional[int] = None,
parse_mode: ODVInput[str] = DEFAULT_NONE,
thumb_mime_type: str = None,
caption_entities: Sequence[MessageEntity] = None,
thumbnail_mime_type: str = None,
thumb_mime_type: Optional[str] = None,
caption_entities: Optional[Sequence[MessageEntity]] = None,
thumbnail_mime_type: Optional[str] = None,
# thumb_url is not optional in Telegram API, but it is here, along with thumbnail_url.
thumb_url: str = None,
thumb_url: Optional[str] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
if not (thumbnail_url or thumb_url):
raise ValueError(

View file

@ -134,20 +134,20 @@ class InlineQueryResultPhoto(InlineQueryResult):
# thumbnail_url is not optional in Telegram API, but we want to support thumb_url as well,
# so thumbnail_url may not be passed. We will raise ValueError manually if neither
# thumbnail_url nor thumb_url are passed
thumbnail_url: str = None,
photo_width: int = None,
photo_height: int = None,
title: str = None,
description: str = None,
caption: str = None,
reply_markup: InlineKeyboardMarkup = None,
input_message_content: "InputMessageContent" = None,
thumbnail_url: Optional[str] = None,
photo_width: Optional[int] = None,
photo_height: Optional[int] = None,
title: Optional[str] = None,
description: Optional[str] = None,
caption: Optional[str] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
input_message_content: Optional["InputMessageContent"] = None,
parse_mode: ODVInput[str] = DEFAULT_NONE,
caption_entities: Sequence[MessageEntity] = None,
caption_entities: Optional[Sequence[MessageEntity]] = None,
# thumb_url is not optional in Telegram API, but it is here, along with thumbnail_url.
thumb_url: str = None,
thumb_url: Optional[str] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
if not (thumbnail_url or thumb_url):
raise ValueError(

View file

@ -79,10 +79,10 @@ class InlineQueryResultsButton(TelegramObject):
def __init__(
self,
text: str,
web_app: WebAppInfo = None,
start_parameter: str = None,
web_app: Optional[WebAppInfo] = None,
start_parameter: Optional[str] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)

View file

@ -141,20 +141,20 @@ class InlineQueryResultVenue(InlineQueryResult):
longitude: float,
title: str,
address: str,
foursquare_id: str = None,
foursquare_type: str = None,
reply_markup: InlineKeyboardMarkup = None,
input_message_content: "InputMessageContent" = None,
thumb_url: str = None,
thumb_width: int = None,
thumb_height: int = None,
google_place_id: str = None,
google_place_type: str = None,
thumbnail_url: str = None,
thumbnail_width: int = None,
thumbnail_height: int = None,
foursquare_id: Optional[str] = None,
foursquare_type: Optional[str] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
input_message_content: Optional["InputMessageContent"] = None,
thumb_url: Optional[str] = None,
thumb_width: Optional[int] = None,
thumb_height: Optional[int] = None,
google_place_id: Optional[str] = None,
google_place_type: Optional[str] = None,
thumbnail_url: Optional[str] = None,
thumbnail_width: Optional[int] = None,
thumbnail_height: Optional[int] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
# Required
super().__init__(InlineQueryResultType.VENUE, id, api_kwargs=api_kwargs)

View file

@ -159,23 +159,23 @@ class InlineQueryResultVideo(InlineQueryResult):
# thumbnail_url and title are not optional in Telegram API, but we want to support
# thumb_url as well, so thumbnail_url may not be passed if thumb_url is passed.
# We will raise ValueError manually if neither thumbnail_url nor thumb_url are passed.
thumbnail_url: str = None,
thumbnail_url: Optional[str] = None,
# title had to be made optional because of thumbnail_url. This is compensated by raising
# TypeError manually if title is not passed.
title: str = None,
caption: str = None,
video_width: int = None,
video_height: int = None,
video_duration: int = None,
description: str = None,
reply_markup: InlineKeyboardMarkup = None,
input_message_content: "InputMessageContent" = None,
title: Optional[str] = None,
caption: Optional[str] = None,
video_width: Optional[int] = None,
video_height: Optional[int] = None,
video_duration: Optional[int] = None,
description: Optional[str] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
input_message_content: Optional["InputMessageContent"] = None,
parse_mode: ODVInput[str] = DEFAULT_NONE,
caption_entities: Sequence[MessageEntity] = None,
caption_entities: Optional[Sequence[MessageEntity]] = None,
# thumb_url is not optional in Telegram API, but it is here, along with thumbnail_url.
thumb_url: str = None,
thumb_url: Optional[str] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
if not (thumbnail_url or thumb_url):
raise ValueError(

View file

@ -102,14 +102,14 @@ class InlineQueryResultVoice(InlineQueryResult):
id: str, # pylint: disable=redefined-builtin
voice_url: str,
title: str,
voice_duration: int = None,
caption: str = None,
reply_markup: InlineKeyboardMarkup = None,
input_message_content: "InputMessageContent" = None,
voice_duration: Optional[int] = None,
caption: Optional[str] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
input_message_content: Optional["InputMessageContent"] = None,
parse_mode: ODVInput[str] = DEFAULT_NONE,
caption_entities: Sequence[MessageEntity] = None,
caption_entities: Optional[Sequence[MessageEntity]] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
# Required
super().__init__(InlineQueryResultType.VOICE, id, api_kwargs=api_kwargs)

View file

@ -51,10 +51,10 @@ class InputContactMessageContent(InputMessageContent):
self,
phone_number: str,
first_name: str,
last_name: str = None,
vcard: str = None,
last_name: Optional[str] = None,
vcard: Optional[str] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
with self._unfrozen():

View file

@ -193,22 +193,22 @@ class InputInvoiceMessageContent(InputMessageContent):
provider_token: str,
currency: str,
prices: Sequence[LabeledPrice],
max_tip_amount: int = None,
suggested_tip_amounts: Sequence[int] = None,
provider_data: str = None,
photo_url: str = None,
photo_size: int = None,
photo_width: int = None,
photo_height: int = None,
need_name: bool = None,
need_phone_number: bool = None,
need_email: bool = None,
need_shipping_address: bool = None,
send_phone_number_to_provider: bool = None,
send_email_to_provider: bool = None,
is_flexible: bool = None,
max_tip_amount: Optional[int] = None,
suggested_tip_amounts: Optional[Sequence[int]] = None,
provider_data: Optional[str] = None,
photo_url: Optional[str] = None,
photo_size: Optional[int] = None,
photo_width: Optional[int] = None,
photo_height: Optional[int] = None,
need_name: Optional[bool] = None,
need_phone_number: Optional[bool] = None,
need_email: Optional[bool] = None,
need_shipping_address: Optional[bool] = None,
send_phone_number_to_provider: Optional[bool] = None,
send_email_to_provider: Optional[bool] = None,
is_flexible: Optional[bool] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
with self._unfrozen():

View file

@ -83,12 +83,12 @@ class InputLocationMessageContent(InputMessageContent):
self,
latitude: float,
longitude: float,
live_period: int = None,
horizontal_accuracy: float = None,
heading: int = None,
proximity_alert_radius: int = None,
live_period: Optional[int] = None,
horizontal_accuracy: Optional[float] = None,
heading: Optional[int] = None,
proximity_alert_radius: Optional[int] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
with self._unfrozen():

View file

@ -18,6 +18,8 @@
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the classes that represent Telegram InputMessageContent."""
from typing import Optional
from telegram._telegramobject import TelegramObject
from telegram._utils.types import JSONDict
@ -34,7 +36,7 @@ class InputMessageContent(TelegramObject):
__slots__ = ()
def __init__(self, *, api_kwargs: JSONDict = None) -> None:
def __init__(self, *, api_kwargs: Optional[JSONDict] = None) -> None:
super().__init__(api_kwargs=api_kwargs)
self._freeze()

View file

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

View file

@ -81,12 +81,12 @@ class InputVenueMessageContent(InputMessageContent):
longitude: float,
title: str,
address: str,
foursquare_id: str = None,
foursquare_type: str = None,
google_place_id: str = None,
google_place_type: str = None,
foursquare_id: Optional[str] = None,
foursquare_type: Optional[str] = None,
google_place_id: Optional[str] = None,
google_place_type: Optional[str] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
with self._unfrozen():

View file

@ -131,14 +131,14 @@ class KeyboardButton(TelegramObject):
def __init__(
self,
text: str,
request_contact: bool = None,
request_location: bool = None,
request_poll: KeyboardButtonPollType = None,
web_app: WebAppInfo = None,
request_user: KeyboardButtonRequestUser = None,
request_chat: KeyboardButtonRequestChat = None,
request_contact: Optional[bool] = None,
request_location: Optional[bool] = None,
request_poll: Optional[KeyboardButtonPollType] = None,
web_app: Optional[WebAppInfo] = None,
request_user: Optional[KeyboardButtonRequestUser] = None,
request_chat: Optional[KeyboardButtonRequestChat] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
# Required

View file

@ -48,8 +48,11 @@ class KeyboardButtonPollType(TelegramObject):
__slots__ = ("type",)
def __init__(
self, type: str = None, *, api_kwargs: JSONDict = None # skipcq: PYL-W0622
): # pylint: disable=redefined-builtin
self,
type: Optional[str] = None, # pylint: disable=redefined-builtin
*,
api_kwargs: Optional[JSONDict] = None, # skipcq: PYL-W0622
):
super().__init__(api_kwargs=api_kwargs)
self.type: Optional[str] = type

View file

@ -66,10 +66,10 @@ class KeyboardButtonRequestUser(TelegramObject):
def __init__(
self,
request_id: int,
user_is_bot: bool = None,
user_is_premium: bool = None,
user_is_bot: Optional[bool] = None,
user_is_premium: Optional[bool] = None,
*,
api_kwargs: JSONDict = None, # skipcq: PYL-W0622
api_kwargs: Optional[JSONDict] = None, # skipcq: PYL-W0622
):
super().__init__(api_kwargs=api_kwargs)
# Required
@ -157,14 +157,14 @@ class KeyboardButtonRequestChat(TelegramObject):
self,
request_id: int,
chat_is_channel: bool,
chat_is_forum: bool = None,
chat_has_username: bool = None,
chat_is_created: bool = None,
user_administrator_rights: ChatAdministratorRights = None,
bot_administrator_rights: ChatAdministratorRights = None,
bot_is_member: bool = None,
chat_is_forum: Optional[bool] = None,
chat_has_username: Optional[bool] = None,
chat_is_created: Optional[bool] = None,
user_administrator_rights: Optional[ChatAdministratorRights] = None,
bot_administrator_rights: Optional[ChatAdministratorRights] = None,
bot_is_member: Optional[bool] = None,
*,
api_kwargs: JSONDict = None, # skipcq: PYL-W0622
api_kwargs: Optional[JSONDict] = None, # skipcq: PYL-W0622
):
super().__init__(api_kwargs=api_kwargs)
# required

View file

@ -86,11 +86,11 @@ class LoginUrl(TelegramObject):
def __init__(
self,
url: str,
forward_text: bool = None,
bot_username: str = None,
request_write_access: bool = None,
forward_text: Optional[bool] = None,
bot_username: Optional[str] = None,
request_write_access: Optional[bool] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
# Required

View file

@ -55,7 +55,7 @@ class MenuButton(TelegramObject):
__slots__ = ("type",)
def __init__(
self, type: str, *, api_kwargs: JSONDict = None # skipcq: PYL-W0622
self, type: str, *, api_kwargs: Optional[JSONDict] = None # skipcq: PYL-W0622
): # pylint: disable=redefined-builtin
super().__init__(api_kwargs=api_kwargs)
self.type: str = type
@ -115,7 +115,7 @@ class MenuButtonCommands(MenuButton):
__slots__ = ()
def __init__(self, *, api_kwargs: JSONDict = None):
def __init__(self, *, api_kwargs: Optional[JSONDict] = None):
super().__init__(type=constants.MenuButtonType.COMMANDS, api_kwargs=api_kwargs)
self._freeze()
@ -148,7 +148,7 @@ class MenuButtonWebApp(MenuButton):
__slots__ = ("text", "web_app")
def __init__(self, text: str, web_app: WebAppInfo, *, api_kwargs: JSONDict = None):
def __init__(self, text: str, web_app: WebAppInfo, *, api_kwargs: Optional[JSONDict] = None):
super().__init__(type=constants.MenuButtonType.WEB_APP, api_kwargs=api_kwargs)
with self._unfrozen():
self.text: str = text
@ -179,6 +179,6 @@ class MenuButtonDefault(MenuButton):
__slots__ = ()
def __init__(self, *, api_kwargs: JSONDict = None):
def __init__(self, *, api_kwargs: Optional[JSONDict] = None):
super().__init__(type=constants.MenuButtonType.DEFAULT, api_kwargs=api_kwargs)
self._freeze()

File diff suppressed because it is too large Load diff

View file

@ -20,6 +20,8 @@
deletion.
"""
from typing import Optional
from telegram._telegramobject import TelegramObject
from telegram._utils.types import JSONDict
@ -48,7 +50,7 @@ class MessageAutoDeleteTimerChanged(TelegramObject):
self,
message_auto_delete_time: int,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
self.message_auto_delete_time: int = message_auto_delete_time

View file

@ -96,12 +96,12 @@ class MessageEntity(TelegramObject):
type: str, # pylint: disable=redefined-builtin
offset: int,
length: int,
url: str = None,
user: User = None,
language: str = None,
custom_emoji_id: str = None,
url: Optional[str] = None,
user: Optional[User] = None,
language: Optional[str] = None,
custom_emoji_id: Optional[str] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
# Required

View file

@ -18,6 +18,8 @@
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents an instance of a Telegram MessageId."""
from typing import Optional
from telegram._telegramobject import TelegramObject
from telegram._utils.types import JSONDict
@ -37,7 +39,7 @@ class MessageId(TelegramObject):
__slots__ = ("message_id",)
def __init__(self, message_id: int, *, api_kwargs: JSONDict = None):
def __init__(self, message_id: int, *, api_kwargs: Optional[JSONDict] = None):
super().__init__(api_kwargs=api_kwargs)
self.message_id: int = message_id

View file

@ -143,7 +143,7 @@ class EncryptedCredentials(TelegramObject):
hash: str, # skipcq: PYL-W0622
secret: str,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
# Required
@ -222,7 +222,7 @@ class Credentials(TelegramObject):
secure_data: "SecureData",
nonce: str,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
# Required
@ -310,19 +310,19 @@ class SecureData(TelegramObject):
def __init__(
self,
personal_details: "SecureValue" = None,
passport: "SecureValue" = None,
internal_passport: "SecureValue" = None,
driver_license: "SecureValue" = None,
identity_card: "SecureValue" = None,
address: "SecureValue" = None,
utility_bill: "SecureValue" = None,
bank_statement: "SecureValue" = None,
rental_agreement: "SecureValue" = None,
passport_registration: "SecureValue" = None,
temporary_registration: "SecureValue" = None,
personal_details: Optional["SecureValue"] = None,
passport: Optional["SecureValue"] = None,
internal_passport: Optional["SecureValue"] = None,
driver_license: Optional["SecureValue"] = None,
identity_card: Optional["SecureValue"] = None,
address: Optional["SecureValue"] = None,
utility_bill: Optional["SecureValue"] = None,
bank_statement: Optional["SecureValue"] = None,
rental_agreement: Optional["SecureValue"] = None,
passport_registration: Optional["SecureValue"] = None,
temporary_registration: Optional["SecureValue"] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
@ -428,14 +428,14 @@ class SecureValue(TelegramObject):
def __init__(
self,
data: "DataCredentials" = None,
front_side: "FileCredentials" = None,
reverse_side: "FileCredentials" = None,
selfie: "FileCredentials" = None,
files: Sequence["FileCredentials"] = None,
translation: Sequence["FileCredentials"] = None,
data: Optional["DataCredentials"] = None,
front_side: Optional["FileCredentials"] = None,
reverse_side: Optional["FileCredentials"] = None,
selfie: Optional["FileCredentials"] = None,
files: Optional[Sequence["FileCredentials"]] = None,
translation: Optional[Sequence["FileCredentials"]] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
self.data: Optional[DataCredentials] = data
@ -471,7 +471,7 @@ class _CredentialsBase(TelegramObject):
__slots__ = ("hash", "secret", "file_hash", "data_hash")
def __init__(
self, hash: str, secret: str, *, api_kwargs: JSONDict = None # skipcq: PYL-W0622
self, hash: str, secret: str, *, api_kwargs: Optional[JSONDict] = None # skipcq: PYL-W0622
):
super().__init__(api_kwargs=api_kwargs)
with self._unfrozen():
@ -499,7 +499,7 @@ class DataCredentials(_CredentialsBase):
__slots__ = ()
def __init__(self, data_hash: str, secret: str, *, api_kwargs: JSONDict = None):
def __init__(self, data_hash: str, secret: str, *, api_kwargs: Optional[JSONDict] = None):
super().__init__(hash=data_hash, secret=secret, api_kwargs=api_kwargs)
self._freeze()
@ -520,6 +520,6 @@ class FileCredentials(_CredentialsBase):
__slots__ = ()
def __init__(self, file_hash: str, secret: str, *, api_kwargs: JSONDict = None):
def __init__(self, file_hash: str, secret: str, *, api_kwargs: Optional[JSONDict] = None):
super().__init__(hash=file_hash, secret=secret, api_kwargs=api_kwargs)
self._freeze()

View file

@ -81,12 +81,12 @@ class PersonalDetails(TelegramObject):
gender: str,
country_code: str,
residence_country_code: str,
first_name_native: str = None,
last_name_native: str = None,
middle_name: str = None,
middle_name_native: str = None,
first_name_native: Optional[str] = None,
last_name_native: Optional[str] = None,
middle_name: Optional[str] = None,
middle_name_native: Optional[str] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
# Required
@ -143,7 +143,7 @@ class ResidentialAddress(TelegramObject):
country_code: str,
post_code: str,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
# Required
@ -177,7 +177,7 @@ class IdDocumentData(TelegramObject):
document_no: str,
expiry_date: str,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
self.document_no: str = document_no

View file

@ -151,17 +151,17 @@ class EncryptedPassportElement(TelegramObject):
self,
type: str, # pylint: disable=redefined-builtin
hash: str, # pylint: disable=redefined-builtin
data: PersonalDetails = None,
phone_number: str = None,
email: str = None,
files: Sequence[PassportFile] = None,
front_side: PassportFile = None,
reverse_side: PassportFile = None,
selfie: PassportFile = None,
translation: Sequence[PassportFile] = None,
credentials: "Credentials" = None, # pylint: disable=unused-argument
data: Optional[PersonalDetails] = None,
phone_number: Optional[str] = None,
email: Optional[str] = None,
files: Optional[Sequence[PassportFile]] = None,
front_side: Optional[PassportFile] = None,
reverse_side: Optional[PassportFile] = None,
selfie: Optional[PassportFile] = None,
translation: Optional[Sequence[PassportFile]] = None,
credentials: Optional["Credentials"] = None, # pylint: disable=unused-argument
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)

View file

@ -68,7 +68,7 @@ class PassportData(TelegramObject):
data: Sequence[EncryptedPassportElement],
credentials: EncryptedCredentials,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)

View file

@ -19,6 +19,8 @@
# pylint: disable=redefined-builtin
"""This module contains the classes that represent Telegram PassportElementError."""
from typing import Optional
from telegram._telegramobject import TelegramObject
from telegram._utils.types import JSONDict
@ -46,7 +48,9 @@ class PassportElementError(TelegramObject):
__slots__ = ("message", "source", "type")
def __init__(self, source: str, type: str, message: str, *, api_kwargs: JSONDict = None):
def __init__(
self, source: str, type: str, message: str, *, api_kwargs: Optional[JSONDict] = None
):
super().__init__(api_kwargs=api_kwargs)
# Required
self.source: str = str(source)
@ -94,7 +98,7 @@ class PassportElementErrorDataField(PassportElementError):
data_hash: str,
message: str,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
# Required
super().__init__("data", type, message, api_kwargs=api_kwargs)
@ -138,7 +142,9 @@ class PassportElementErrorFile(PassportElementError):
__slots__ = ("file_hash",)
def __init__(self, type: str, file_hash: str, message: str, *, api_kwargs: JSONDict = None):
def __init__(
self, type: str, file_hash: str, message: str, *, api_kwargs: Optional[JSONDict] = None
):
# Required
super().__init__("file", type, message, api_kwargs=api_kwargs)
with self._unfrozen():
@ -174,7 +180,9 @@ class PassportElementErrorFiles(PassportElementError):
__slots__ = ("file_hashes",)
def __init__(self, type: str, file_hashes: str, message: str, *, api_kwargs: JSONDict = None):
def __init__(
self, type: str, file_hashes: str, message: str, *, api_kwargs: Optional[JSONDict] = None
):
# Required
super().__init__("files", type, message, api_kwargs=api_kwargs)
with self._unfrozen():
@ -210,7 +218,9 @@ class PassportElementErrorFrontSide(PassportElementError):
__slots__ = ("file_hash",)
def __init__(self, type: str, file_hash: str, message: str, *, api_kwargs: JSONDict = None):
def __init__(
self, type: str, file_hash: str, message: str, *, api_kwargs: Optional[JSONDict] = None
):
# Required
super().__init__("front_side", type, message, api_kwargs=api_kwargs)
with self._unfrozen():
@ -246,7 +256,9 @@ class PassportElementErrorReverseSide(PassportElementError):
__slots__ = ("file_hash",)
def __init__(self, type: str, file_hash: str, message: str, *, api_kwargs: JSONDict = None):
def __init__(
self, type: str, file_hash: str, message: str, *, api_kwargs: Optional[JSONDict] = None
):
# Required
super().__init__("reverse_side", type, message, api_kwargs=api_kwargs)
with self._unfrozen():
@ -280,7 +292,9 @@ class PassportElementErrorSelfie(PassportElementError):
__slots__ = ("file_hash",)
def __init__(self, type: str, file_hash: str, message: str, *, api_kwargs: JSONDict = None):
def __init__(
self, type: str, file_hash: str, message: str, *, api_kwargs: Optional[JSONDict] = None
):
# Required
super().__init__("selfie", type, message, api_kwargs=api_kwargs)
with self._unfrozen():
@ -318,7 +332,9 @@ class PassportElementErrorTranslationFile(PassportElementError):
__slots__ = ("file_hash",)
def __init__(self, type: str, file_hash: str, message: str, *, api_kwargs: JSONDict = None):
def __init__(
self, type: str, file_hash: str, message: str, *, api_kwargs: Optional[JSONDict] = None
):
# Required
super().__init__("translation_file", type, message, api_kwargs=api_kwargs)
with self._unfrozen():
@ -356,7 +372,9 @@ class PassportElementErrorTranslationFiles(PassportElementError):
__slots__ = ("file_hashes",)
def __init__(self, type: str, file_hashes: str, message: str, *, api_kwargs: JSONDict = None):
def __init__(
self, type: str, file_hashes: str, message: str, *, api_kwargs: Optional[JSONDict] = None
):
# Required
super().__init__("translation_files", type, message, api_kwargs=api_kwargs)
with self._unfrozen():
@ -388,7 +406,9 @@ class PassportElementErrorUnspecified(PassportElementError):
__slots__ = ("element_hash",)
def __init__(self, type: str, element_hash: str, message: str, *, api_kwargs: JSONDict = None):
def __init__(
self, type: str, element_hash: str, message: str, *, api_kwargs: Optional[JSONDict] = None
):
# Required
super().__init__("unspecified", type, message, api_kwargs=api_kwargs)
with self._unfrozen():

View file

@ -71,9 +71,9 @@ class PassportFile(TelegramObject):
file_unique_id: str,
file_date: int,
file_size: int,
credentials: "FileCredentials" = None,
credentials: Optional["FileCredentials"] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
@ -155,7 +155,7 @@ class PassportFile(TelegramObject):
write_timeout: ODVInput[float] = DEFAULT_NONE,
connect_timeout: ODVInput[float] = DEFAULT_NONE,
pool_timeout: ODVInput[float] = DEFAULT_NONE,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
) -> "File":
"""
Wrapper over :meth:`telegram.Bot.get_file`. Will automatically assign the correct

View file

@ -18,7 +18,7 @@
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram Invoice."""
from typing import ClassVar
from typing import ClassVar, Optional
from telegram import constants
from telegram._telegramobject import TelegramObject
@ -76,7 +76,7 @@ class Invoice(TelegramObject):
currency: str,
total_amount: int,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
self.title: str = title

View file

@ -18,6 +18,8 @@
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram LabeledPrice."""
from typing import Optional
from telegram._telegramobject import TelegramObject
from telegram._utils.types import JSONDict
@ -53,7 +55,7 @@ class LabeledPrice(TelegramObject):
__slots__ = ("label", "amount")
def __init__(self, label: str, amount: int, *, api_kwargs: JSONDict = None):
def __init__(self, label: str, amount: int, *, api_kwargs: Optional[JSONDict] = None):
super().__init__(api_kwargs=api_kwargs)
self.label: str = label
self.amount: int = amount

View file

@ -53,12 +53,12 @@ class OrderInfo(TelegramObject):
def __init__(
self,
name: str = None,
phone_number: str = None,
email: str = None,
shipping_address: str = None,
name: Optional[str] = None,
phone_number: Optional[str] = None,
email: Optional[str] = None,
shipping_address: Optional[str] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
self.name: Optional[str] = name

View file

@ -89,10 +89,10 @@ class PreCheckoutQuery(TelegramObject):
currency: str,
total_amount: int,
invoice_payload: str,
shipping_option_id: str = None,
order_info: OrderInfo = None,
shipping_option_id: Optional[str] = None,
order_info: Optional[OrderInfo] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
self.id: str = id # pylint: disable=invalid-name
@ -123,13 +123,13 @@ class PreCheckoutQuery(TelegramObject):
async def answer( # pylint: disable=invalid-name
self,
ok: bool,
error_message: str = None,
error_message: Optional[str] = None,
*,
read_timeout: ODVInput[float] = DEFAULT_NONE,
write_timeout: ODVInput[float] = DEFAULT_NONE,
connect_timeout: ODVInput[float] = DEFAULT_NONE,
pool_timeout: ODVInput[float] = DEFAULT_NONE,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
) -> bool:
"""Shortcut for::

View file

@ -18,6 +18,8 @@
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram ShippingAddress."""
from typing import Optional
from telegram._telegramobject import TelegramObject
from telegram._utils.types import JSONDict
@ -65,7 +67,7 @@ class ShippingAddress(TelegramObject):
street_line2: str,
post_code: str,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
self.country_code: str = country_code

View file

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

View file

@ -64,7 +64,7 @@ class ShippingQuery(TelegramObject):
invoice_payload: str,
shipping_address: ShippingAddress,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
self.id: str = id # pylint: disable=invalid-name
@ -92,14 +92,14 @@ class ShippingQuery(TelegramObject):
async def answer( # pylint: disable=invalid-name
self,
ok: bool,
shipping_options: Sequence[ShippingOption] = None,
error_message: str = None,
shipping_options: Optional[Sequence[ShippingOption]] = None,
error_message: Optional[str] = None,
*,
read_timeout: ODVInput[float] = DEFAULT_NONE,
write_timeout: ODVInput[float] = DEFAULT_NONE,
connect_timeout: ODVInput[float] = DEFAULT_NONE,
pool_timeout: ODVInput[float] = DEFAULT_NONE,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
) -> bool:
"""Shortcut for::

View file

@ -84,10 +84,10 @@ class SuccessfulPayment(TelegramObject):
invoice_payload: str,
telegram_payment_charge_id: str,
provider_payment_charge_id: str,
shipping_option_id: str = None,
order_info: OrderInfo = None,
shipping_option_id: Optional[str] = None,
order_info: Optional[OrderInfo] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
self.currency: str = currency

View file

@ -56,7 +56,7 @@ class PollOption(TelegramObject):
__slots__ = ("voter_count", "text")
def __init__(self, text: str, voter_count: int, *, api_kwargs: JSONDict = None):
def __init__(self, text: str, voter_count: int, *, api_kwargs: Optional[JSONDict] = None):
super().__init__(api_kwargs=api_kwargs)
self.text: str = text
self.voter_count: int = voter_count
@ -107,7 +107,12 @@ class PollAnswer(TelegramObject):
__slots__ = ("option_ids", "user", "poll_id")
def __init__(
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: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
self.poll_id: str = poll_id
@ -240,13 +245,13 @@ class Poll(TelegramObject):
is_anonymous: bool,
type: str, # pylint: disable=redefined-builtin
allows_multiple_answers: bool,
correct_option_id: int = None,
explanation: str = None,
explanation_entities: Sequence[MessageEntity] = None,
open_period: int = None,
close_date: datetime.datetime = None,
correct_option_id: Optional[int] = None,
explanation: Optional[str] = None,
explanation_entities: Optional[Sequence[MessageEntity]] = None,
open_period: Optional[int] = None,
close_date: Optional[datetime.datetime] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
self.id: str = id # pylint: disable=invalid-name
@ -313,7 +318,9 @@ class Poll(TelegramObject):
return entity_text.decode("utf-16-le")
def parse_explanation_entities(self, types: List[str] = None) -> Dict[MessageEntity, str]:
def parse_explanation_entities(
self, types: Optional[List[str]] = None
) -> Dict[MessageEntity, str]:
"""
Returns a :obj:`dict` that maps :class:`telegram.MessageEntity` to :obj:`str`.
It contains entities from this polls explanation filtered by their ``type`` attribute as

View file

@ -50,7 +50,12 @@ class ProximityAlertTriggered(TelegramObject):
__slots__ = ("traveler", "distance", "watcher")
def __init__(
self, traveler: User, watcher: User, distance: int, *, api_kwargs: JSONDict = None
self,
traveler: User,
watcher: User,
distance: int,
*,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
self.traveler: User = traveler

View file

@ -131,13 +131,13 @@ class ReplyKeyboardMarkup(TelegramObject):
def __init__(
self,
keyboard: Sequence[Sequence[Union[str, KeyboardButton]]],
resize_keyboard: bool = None,
one_time_keyboard: bool = None,
selective: bool = None,
input_field_placeholder: str = None,
is_persistent: bool = None,
resize_keyboard: Optional[bool] = None,
one_time_keyboard: Optional[bool] = None,
selective: Optional[bool] = None,
input_field_placeholder: Optional[str] = None,
is_persistent: Optional[bool] = None,
*,
api_kwargs: JSONDict = None,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)
if not check_keyboard_type(keyboard):
@ -170,8 +170,8 @@ class ReplyKeyboardMarkup(TelegramObject):
resize_keyboard: bool = False,
one_time_keyboard: bool = False,
selective: bool = False,
input_field_placeholder: str = None,
is_persistent: bool = None,
input_field_placeholder: Optional[str] = None,
is_persistent: Optional[bool] = None,
**kwargs: object,
) -> "ReplyKeyboardMarkup":
"""Shortcut for::
@ -228,8 +228,8 @@ class ReplyKeyboardMarkup(TelegramObject):
resize_keyboard: bool = False,
one_time_keyboard: bool = False,
selective: bool = False,
input_field_placeholder: str = None,
is_persistent: bool = None,
input_field_placeholder: Optional[str] = None,
is_persistent: Optional[bool] = None,
**kwargs: object,
) -> "ReplyKeyboardMarkup":
"""Shortcut for::
@ -290,8 +290,8 @@ class ReplyKeyboardMarkup(TelegramObject):
resize_keyboard: bool = False,
one_time_keyboard: bool = False,
selective: bool = False,
input_field_placeholder: str = None,
is_persistent: bool = None,
input_field_placeholder: Optional[str] = None,
is_persistent: Optional[bool] = None,
**kwargs: object,
) -> "ReplyKeyboardMarkup":
"""Shortcut for::

View file

@ -62,7 +62,7 @@ class ReplyKeyboardRemove(TelegramObject):
__slots__ = ("selective", "remove_keyboard")
def __init__(self, selective: bool = None, *, api_kwargs: JSONDict = None):
def __init__(self, selective: Optional[bool] = None, *, api_kwargs: Optional[JSONDict] = None):
super().__init__(api_kwargs=api_kwargs)
# Required
self.remove_keyboard: bool = True

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