mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Update pydantic to V2 (#1202)
* Update pydantic, fix errors and warnings (all?) * Fixed typehints * Reformat code, removed unused imports * Fixed typing extensions version compatibility * Fixed coverage * Describe changes * Regen code
This commit is contained in:
parent
066d16b522
commit
461e59bbdd
182 changed files with 385 additions and 485 deletions
|
|
@ -1,4 +1,4 @@
|
|||
from typing import Optional
|
||||
from typing import List, Literal, Optional, Union
|
||||
|
||||
from .animation import Animation
|
||||
from .audio import Audio
|
||||
|
|
@ -324,11 +324,16 @@ __all__ = (
|
|||
# Load typing forward refs for every TelegramObject
|
||||
for _entity_name in __all__:
|
||||
_entity = globals()[_entity_name]
|
||||
if not hasattr(_entity, "update_forward_refs"):
|
||||
if not hasattr(_entity, "model_rebuild"):
|
||||
continue
|
||||
_entity.update_forward_refs(
|
||||
**{k: v for k, v in globals().items() if k in __all__},
|
||||
**{"Optional": Optional},
|
||||
_entity.model_rebuild(
|
||||
_types_namespace={
|
||||
"List": List,
|
||||
"Optional": Optional,
|
||||
"Union": Union,
|
||||
"Literal": Literal,
|
||||
**{k: v for k, v in globals().items() if k in __all__},
|
||||
}
|
||||
)
|
||||
|
||||
del _entity
|
||||
|
|
|
|||
|
|
@ -1,26 +1,26 @@
|
|||
import datetime
|
||||
from typing import Any
|
||||
from unittest.mock import sentinel
|
||||
|
||||
from pydantic import BaseModel, Extra
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
|
||||
from aiogram.utils.mixins import ContextInstanceMixin
|
||||
|
||||
|
||||
class TelegramObject(ContextInstanceMixin["TelegramObject"], BaseModel):
|
||||
class Config:
|
||||
use_enum_values = True
|
||||
orm_mode = True
|
||||
extra = Extra.allow
|
||||
validate_assignment = True
|
||||
allow_mutation = False
|
||||
allow_population_by_field_name = True
|
||||
json_encoders = {datetime.datetime: lambda dt: int(dt.timestamp())}
|
||||
model_config = ConfigDict(
|
||||
use_enum_values=True,
|
||||
extra="allow",
|
||||
validate_assignment=True,
|
||||
frozen=True,
|
||||
populate_by_name=True,
|
||||
arbitrary_types_allowed=True,
|
||||
)
|
||||
|
||||
|
||||
class MutableTelegramObject(TelegramObject):
|
||||
class Config:
|
||||
allow_mutation = True
|
||||
model_config = ConfigDict(
|
||||
frozen=False,
|
||||
)
|
||||
|
||||
|
||||
# special sentinel object which used in situation when None might be a useful value
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from pydantic import Field
|
||||
from typing import Literal
|
||||
|
||||
from ..enums import BotCommandScopeType
|
||||
from .bot_command_scope import BotCommandScope
|
||||
|
|
@ -13,5 +13,7 @@ class BotCommandScopeAllChatAdministrators(BotCommandScope):
|
|||
Source: https://core.telegram.org/bots/api#botcommandscopeallchatadministrators
|
||||
"""
|
||||
|
||||
type: str = Field(BotCommandScopeType.ALL_CHAT_ADMINISTRATORS, const=True)
|
||||
type: Literal[
|
||||
BotCommandScopeType.ALL_CHAT_ADMINISTRATORS
|
||||
] = BotCommandScopeType.ALL_CHAT_ADMINISTRATORS
|
||||
"""Scope type, must be *all_chat_administrators*"""
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from pydantic import Field
|
||||
from typing import Literal
|
||||
|
||||
from ..enums import BotCommandScopeType
|
||||
from .bot_command_scope import BotCommandScope
|
||||
|
|
@ -13,5 +13,5 @@ class BotCommandScopeAllGroupChats(BotCommandScope):
|
|||
Source: https://core.telegram.org/bots/api#botcommandscopeallgroupchats
|
||||
"""
|
||||
|
||||
type: str = Field(BotCommandScopeType.ALL_GROUP_CHATS, const=True)
|
||||
type: Literal[BotCommandScopeType.ALL_GROUP_CHATS] = BotCommandScopeType.ALL_GROUP_CHATS
|
||||
"""Scope type, must be *all_group_chats*"""
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from pydantic import Field
|
||||
from typing import Literal
|
||||
|
||||
from ..enums import BotCommandScopeType
|
||||
from .bot_command_scope import BotCommandScope
|
||||
|
|
@ -13,5 +13,5 @@ class BotCommandScopeAllPrivateChats(BotCommandScope):
|
|||
Source: https://core.telegram.org/bots/api#botcommandscopeallprivatechats
|
||||
"""
|
||||
|
||||
type: str = Field(BotCommandScopeType.ALL_PRIVATE_CHATS, const=True)
|
||||
type: Literal[BotCommandScopeType.ALL_PRIVATE_CHATS] = BotCommandScopeType.ALL_PRIVATE_CHATS
|
||||
"""Scope type, must be *all_private_chats*"""
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import Union
|
||||
|
||||
from pydantic import Field
|
||||
from typing import Literal, Union
|
||||
|
||||
from ..enums import BotCommandScopeType
|
||||
from .bot_command_scope import BotCommandScope
|
||||
|
|
@ -15,7 +13,7 @@ class BotCommandScopeChat(BotCommandScope):
|
|||
Source: https://core.telegram.org/bots/api#botcommandscopechat
|
||||
"""
|
||||
|
||||
type: str = Field(BotCommandScopeType.CHAT, const=True)
|
||||
type: Literal[BotCommandScopeType.CHAT] = BotCommandScopeType.CHAT
|
||||
"""Scope type, must be *chat*"""
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target supergroup (in the format :code:`@supergroupusername`)"""
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import Union
|
||||
|
||||
from pydantic import Field
|
||||
from typing import Literal, Union
|
||||
|
||||
from ..enums import BotCommandScopeType
|
||||
from .bot_command_scope import BotCommandScope
|
||||
|
|
@ -15,7 +13,9 @@ class BotCommandScopeChatAdministrators(BotCommandScope):
|
|||
Source: https://core.telegram.org/bots/api#botcommandscopechatadministrators
|
||||
"""
|
||||
|
||||
type: str = Field(BotCommandScopeType.CHAT_ADMINISTRATORS, const=True)
|
||||
type: Literal[
|
||||
BotCommandScopeType.CHAT_ADMINISTRATORS
|
||||
] = BotCommandScopeType.CHAT_ADMINISTRATORS
|
||||
"""Scope type, must be *chat_administrators*"""
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target supergroup (in the format :code:`@supergroupusername`)"""
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import Union
|
||||
|
||||
from pydantic import Field
|
||||
from typing import Literal, Union
|
||||
|
||||
from ..enums import BotCommandScopeType
|
||||
from .bot_command_scope import BotCommandScope
|
||||
|
|
@ -15,7 +13,7 @@ class BotCommandScopeChatMember(BotCommandScope):
|
|||
Source: https://core.telegram.org/bots/api#botcommandscopechatmember
|
||||
"""
|
||||
|
||||
type: str = Field(BotCommandScopeType.CHAT_MEMBER, const=True)
|
||||
type: Literal[BotCommandScopeType.CHAT_MEMBER] = BotCommandScopeType.CHAT_MEMBER
|
||||
"""Scope type, must be *chat_member*"""
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target supergroup (in the format :code:`@supergroupusername`)"""
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from pydantic import Field
|
||||
from typing import Literal
|
||||
|
||||
from ..enums import BotCommandScopeType
|
||||
from .bot_command_scope import BotCommandScope
|
||||
|
|
@ -13,5 +13,5 @@ class BotCommandScopeDefault(BotCommandScope):
|
|||
Source: https://core.telegram.org/bots/api#botcommandscopedefault
|
||||
"""
|
||||
|
||||
type: str = Field(BotCommandScopeType.DEFAULT, const=True)
|
||||
type: Literal[BotCommandScopeType.DEFAULT] = BotCommandScopeType.DEFAULT
|
||||
"""Scope type, must be *default*"""
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from pydantic import Field
|
||||
from typing import TYPE_CHECKING, Literal, Optional
|
||||
|
||||
from ..enums import ChatMemberStatus
|
||||
from .chat_member import ChatMember
|
||||
|
|
@ -18,7 +16,7 @@ class ChatMemberAdministrator(ChatMember):
|
|||
Source: https://core.telegram.org/bots/api#chatmemberadministrator
|
||||
"""
|
||||
|
||||
status: str = Field(ChatMemberStatus.ADMINISTRATOR, const=True)
|
||||
status: Literal[ChatMemberStatus.ADMINISTRATOR] = ChatMemberStatus.ADMINISTRATOR
|
||||
"""The member's status in the chat, always 'administrator'"""
|
||||
user: User
|
||||
"""Information about the user"""
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import datetime
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from pydantic import Field
|
||||
from typing import TYPE_CHECKING, Literal
|
||||
|
||||
from ..enums import ChatMemberStatus
|
||||
from .chat_member import ChatMember
|
||||
|
|
@ -19,7 +17,7 @@ class ChatMemberBanned(ChatMember):
|
|||
Source: https://core.telegram.org/bots/api#chatmemberbanned
|
||||
"""
|
||||
|
||||
status: str = Field(ChatMemberStatus.KICKED, const=True)
|
||||
status: Literal[ChatMemberStatus.KICKED] = ChatMemberStatus.KICKED
|
||||
"""The member's status in the chat, always 'kicked'"""
|
||||
user: User
|
||||
"""Information about the user"""
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from pydantic import Field
|
||||
from typing import TYPE_CHECKING, Literal
|
||||
|
||||
from ..enums import ChatMemberStatus
|
||||
from .chat_member import ChatMember
|
||||
|
|
@ -18,7 +16,7 @@ class ChatMemberLeft(ChatMember):
|
|||
Source: https://core.telegram.org/bots/api#chatmemberleft
|
||||
"""
|
||||
|
||||
status: str = Field(ChatMemberStatus.LEFT, const=True)
|
||||
status: Literal[ChatMemberStatus.LEFT] = ChatMemberStatus.LEFT
|
||||
"""The member's status in the chat, always 'left'"""
|
||||
user: User
|
||||
"""Information about the user"""
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from pydantic import Field
|
||||
from typing import TYPE_CHECKING, Literal
|
||||
|
||||
from ..enums import ChatMemberStatus
|
||||
from .chat_member import ChatMember
|
||||
|
|
@ -18,7 +16,7 @@ class ChatMemberMember(ChatMember):
|
|||
Source: https://core.telegram.org/bots/api#chatmembermember
|
||||
"""
|
||||
|
||||
status: str = Field(ChatMemberStatus.MEMBER, const=True)
|
||||
status: Literal[ChatMemberStatus.MEMBER] = ChatMemberStatus.MEMBER
|
||||
"""The member's status in the chat, always 'member'"""
|
||||
user: User
|
||||
"""Information about the user"""
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from pydantic import Field
|
||||
from typing import TYPE_CHECKING, Literal, Optional
|
||||
|
||||
from ..enums import ChatMemberStatus
|
||||
from .chat_member import ChatMember
|
||||
|
|
@ -18,7 +16,7 @@ class ChatMemberOwner(ChatMember):
|
|||
Source: https://core.telegram.org/bots/api#chatmemberowner
|
||||
"""
|
||||
|
||||
status: str = Field(ChatMemberStatus.CREATOR, const=True)
|
||||
status: Literal[ChatMemberStatus.CREATOR] = ChatMemberStatus.CREATOR
|
||||
"""The member's status in the chat, always 'creator'"""
|
||||
user: User
|
||||
"""Information about the user"""
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import datetime
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from pydantic import Field
|
||||
from typing import TYPE_CHECKING, Literal
|
||||
|
||||
from ..enums import ChatMemberStatus
|
||||
from .chat_member import ChatMember
|
||||
|
|
@ -19,7 +17,7 @@ class ChatMemberRestricted(ChatMember):
|
|||
Source: https://core.telegram.org/bots/api#chatmemberrestricted
|
||||
"""
|
||||
|
||||
status: str = Field(ChatMemberStatus.RESTRICTED, const=True)
|
||||
status: Literal[ChatMemberStatus.RESTRICTED] = ChatMemberStatus.RESTRICTED
|
||||
"""The member's status in the chat, always 'restricted'"""
|
||||
user: User
|
||||
"""Information about the user"""
|
||||
|
|
|
|||
|
|
@ -2,18 +2,13 @@ from __future__ import annotations
|
|||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from aiogram.types.base import MutableTelegramObject
|
||||
from aiogram.types.base import TelegramObject
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .update import Update
|
||||
|
||||
|
||||
class _ErrorEvent(MutableTelegramObject):
|
||||
class Config:
|
||||
arbitrary_types_allowed = True
|
||||
|
||||
|
||||
class ErrorEvent(_ErrorEvent):
|
||||
class ErrorEvent(TelegramObject):
|
||||
"""
|
||||
Internal event, should be used to receive errors while processing Updates from Telegram
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import Field
|
||||
from typing import Literal, Optional
|
||||
|
||||
from .base import MutableTelegramObject
|
||||
|
||||
|
|
@ -21,7 +19,7 @@ class ForceReply(MutableTelegramObject):
|
|||
Source: https://core.telegram.org/bots/api#forcereply
|
||||
"""
|
||||
|
||||
force_reply: bool = Field(True, const=True)
|
||||
force_reply: Literal[True] = True
|
||||
"""Shows reply interface to the user, as if they manually selected the bot's message and tapped 'Reply'"""
|
||||
input_field_placeholder: Optional[str] = None
|
||||
"""*Optional*. The placeholder to be shown in the input field when the reply is active; 1-64 characters"""
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from pydantic import Field
|
||||
from typing import TYPE_CHECKING, Literal, Optional
|
||||
|
||||
from ..enums import InlineQueryResultType
|
||||
from .inline_query_result import InlineQueryResult
|
||||
|
|
@ -19,7 +17,7 @@ class InlineQueryResultArticle(InlineQueryResult):
|
|||
Source: https://core.telegram.org/bots/api#inlinequeryresultarticle
|
||||
"""
|
||||
|
||||
type: str = Field(InlineQueryResultType.ARTICLE, const=True)
|
||||
type: Literal[InlineQueryResultType.ARTICLE] = InlineQueryResultType.ARTICLE
|
||||
"""Type of the result, must be *article*"""
|
||||
id: str
|
||||
"""Unique identifier for this result, 1-64 Bytes"""
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, List, Optional
|
||||
|
||||
from pydantic import Field
|
||||
from typing import TYPE_CHECKING, List, Literal, Optional
|
||||
|
||||
from ..enums import InlineQueryResultType
|
||||
from .base import UNSET_PARSE_MODE
|
||||
|
|
@ -22,7 +20,7 @@ class InlineQueryResultAudio(InlineQueryResult):
|
|||
Source: https://core.telegram.org/bots/api#inlinequeryresultaudio
|
||||
"""
|
||||
|
||||
type: str = Field(InlineQueryResultType.AUDIO, const=True)
|
||||
type: Literal[InlineQueryResultType.AUDIO] = InlineQueryResultType.AUDIO
|
||||
"""Type of the result, must be *audio*"""
|
||||
id: str
|
||||
"""Unique identifier for this result, 1-64 bytes"""
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, List, Optional
|
||||
|
||||
from pydantic import Field
|
||||
from typing import TYPE_CHECKING, List, Literal, Optional
|
||||
|
||||
from ..enums import InlineQueryResultType
|
||||
from .base import UNSET_PARSE_MODE
|
||||
|
|
@ -22,7 +20,7 @@ class InlineQueryResultCachedAudio(InlineQueryResult):
|
|||
Source: https://core.telegram.org/bots/api#inlinequeryresultcachedaudio
|
||||
"""
|
||||
|
||||
type: str = Field(InlineQueryResultType.AUDIO, const=True)
|
||||
type: Literal[InlineQueryResultType.AUDIO] = InlineQueryResultType.AUDIO
|
||||
"""Type of the result, must be *audio*"""
|
||||
id: str
|
||||
"""Unique identifier for this result, 1-64 bytes"""
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, List, Optional
|
||||
|
||||
from pydantic import Field
|
||||
from typing import TYPE_CHECKING, List, Literal, Optional
|
||||
|
||||
from ..enums import InlineQueryResultType
|
||||
from .base import UNSET_PARSE_MODE
|
||||
|
|
@ -22,7 +20,7 @@ class InlineQueryResultCachedDocument(InlineQueryResult):
|
|||
Source: https://core.telegram.org/bots/api#inlinequeryresultcacheddocument
|
||||
"""
|
||||
|
||||
type: str = Field(InlineQueryResultType.DOCUMENT, const=True)
|
||||
type: Literal[InlineQueryResultType.DOCUMENT] = InlineQueryResultType.DOCUMENT
|
||||
"""Type of the result, must be *document*"""
|
||||
id: str
|
||||
"""Unique identifier for this result, 1-64 bytes"""
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, List, Optional
|
||||
|
||||
from pydantic import Field
|
||||
from typing import TYPE_CHECKING, List, Literal, Optional
|
||||
|
||||
from ..enums import InlineQueryResultType
|
||||
from .base import UNSET_PARSE_MODE
|
||||
|
|
@ -21,7 +19,7 @@ class InlineQueryResultCachedGif(InlineQueryResult):
|
|||
Source: https://core.telegram.org/bots/api#inlinequeryresultcachedgif
|
||||
"""
|
||||
|
||||
type: str = Field(InlineQueryResultType.GIF, const=True)
|
||||
type: Literal[InlineQueryResultType.GIF] = InlineQueryResultType.GIF
|
||||
"""Type of the result, must be *gif*"""
|
||||
id: str
|
||||
"""Unique identifier for this result, 1-64 bytes"""
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, List, Optional
|
||||
|
||||
from pydantic import Field
|
||||
from typing import TYPE_CHECKING, List, Literal, Optional
|
||||
|
||||
from ..enums import InlineQueryResultType
|
||||
from .base import UNSET_PARSE_MODE
|
||||
|
|
@ -21,7 +19,7 @@ class InlineQueryResultCachedMpeg4Gif(InlineQueryResult):
|
|||
Source: https://core.telegram.org/bots/api#inlinequeryresultcachedmpeg4gif
|
||||
"""
|
||||
|
||||
type: str = Field(InlineQueryResultType.MPEG4_GIF, const=True)
|
||||
type: Literal[InlineQueryResultType.MPEG4_GIF] = InlineQueryResultType.MPEG4_GIF
|
||||
"""Type of the result, must be *mpeg4_gif*"""
|
||||
id: str
|
||||
"""Unique identifier for this result, 1-64 bytes"""
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, List, Optional
|
||||
|
||||
from pydantic import Field
|
||||
from typing import TYPE_CHECKING, List, Literal, Optional
|
||||
|
||||
from ..enums import InlineQueryResultType
|
||||
from .base import UNSET_PARSE_MODE
|
||||
|
|
@ -21,7 +19,7 @@ class InlineQueryResultCachedPhoto(InlineQueryResult):
|
|||
Source: https://core.telegram.org/bots/api#inlinequeryresultcachedphoto
|
||||
"""
|
||||
|
||||
type: str = Field(InlineQueryResultType.PHOTO, const=True)
|
||||
type: Literal[InlineQueryResultType.PHOTO] = InlineQueryResultType.PHOTO
|
||||
"""Type of the result, must be *photo*"""
|
||||
id: str
|
||||
"""Unique identifier for this result, 1-64 bytes"""
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from pydantic import Field
|
||||
from typing import TYPE_CHECKING, Literal, Optional
|
||||
|
||||
from ..enums import InlineQueryResultType
|
||||
from .inline_query_result import InlineQueryResult
|
||||
|
|
@ -20,7 +18,7 @@ class InlineQueryResultCachedSticker(InlineQueryResult):
|
|||
Source: https://core.telegram.org/bots/api#inlinequeryresultcachedsticker
|
||||
"""
|
||||
|
||||
type: str = Field(InlineQueryResultType.STICKER, const=True)
|
||||
type: Literal[InlineQueryResultType.STICKER] = InlineQueryResultType.STICKER
|
||||
"""Type of the result, must be *sticker*"""
|
||||
id: str
|
||||
"""Unique identifier for this result, 1-64 bytes"""
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, List, Optional
|
||||
|
||||
from pydantic import Field
|
||||
from typing import TYPE_CHECKING, List, Literal, Optional
|
||||
|
||||
from ..enums import InlineQueryResultType
|
||||
from .base import UNSET_PARSE_MODE
|
||||
|
|
@ -21,7 +19,7 @@ class InlineQueryResultCachedVideo(InlineQueryResult):
|
|||
Source: https://core.telegram.org/bots/api#inlinequeryresultcachedvideo
|
||||
"""
|
||||
|
||||
type: str = Field(InlineQueryResultType.VIDEO, const=True)
|
||||
type: Literal[InlineQueryResultType.VIDEO] = InlineQueryResultType.VIDEO
|
||||
"""Type of the result, must be *video*"""
|
||||
id: str
|
||||
"""Unique identifier for this result, 1-64 bytes"""
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, List, Optional
|
||||
|
||||
from pydantic import Field
|
||||
from typing import TYPE_CHECKING, List, Literal, Optional
|
||||
|
||||
from ..enums import InlineQueryResultType
|
||||
from .base import UNSET_PARSE_MODE
|
||||
|
|
@ -22,7 +20,7 @@ class InlineQueryResultCachedVoice(InlineQueryResult):
|
|||
Source: https://core.telegram.org/bots/api#inlinequeryresultcachedvoice
|
||||
"""
|
||||
|
||||
type: str = Field(InlineQueryResultType.VOICE, const=True)
|
||||
type: Literal[InlineQueryResultType.VOICE] = InlineQueryResultType.VOICE
|
||||
"""Type of the result, must be *voice*"""
|
||||
id: str
|
||||
"""Unique identifier for this result, 1-64 bytes"""
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from pydantic import Field
|
||||
from typing import TYPE_CHECKING, Literal, Optional
|
||||
|
||||
from ..enums import InlineQueryResultType
|
||||
from .inline_query_result import InlineQueryResult
|
||||
|
|
@ -20,7 +18,7 @@ class InlineQueryResultContact(InlineQueryResult):
|
|||
Source: https://core.telegram.org/bots/api#inlinequeryresultcontact
|
||||
"""
|
||||
|
||||
type: str = Field(InlineQueryResultType.CONTACT, const=True)
|
||||
type: Literal[InlineQueryResultType.CONTACT] = InlineQueryResultType.CONTACT
|
||||
"""Type of the result, must be *contact*"""
|
||||
id: str
|
||||
"""Unique identifier for this result, 1-64 Bytes"""
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, List, Optional
|
||||
|
||||
from pydantic import Field
|
||||
from typing import TYPE_CHECKING, List, Literal, Optional
|
||||
|
||||
from ..enums import InlineQueryResultType
|
||||
from .base import UNSET_PARSE_MODE
|
||||
|
|
@ -22,7 +20,7 @@ class InlineQueryResultDocument(InlineQueryResult):
|
|||
Source: https://core.telegram.org/bots/api#inlinequeryresultdocument
|
||||
"""
|
||||
|
||||
type: str = Field(InlineQueryResultType.DOCUMENT, const=True)
|
||||
type: Literal[InlineQueryResultType.DOCUMENT] = InlineQueryResultType.DOCUMENT
|
||||
"""Type of the result, must be *document*"""
|
||||
id: str
|
||||
"""Unique identifier for this result, 1-64 bytes"""
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from pydantic import Field
|
||||
from typing import TYPE_CHECKING, Literal, Optional
|
||||
|
||||
from ..enums import InlineQueryResultType
|
||||
from .inline_query_result import InlineQueryResult
|
||||
|
|
@ -19,7 +17,7 @@ class InlineQueryResultGame(InlineQueryResult):
|
|||
Source: https://core.telegram.org/bots/api#inlinequeryresultgame
|
||||
"""
|
||||
|
||||
type: str = Field(InlineQueryResultType.GAME, const=True)
|
||||
type: Literal[InlineQueryResultType.GAME] = InlineQueryResultType.GAME
|
||||
"""Type of the result, must be *game*"""
|
||||
id: str
|
||||
"""Unique identifier for this result, 1-64 bytes"""
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, List, Optional
|
||||
|
||||
from pydantic import Field
|
||||
from typing import TYPE_CHECKING, List, Literal, Optional
|
||||
|
||||
from ..enums import InlineQueryResultType
|
||||
from .base import UNSET_PARSE_MODE
|
||||
|
|
@ -21,7 +19,7 @@ class InlineQueryResultGif(InlineQueryResult):
|
|||
Source: https://core.telegram.org/bots/api#inlinequeryresultgif
|
||||
"""
|
||||
|
||||
type: str = Field(InlineQueryResultType.GIF, const=True)
|
||||
type: Literal[InlineQueryResultType.GIF] = InlineQueryResultType.GIF
|
||||
"""Type of the result, must be *gif*"""
|
||||
id: str
|
||||
"""Unique identifier for this result, 1-64 bytes"""
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from pydantic import Field
|
||||
from typing import TYPE_CHECKING, Literal, Optional
|
||||
|
||||
from ..enums import InlineQueryResultType
|
||||
from .inline_query_result import InlineQueryResult
|
||||
|
|
@ -20,7 +18,7 @@ class InlineQueryResultLocation(InlineQueryResult):
|
|||
Source: https://core.telegram.org/bots/api#inlinequeryresultlocation
|
||||
"""
|
||||
|
||||
type: str = Field(InlineQueryResultType.LOCATION, const=True)
|
||||
type: Literal[InlineQueryResultType.LOCATION] = InlineQueryResultType.LOCATION
|
||||
"""Type of the result, must be *location*"""
|
||||
id: str
|
||||
"""Unique identifier for this result, 1-64 Bytes"""
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, List, Optional
|
||||
|
||||
from pydantic import Field
|
||||
from typing import TYPE_CHECKING, List, Literal, Optional
|
||||
|
||||
from ..enums import InlineQueryResultType
|
||||
from .base import UNSET_PARSE_MODE
|
||||
|
|
@ -21,7 +19,7 @@ class InlineQueryResultMpeg4Gif(InlineQueryResult):
|
|||
Source: https://core.telegram.org/bots/api#inlinequeryresultmpeg4gif
|
||||
"""
|
||||
|
||||
type: str = Field(InlineQueryResultType.MPEG4_GIF, const=True)
|
||||
type: Literal[InlineQueryResultType.MPEG4_GIF] = InlineQueryResultType.MPEG4_GIF
|
||||
"""Type of the result, must be *mpeg4_gif*"""
|
||||
id: str
|
||||
"""Unique identifier for this result, 1-64 bytes"""
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, List, Optional
|
||||
|
||||
from pydantic import Field
|
||||
from typing import TYPE_CHECKING, List, Literal, Optional
|
||||
|
||||
from ..enums import InlineQueryResultType
|
||||
from .base import UNSET_PARSE_MODE
|
||||
|
|
@ -21,7 +19,7 @@ class InlineQueryResultPhoto(InlineQueryResult):
|
|||
Source: https://core.telegram.org/bots/api#inlinequeryresultphoto
|
||||
"""
|
||||
|
||||
type: str = Field(InlineQueryResultType.PHOTO, const=True)
|
||||
type: Literal[InlineQueryResultType.PHOTO] = InlineQueryResultType.PHOTO
|
||||
"""Type of the result, must be *photo*"""
|
||||
id: str
|
||||
"""Unique identifier for this result, 1-64 bytes"""
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from pydantic import Field
|
||||
from typing import TYPE_CHECKING, Literal, Optional
|
||||
|
||||
from ..enums import InlineQueryResultType
|
||||
from .inline_query_result import InlineQueryResult
|
||||
|
|
@ -20,7 +18,7 @@ class InlineQueryResultVenue(InlineQueryResult):
|
|||
Source: https://core.telegram.org/bots/api#inlinequeryresultvenue
|
||||
"""
|
||||
|
||||
type: str = Field(InlineQueryResultType.VENUE, const=True)
|
||||
type: Literal[InlineQueryResultType.VENUE] = InlineQueryResultType.VENUE
|
||||
"""Type of the result, must be *venue*"""
|
||||
id: str
|
||||
"""Unique identifier for this result, 1-64 Bytes"""
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, List, Optional
|
||||
|
||||
from pydantic import Field
|
||||
from typing import TYPE_CHECKING, List, Literal, Optional
|
||||
|
||||
from ..enums import InlineQueryResultType
|
||||
from .base import UNSET_PARSE_MODE
|
||||
|
|
@ -23,7 +21,7 @@ class InlineQueryResultVideo(InlineQueryResult):
|
|||
Source: https://core.telegram.org/bots/api#inlinequeryresultvideo
|
||||
"""
|
||||
|
||||
type: str = Field(InlineQueryResultType.VIDEO, const=True)
|
||||
type: Literal[InlineQueryResultType.VIDEO] = InlineQueryResultType.VIDEO
|
||||
"""Type of the result, must be *video*"""
|
||||
id: str
|
||||
"""Unique identifier for this result, 1-64 bytes"""
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, List, Optional
|
||||
|
||||
from pydantic import Field
|
||||
from typing import TYPE_CHECKING, List, Literal, Optional
|
||||
|
||||
from ..enums import InlineQueryResultType
|
||||
from .base import UNSET_PARSE_MODE
|
||||
|
|
@ -22,7 +20,7 @@ class InlineQueryResultVoice(InlineQueryResult):
|
|||
Source: https://core.telegram.org/bots/api#inlinequeryresultvoice
|
||||
"""
|
||||
|
||||
type: str = Field(InlineQueryResultType.VOICE, const=True)
|
||||
type: Literal[InlineQueryResultType.VOICE] = InlineQueryResultType.VOICE
|
||||
"""Type of the result, must be *voice*"""
|
||||
id: str
|
||||
"""Unique identifier for this result, 1-64 bytes"""
|
||||
|
|
|
|||
|
|
@ -18,6 +18,6 @@ class InlineQueryResultsButton(TelegramObject):
|
|||
text: str
|
||||
"""Label text on the button"""
|
||||
web_app: Optional[WebAppInfo] = None
|
||||
"""*Optional*. Description of the `Web App <https://core.telegram.org/bots/webapps>`_ that will be launched when the user presses the button. The Web App will be able to switch back to the inline mode using the method *web_app_switch_inline_query* inside the Web App."""
|
||||
"""*Optional*. Description of the `Web App <https://core.telegram.org/bots/webapps>`_ that will be launched when the user presses the button. The Web App will be able to switch back to the inline mode using the method `switchInlineQuery <https://core.telegram.org/bots/webapps#initializing-web-apps>`_ inside the Web App."""
|
||||
start_parameter: Optional[str] = None
|
||||
"""*Optional*. `Deep-linking <https://core.telegram.org/bots/features#deep-linking>`_ parameter for the /start message sent to the bot when a user presses the button. 1-64 characters, only :code:`A-Z`, :code:`a-z`, :code:`0-9`, :code:`_` and :code:`-` are allowed."""
|
||||
|
|
|
|||
|
|
@ -29,10 +29,6 @@ class InputFile(ABC):
|
|||
self.filename = filename
|
||||
self.chunk_size = chunk_size
|
||||
|
||||
@classmethod
|
||||
def __get_validators__(cls) -> Iterator[None]:
|
||||
yield None
|
||||
|
||||
@abstractmethod
|
||||
async def read(self, chunk_size: int) -> AsyncGenerator[bytes, None]: # pragma: no cover
|
||||
yield b""
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, List, Optional, Union
|
||||
|
||||
from pydantic import Field
|
||||
from typing import TYPE_CHECKING, List, Literal, Optional, Union
|
||||
|
||||
from ..enums import InputMediaType
|
||||
from .base import UNSET_PARSE_MODE
|
||||
|
|
@ -20,7 +18,7 @@ class InputMediaAnimation(InputMedia):
|
|||
Source: https://core.telegram.org/bots/api#inputmediaanimation
|
||||
"""
|
||||
|
||||
type: str = Field(InputMediaType.ANIMATION, const=True)
|
||||
type: Literal[InputMediaType.ANIMATION] = InputMediaType.ANIMATION
|
||||
"""Type of the result, must be *animation*"""
|
||||
media: Union[str, InputFile]
|
||||
"""File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass 'attach://<file_attach_name>' to upload a new one using multipart/form-data under <file_attach_name> name. :ref:`More information on Sending Files » <sending-files>`"""
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, List, Optional, Union
|
||||
|
||||
from pydantic import Field
|
||||
from typing import TYPE_CHECKING, List, Literal, Optional, Union
|
||||
|
||||
from ..enums import InputMediaType
|
||||
from .base import UNSET_PARSE_MODE
|
||||
|
|
@ -20,7 +18,7 @@ class InputMediaAudio(InputMedia):
|
|||
Source: https://core.telegram.org/bots/api#inputmediaaudio
|
||||
"""
|
||||
|
||||
type: str = Field(InputMediaType.AUDIO, const=True)
|
||||
type: Literal[InputMediaType.AUDIO] = InputMediaType.AUDIO
|
||||
"""Type of the result, must be *audio*"""
|
||||
media: Union[str, InputFile]
|
||||
"""File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass 'attach://<file_attach_name>' to upload a new one using multipart/form-data under <file_attach_name> name. :ref:`More information on Sending Files » <sending-files>`"""
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, List, Optional, Union
|
||||
|
||||
from pydantic import Field
|
||||
from typing import TYPE_CHECKING, List, Literal, Optional, Union
|
||||
|
||||
from ..enums import InputMediaType
|
||||
from .base import UNSET_PARSE_MODE
|
||||
|
|
@ -20,7 +18,7 @@ class InputMediaDocument(InputMedia):
|
|||
Source: https://core.telegram.org/bots/api#inputmediadocument
|
||||
"""
|
||||
|
||||
type: str = Field(InputMediaType.DOCUMENT, const=True)
|
||||
type: Literal[InputMediaType.DOCUMENT] = InputMediaType.DOCUMENT
|
||||
"""Type of the result, must be *document*"""
|
||||
media: Union[str, InputFile]
|
||||
"""File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass 'attach://<file_attach_name>' to upload a new one using multipart/form-data under <file_attach_name> name. :ref:`More information on Sending Files » <sending-files>`"""
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, List, Optional, Union
|
||||
|
||||
from pydantic import Field
|
||||
from typing import TYPE_CHECKING, List, Literal, Optional, Union
|
||||
|
||||
from ..enums import InputMediaType
|
||||
from .base import UNSET_PARSE_MODE
|
||||
|
|
@ -20,7 +18,7 @@ class InputMediaPhoto(InputMedia):
|
|||
Source: https://core.telegram.org/bots/api#inputmediaphoto
|
||||
"""
|
||||
|
||||
type: str = Field(InputMediaType.PHOTO, const=True)
|
||||
type: Literal[InputMediaType.PHOTO] = InputMediaType.PHOTO
|
||||
"""Type of the result, must be *photo*"""
|
||||
media: Union[str, InputFile]
|
||||
"""File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass 'attach://<file_attach_name>' to upload a new one using multipart/form-data under <file_attach_name> name. :ref:`More information on Sending Files » <sending-files>`"""
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, List, Optional, Union
|
||||
|
||||
from pydantic import Field
|
||||
from typing import TYPE_CHECKING, List, Literal, Optional, Union
|
||||
|
||||
from ..enums import InputMediaType
|
||||
from .base import UNSET_PARSE_MODE
|
||||
|
|
@ -20,7 +18,7 @@ class InputMediaVideo(InputMedia):
|
|||
Source: https://core.telegram.org/bots/api#inputmediavideo
|
||||
"""
|
||||
|
||||
type: str = Field(InputMediaType.VIDEO, const=True)
|
||||
type: Literal[InputMediaType.VIDEO] = InputMediaType.VIDEO
|
||||
"""Type of the result, must be *video*"""
|
||||
media: Union[str, InputFile]
|
||||
"""File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass 'attach://<file_attach_name>' to upload a new one using multipart/form-data under <file_attach_name> name. :ref:`More information on Sending Files » <sending-files>`"""
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from pydantic import Field
|
||||
from typing import Literal
|
||||
|
||||
from ..enums import MenuButtonType
|
||||
from .menu_button import MenuButton
|
||||
|
|
@ -13,5 +13,5 @@ class MenuButtonCommands(MenuButton):
|
|||
Source: https://core.telegram.org/bots/api#menubuttoncommands
|
||||
"""
|
||||
|
||||
type: str = Field(MenuButtonType.COMMANDS, const=True)
|
||||
type: Literal[MenuButtonType.COMMANDS] = MenuButtonType.COMMANDS
|
||||
"""Type of the button, must be *commands*"""
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from pydantic import Field
|
||||
from typing import Literal
|
||||
|
||||
from ..enums import MenuButtonType
|
||||
from .menu_button import MenuButton
|
||||
|
|
@ -13,5 +13,5 @@ class MenuButtonDefault(MenuButton):
|
|||
Source: https://core.telegram.org/bots/api#menubuttondefault
|
||||
"""
|
||||
|
||||
type: str = Field(MenuButtonType.DEFAULT, const=True)
|
||||
type: Literal[MenuButtonType.DEFAULT] = MenuButtonType.DEFAULT
|
||||
"""Type of the button, must be *default*"""
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from pydantic import Field
|
||||
from typing import TYPE_CHECKING, Literal
|
||||
|
||||
from ..enums import MenuButtonType
|
||||
from .menu_button import MenuButton
|
||||
|
|
@ -18,7 +16,7 @@ class MenuButtonWebApp(MenuButton):
|
|||
Source: https://core.telegram.org/bots/api#menubuttonwebapp
|
||||
"""
|
||||
|
||||
type: str = Field(MenuButtonType.WEB_APP, const=True)
|
||||
type: Literal[MenuButtonType.WEB_APP] = MenuButtonType.WEB_APP
|
||||
"""Type of the button, must be *web_app*"""
|
||||
text: str
|
||||
"""Text on the button"""
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from pydantic import Field
|
||||
from typing import Literal
|
||||
|
||||
from .passport_element_error import PassportElementError
|
||||
|
||||
|
|
@ -12,7 +12,7 @@ class PassportElementErrorDataField(PassportElementError):
|
|||
Source: https://core.telegram.org/bots/api#passportelementerrordatafield
|
||||
"""
|
||||
|
||||
source: str = Field("data", const=True)
|
||||
source: Literal["data"] = "data"
|
||||
"""Error source, must be *data*"""
|
||||
type: str
|
||||
"""The section of the user's Telegram Passport which has the error, one of 'personal_details', 'passport', 'driver_license', 'identity_card', 'internal_passport', 'address'"""
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from pydantic import Field
|
||||
from typing import Literal
|
||||
|
||||
from .passport_element_error import PassportElementError
|
||||
|
||||
|
|
@ -12,7 +12,7 @@ class PassportElementErrorFile(PassportElementError):
|
|||
Source: https://core.telegram.org/bots/api#passportelementerrorfile
|
||||
"""
|
||||
|
||||
source: str = Field("file", const=True)
|
||||
source: Literal["file"] = "file"
|
||||
"""Error source, must be *file*"""
|
||||
type: str
|
||||
"""The section of the user's Telegram Passport which has the issue, one of 'utility_bill', 'bank_statement', 'rental_agreement', 'passport_registration', 'temporary_registration'"""
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import List
|
||||
|
||||
from pydantic import Field
|
||||
from typing import List, Literal
|
||||
|
||||
from .passport_element_error import PassportElementError
|
||||
|
||||
|
|
@ -14,7 +12,7 @@ class PassportElementErrorFiles(PassportElementError):
|
|||
Source: https://core.telegram.org/bots/api#passportelementerrorfiles
|
||||
"""
|
||||
|
||||
source: str = Field("files", const=True)
|
||||
source: Literal["files"] = "files"
|
||||
"""Error source, must be *files*"""
|
||||
type: str
|
||||
"""The section of the user's Telegram Passport which has the issue, one of 'utility_bill', 'bank_statement', 'rental_agreement', 'passport_registration', 'temporary_registration'"""
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from pydantic import Field
|
||||
from typing import Literal
|
||||
|
||||
from .passport_element_error import PassportElementError
|
||||
|
||||
|
|
@ -12,7 +12,7 @@ class PassportElementErrorFrontSide(PassportElementError):
|
|||
Source: https://core.telegram.org/bots/api#passportelementerrorfrontside
|
||||
"""
|
||||
|
||||
source: str = Field("front_side", const=True)
|
||||
source: Literal["front_side"] = "front_side"
|
||||
"""Error source, must be *front_side*"""
|
||||
type: str
|
||||
"""The section of the user's Telegram Passport which has the issue, one of 'passport', 'driver_license', 'identity_card', 'internal_passport'"""
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from pydantic import Field
|
||||
from typing import Literal
|
||||
|
||||
from .passport_element_error import PassportElementError
|
||||
|
||||
|
|
@ -12,7 +12,7 @@ class PassportElementErrorReverseSide(PassportElementError):
|
|||
Source: https://core.telegram.org/bots/api#passportelementerrorreverseside
|
||||
"""
|
||||
|
||||
source: str = Field("reverse_side", const=True)
|
||||
source: Literal["reverse_side"] = "reverse_side"
|
||||
"""Error source, must be *reverse_side*"""
|
||||
type: str
|
||||
"""The section of the user's Telegram Passport which has the issue, one of 'driver_license', 'identity_card'"""
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from pydantic import Field
|
||||
from typing import Literal
|
||||
|
||||
from .passport_element_error import PassportElementError
|
||||
|
||||
|
|
@ -12,7 +12,7 @@ class PassportElementErrorSelfie(PassportElementError):
|
|||
Source: https://core.telegram.org/bots/api#passportelementerrorselfie
|
||||
"""
|
||||
|
||||
source: str = Field("selfie", const=True)
|
||||
source: Literal["selfie"] = "selfie"
|
||||
"""Error source, must be *selfie*"""
|
||||
type: str
|
||||
"""The section of the user's Telegram Passport which has the issue, one of 'passport', 'driver_license', 'identity_card', 'internal_passport'"""
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from pydantic import Field
|
||||
from typing import Literal
|
||||
|
||||
from .passport_element_error import PassportElementError
|
||||
|
||||
|
|
@ -12,7 +12,7 @@ class PassportElementErrorTranslationFile(PassportElementError):
|
|||
Source: https://core.telegram.org/bots/api#passportelementerrortranslationfile
|
||||
"""
|
||||
|
||||
source: str = Field("translation_file", const=True)
|
||||
source: Literal["translation_file"] = "translation_file"
|
||||
"""Error source, must be *translation_file*"""
|
||||
type: str
|
||||
"""Type of element of the user's Telegram Passport which has the issue, one of 'passport', 'driver_license', 'identity_card', 'internal_passport', 'utility_bill', 'bank_statement', 'rental_agreement', 'passport_registration', 'temporary_registration'"""
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import List
|
||||
|
||||
from pydantic import Field
|
||||
from typing import List, Literal
|
||||
|
||||
from .passport_element_error import PassportElementError
|
||||
|
||||
|
|
@ -14,7 +12,7 @@ class PassportElementErrorTranslationFiles(PassportElementError):
|
|||
Source: https://core.telegram.org/bots/api#passportelementerrortranslationfiles
|
||||
"""
|
||||
|
||||
source: str = Field("translation_files", const=True)
|
||||
source: Literal["translation_files"] = "translation_files"
|
||||
"""Error source, must be *translation_files*"""
|
||||
type: str
|
||||
"""Type of element of the user's Telegram Passport which has the issue, one of 'passport', 'driver_license', 'identity_card', 'internal_passport', 'utility_bill', 'bank_statement', 'rental_agreement', 'passport_registration', 'temporary_registration'"""
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from pydantic import Field
|
||||
from typing import Literal
|
||||
|
||||
from .passport_element_error import PassportElementError
|
||||
|
||||
|
|
@ -12,7 +12,7 @@ class PassportElementErrorUnspecified(PassportElementError):
|
|||
Source: https://core.telegram.org/bots/api#passportelementerrorunspecified
|
||||
"""
|
||||
|
||||
source: str = Field("unspecified", const=True)
|
||||
source: Literal["unspecified"] = "unspecified"
|
||||
"""Error source, must be *unspecified*"""
|
||||
type: str
|
||||
"""Type of element of the user's Telegram Passport which has the issue"""
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import Field
|
||||
from typing import Literal, Optional
|
||||
|
||||
from .base import MutableTelegramObject
|
||||
|
||||
|
|
@ -14,7 +12,7 @@ class ReplyKeyboardRemove(MutableTelegramObject):
|
|||
Source: https://core.telegram.org/bots/api#replykeyboardremove
|
||||
"""
|
||||
|
||||
remove_keyboard: bool = Field(True, const=True)
|
||||
remove_keyboard: Literal[True] = True
|
||||
"""Requests clients to remove the custom keyboard (user will not be able to summon this keyboard; if you want to hide the keyboard from sight but keep it accessible, use *one_time_keyboard* in :class:`aiogram.types.reply_keyboard_markup.ReplyKeyboardMarkup`)"""
|
||||
selective: Optional[bool] = None
|
||||
"""*Optional*. Use this parameter if you want to remove the keyboard for specific users only. Targets: 1) users that are @mentioned in the *text* of the :class:`aiogram.types.message.Message` object; 2) if the bot's message is a reply (has *reply_to_message_id*), sender of the original message."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue