diff --git a/.butcher/schema/schema.json b/.butcher/schema/schema.json index c3638d34..fa7a76d3 100644 --- a/.butcher/schema/schema.json +++ b/.butcher/schema/schema.json @@ -2928,9 +2928,9 @@ }, { "type": "String", - "description": "If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. May be empty, in which case just the bot's username will be inserted.\n\nNote: This offers an easy way for users to start using your bot in inline mode when they are currently in a private chat with it. Especially useful when combined with switch_pm… actions - in this case the user will be automatically returned to the chat they switched from, skipping the chat selection screen.", - "html_description": "Optional. If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. May be empty, in which case just the bot's username will be inserted.
\n
\nNote: This offers an easy way for users to start using your bot in inline mode when they are currently in a private chat with it. Especially useful when combined with switch_pm… actions - in this case the user will be automatically returned to the chat they switched from, skipping the chat selection screen.", - "rst_description": "*Optional*. If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. May be empty, in which case just the bot's username will be inserted.\n\n\n\n**Note:** This offers an easy way for users to start using your bot in `inline mode `_ when they are currently in a private chat with it. Especially useful when combined with `https://core.telegram.org/bots/api#answerinlinequery `_ *switch_pm…* actions - in this case the user will be automatically returned to the chat they switched from, skipping the chat selection screen.\n", + "description": "If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. May be empty, in which case just the bot's username will be inserted.", + "html_description": "Optional. If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. May be empty, in which case just the bot's username will be inserted.", + "rst_description": "*Optional*. If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. May be empty, in which case just the bot's username will be inserted.\n", "name": "switch_inline_query", "required": false }, @@ -9629,9 +9629,9 @@ }, { "type": "WebAppInfo", - "description": "Description of the Web App 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.", - "html_description": "Optional. Description of the Web App 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.", - "rst_description": "*Optional*. Description of the `Web App `_ 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.\n", + "description": "Description of the Web App 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 inside the Web App.", + "html_description": "Optional. Description of the Web App 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 inside the Web App.", + "rst_description": "*Optional*. Description of the `Web App `_ 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 `_ inside the Web App.\n", "name": "web_app", "required": false }, diff --git a/.butcher/types/InlineKeyboardButton/entity.json b/.butcher/types/InlineKeyboardButton/entity.json index c7919e99..9c1baae5 100644 --- a/.butcher/types/InlineKeyboardButton/entity.json +++ b/.butcher/types/InlineKeyboardButton/entity.json @@ -53,9 +53,9 @@ }, { "type": "String", - "description": "If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. May be empty, in which case just the bot's username will be inserted.\n\nNote: This offers an easy way for users to start using your bot in inline mode when they are currently in a private chat with it. Especially useful when combined with switch_pm… actions - in this case the user will be automatically returned to the chat they switched from, skipping the chat selection screen.", - "html_description": "Optional. If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. May be empty, in which case just the bot's username will be inserted.
\n
\nNote: This offers an easy way for users to start using your bot in inline mode when they are currently in a private chat with it. Especially useful when combined with switch_pm… actions - in this case the user will be automatically returned to the chat they switched from, skipping the chat selection screen.", - "rst_description": "*Optional*. If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. May be empty, in which case just the bot's username will be inserted.\n\n\n\n**Note:** This offers an easy way for users to start using your bot in `inline mode `_ when they are currently in a private chat with it. Especially useful when combined with `https://core.telegram.org/bots/api#answerinlinequery `_ *switch_pm…* actions - in this case the user will be automatically returned to the chat they switched from, skipping the chat selection screen.\n", + "description": "If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. May be empty, in which case just the bot's username will be inserted.", + "html_description": "Optional. If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. May be empty, in which case just the bot's username will be inserted.", + "rst_description": "*Optional*. If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. May be empty, in which case just the bot's username will be inserted.\n", "name": "switch_inline_query", "required": false }, diff --git a/.butcher/types/InlineQueryResultsButton/entity.json b/.butcher/types/InlineQueryResultsButton/entity.json index 169b1c2c..ce4cdf1e 100644 --- a/.butcher/types/InlineQueryResultsButton/entity.json +++ b/.butcher/types/InlineQueryResultsButton/entity.json @@ -21,9 +21,9 @@ }, { "type": "WebAppInfo", - "description": "Description of the Web App 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.", - "html_description": "Optional. Description of the Web App 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.", - "rst_description": "*Optional*. Description of the `Web App `_ 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.\n", + "description": "Description of the Web App 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 inside the Web App.", + "html_description": "Optional. Description of the Web App 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 inside the Web App.", + "rst_description": "*Optional*. Description of the `Web App `_ 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 `_ inside the Web App.\n", "name": "web_app", "required": false }, diff --git a/CHANGES/1202.misc.rst b/CHANGES/1202.misc.rst new file mode 100644 index 00000000..9aeb4099 --- /dev/null +++ b/CHANGES/1202.misc.rst @@ -0,0 +1,6 @@ +Updated `Pydantic to V2 `_ + +.. warning:: + + Be careful, not all libraries is already updated to using V2 + (for example at the time, when this warning was added FastAPI still not support V2) diff --git a/aiogram/client/session/aiohttp.py b/aiogram/client/session/aiohttp.py index c15faf7a..b4c791e8 100644 --- a/aiogram/client/session/aiohttp.py +++ b/aiogram/client/session/aiohttp.py @@ -141,7 +141,7 @@ class AiohttpSession(BaseSession): def build_form_data(self, bot: Bot, method: TelegramMethod[TelegramType]) -> FormData: form = FormData(quote_fields=False) files: Dict[str, InputFile] = {} - for key, value in method.dict().items(): + for key, value in method.model_dump(warnings=False).items(): value = self.prepare_value(value, bot=bot, files=files) if not value: continue diff --git a/aiogram/client/session/middlewares/base.py b/aiogram/client/session/middlewares/base.py index 90dcd09f..c5f3e7cf 100644 --- a/aiogram/client/session/middlewares/base.py +++ b/aiogram/client/session/middlewares/base.py @@ -1,7 +1,7 @@ from __future__ import annotations from abc import ABC, abstractmethod -from typing import TYPE_CHECKING, Awaitable, Callable, Union +from typing import TYPE_CHECKING, Protocol from aiogram.methods import Response, TelegramMethod from aiogram.methods.base import TelegramType @@ -9,16 +9,24 @@ from aiogram.methods.base import TelegramType if TYPE_CHECKING: from ...bot import Bot -NextRequestMiddlewareType = Callable[ - ["Bot", TelegramMethod[TelegramType]], Awaitable[Response[TelegramType]] -] -RequestMiddlewareType = Union[ - "BaseRequestMiddleware", - Callable[ - [NextRequestMiddlewareType[TelegramType], "Bot", TelegramMethod[TelegramType]], - Awaitable[Response[TelegramType]], - ], -] + +class NextRequestMiddlewareType(Protocol[TelegramType]): # pragma: no cover + async def __call__( + self, + bot: "Bot", + method: TelegramMethod[TelegramType], + ) -> Response[TelegramType]: + pass + + +class RequestMiddlewareType(Protocol): # pragma: no cover + async def __call__( + self, + make_request: NextRequestMiddlewareType[TelegramType], + bot: "Bot", + method: TelegramMethod[TelegramType], + ) -> Response[TelegramType]: + pass class BaseRequestMiddleware(ABC): diff --git a/aiogram/client/session/middlewares/manager.py b/aiogram/client/session/middlewares/manager.py index 0e76801e..78015309 100644 --- a/aiogram/client/session/middlewares/manager.py +++ b/aiogram/client/session/middlewares/manager.py @@ -1,68 +1,48 @@ from __future__ import annotations from functools import partial -from typing import ( - TYPE_CHECKING, - Any, - Awaitable, - Callable, - List, - Optional, - Sequence, - Union, - overload, -) +from typing import Any, Callable, List, Optional, Sequence, Union, cast, overload from aiogram.client.session.middlewares.base import ( NextRequestMiddlewareType, RequestMiddlewareType, ) -from aiogram.methods import Response -from aiogram.methods.base import TelegramMethod, TelegramType -from aiogram.types import TelegramObject - -if TYPE_CHECKING: - from aiogram import Bot +from aiogram.methods.base import TelegramType -class RequestMiddlewareManager(Sequence[RequestMiddlewareType[TelegramObject]]): +class RequestMiddlewareManager(Sequence[RequestMiddlewareType]): def __init__(self) -> None: - self._middlewares: List[RequestMiddlewareType[TelegramObject]] = [] + self._middlewares: List[RequestMiddlewareType] = [] def register( self, - middleware: RequestMiddlewareType[TelegramObject], - ) -> RequestMiddlewareType[TelegramObject]: + middleware: RequestMiddlewareType, + ) -> RequestMiddlewareType: self._middlewares.append(middleware) return middleware - def unregister(self, middleware: RequestMiddlewareType[TelegramObject]) -> None: + def unregister(self, middleware: RequestMiddlewareType) -> None: self._middlewares.remove(middleware) def __call__( self, - middleware: Optional[RequestMiddlewareType[TelegramObject]] = None, - ) -> Union[ - Callable[[RequestMiddlewareType[TelegramObject]], RequestMiddlewareType[TelegramObject]], - RequestMiddlewareType[TelegramObject], - ]: + middleware: Optional[RequestMiddlewareType] = None, + ) -> Union[Callable[[RequestMiddlewareType], RequestMiddlewareType], RequestMiddlewareType,]: if middleware is None: return self.register return self.register(middleware) @overload - def __getitem__(self, item: int) -> RequestMiddlewareType[TelegramObject]: + def __getitem__(self, item: int) -> RequestMiddlewareType: pass @overload - def __getitem__(self, item: slice) -> Sequence[RequestMiddlewareType[TelegramObject]]: + def __getitem__(self, item: slice) -> Sequence[RequestMiddlewareType]: pass def __getitem__( self, item: Union[int, slice] - ) -> Union[ - RequestMiddlewareType[TelegramObject], Sequence[RequestMiddlewareType[TelegramObject]] - ]: + ) -> Union[RequestMiddlewareType, Sequence[RequestMiddlewareType]]: return self._middlewares[item] def __len__(self) -> int: @@ -70,10 +50,10 @@ class RequestMiddlewareManager(Sequence[RequestMiddlewareType[TelegramObject]]): def wrap_middlewares( self, - callback: Callable[[Bot, TelegramMethod[TelegramType]], Awaitable[Response[TelegramType]]], + callback: NextRequestMiddlewareType[TelegramType], **kwargs: Any, ) -> NextRequestMiddlewareType[TelegramType]: middleware = partial(callback, **kwargs) for m in reversed(self._middlewares): - middleware = partial(m, middleware) # type: ignore - return middleware + middleware = partial(m, middleware) + return cast(NextRequestMiddlewareType[TelegramType], middleware) diff --git a/aiogram/dispatcher/middlewares/user_context.py b/aiogram/dispatcher/middlewares/user_context.py index 9ede4334..12bb4864 100644 --- a/aiogram/dispatcher/middlewares/user_context.py +++ b/aiogram/dispatcher/middlewares/user_context.py @@ -1,5 +1,4 @@ -from contextlib import contextmanager -from typing import Any, Awaitable, Callable, Dict, Iterator, Optional, Tuple +from typing import Any, Awaitable, Callable, Dict, Optional, Tuple from aiogram.dispatcher.middlewares.base import BaseMiddleware from aiogram.types import Chat, TelegramObject, Update, User diff --git a/aiogram/filters/callback_data.py b/aiogram/filters/callback_data.py index 05d7783d..96c8f3af 100644 --- a/aiogram/filters/callback_data.py +++ b/aiogram/filters/callback_data.py @@ -110,7 +110,7 @@ class CallbackData(BaseModel): :return: instance of CallbackData """ prefix, *parts = value.split(cls.__separator__) - names = cls.__fields__.keys() + names = cls.model_fields.keys() if len(parts) != len(names): raise TypeError( f"Callback data {cls.__name__!r} takes {len(names)} arguments " @@ -120,8 +120,8 @@ class CallbackData(BaseModel): raise ValueError(f"Bad prefix ({prefix!r} != {cls.__prefix__!r})") payload = {} for k, v in zip(names, parts): # type: str, Optional[str] - if field := cls.__fields__.get(k): - if v == "" and not field.required: + if field := cls.model_fields.get(k): + if v == "" and not field.is_required(): v = None payload[k] = v return cls(**payload) diff --git a/aiogram/methods/add_sticker_to_set.py b/aiogram/methods/add_sticker_to_set.py index 49759b84..2c6502a5 100644 --- a/aiogram/methods/add_sticker_to_set.py +++ b/aiogram/methods/add_sticker_to_set.py @@ -1,7 +1,5 @@ from __future__ import annotations -from typing import TYPE_CHECKING - from ..types import InputSticker from .base import TelegramMethod diff --git a/aiogram/methods/answer_callback_query.py b/aiogram/methods/answer_callback_query.py index 4b3e16fd..067c8b34 100644 --- a/aiogram/methods/answer_callback_query.py +++ b/aiogram/methods/answer_callback_query.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional +from typing import Optional from .base import TelegramMethod diff --git a/aiogram/methods/answer_inline_query.py b/aiogram/methods/answer_inline_query.py index 7b6b6d88..53eaf5be 100644 --- a/aiogram/methods/answer_inline_query.py +++ b/aiogram/methods/answer_inline_query.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, List, Optional +from typing import List, Optional from pydantic import Field @@ -32,12 +32,12 @@ class AnswerInlineQuery(TelegramMethod[bool]): """Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you don't support pagination. Offset length can't exceed 64 bytes.""" button: Optional[InlineQueryResultsButton] = None """A JSON-serialized object describing a button to be shown above inline query results""" - switch_pm_parameter: Optional[str] = Field(None, deprecated=True) + switch_pm_parameter: Optional[str] = Field(None, json_schema_extra={"deprecated": True}) """`Deep-linking `_ parameter for the /start message sent to the bot when user presses the switch button. 1-64 characters, only :code:`A-Z`, :code:`a-z`, :code:`0-9`, :code:`_` and :code:`-` are allowed. .. deprecated:: API:6.7 https://core.telegram.org/bots/api-changelog#april-21-2023""" - switch_pm_text: Optional[str] = Field(None, deprecated=True) + switch_pm_text: Optional[str] = Field(None, json_schema_extra={"deprecated": True}) """If passed, clients will display a button with specified text that switches the user to a private chat with the bot and sends the bot a start message with the parameter *switch_pm_parameter* .. deprecated:: API:6.7 diff --git a/aiogram/methods/answer_pre_checkout_query.py b/aiogram/methods/answer_pre_checkout_query.py index a87929fb..8d1679cd 100644 --- a/aiogram/methods/answer_pre_checkout_query.py +++ b/aiogram/methods/answer_pre_checkout_query.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional +from typing import Optional from .base import TelegramMethod diff --git a/aiogram/methods/answer_shipping_query.py b/aiogram/methods/answer_shipping_query.py index 4e62d0cb..81c1eaa6 100644 --- a/aiogram/methods/answer_shipping_query.py +++ b/aiogram/methods/answer_shipping_query.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, List, Optional +from typing import List, Optional from ..types import ShippingOption from .base import TelegramMethod diff --git a/aiogram/methods/answer_web_app_query.py b/aiogram/methods/answer_web_app_query.py index d45e249d..8bb1abc8 100644 --- a/aiogram/methods/answer_web_app_query.py +++ b/aiogram/methods/answer_web_app_query.py @@ -1,7 +1,5 @@ from __future__ import annotations -from typing import TYPE_CHECKING - from ..types import InlineQueryResult, SentWebAppMessage from .base import TelegramMethod diff --git a/aiogram/methods/approve_chat_join_request.py b/aiogram/methods/approve_chat_join_request.py index 83e34599..4e4693f8 100644 --- a/aiogram/methods/approve_chat_join_request.py +++ b/aiogram/methods/approve_chat_join_request.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Union +from typing import Union from .base import TelegramMethod diff --git a/aiogram/methods/ban_chat_member.py b/aiogram/methods/ban_chat_member.py index ecc468ee..f64791fd 100644 --- a/aiogram/methods/ban_chat_member.py +++ b/aiogram/methods/ban_chat_member.py @@ -1,7 +1,7 @@ from __future__ import annotations import datetime -from typing import TYPE_CHECKING, Optional, Union +from typing import Optional, Union from .base import TelegramMethod diff --git a/aiogram/methods/ban_chat_sender_chat.py b/aiogram/methods/ban_chat_sender_chat.py index e63f2ecc..50d51188 100644 --- a/aiogram/methods/ban_chat_sender_chat.py +++ b/aiogram/methods/ban_chat_sender_chat.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Union +from typing import Union from .base import TelegramMethod diff --git a/aiogram/methods/base.py b/aiogram/methods/base.py index 33045bf0..53175784 100644 --- a/aiogram/methods/base.py +++ b/aiogram/methods/base.py @@ -3,8 +3,8 @@ from __future__ import annotations from abc import ABC, abstractmethod from typing import TYPE_CHECKING, Any, Dict, Generator, Generic, Optional, TypeVar -from pydantic import BaseConfig, BaseModel, Extra, root_validator -from pydantic.generics import GenericModel +from pydantic import BaseModel, ConfigDict +from pydantic.functional_validators import model_validator from ..types import InputFile, ResponseParameters from ..types.base import UNSET_TYPE @@ -16,16 +16,15 @@ TelegramType = TypeVar("TelegramType", bound=Any) class Request(BaseModel): + model_config = ConfigDict(arbitrary_types_allowed=True) + method: str data: Dict[str, Optional[Any]] files: Optional[Dict[str, InputFile]] - class Config(BaseConfig): - arbitrary_types_allowed = True - -class Response(GenericModel, Generic[TelegramType]): +class Response(BaseModel, Generic[TelegramType]): ok: bool result: Optional[TelegramType] = None description: Optional[str] = None @@ -33,16 +32,14 @@ class Response(GenericModel, Generic[TelegramType]): parameters: Optional[ResponseParameters] = None -class TelegramMethod(ABC, BaseModel, Generic[TelegramType]): - class Config(BaseConfig): - # use_enum_values = True - extra = Extra.allow - allow_population_by_field_name = True - arbitrary_types_allowed = True - orm_mode = True - smart_union = True # https://github.com/aiogram/aiogram/issues/901 +class TelegramMethod(BaseModel, Generic[TelegramType], ABC): + model_config = ConfigDict( + extra="allow", + populate_by_name=True, + arbitrary_types_allowed=True, + ) - @root_validator(pre=True) + @model_validator(mode="before") def remove_unset(cls, values: Dict[str, Any]) -> Dict[str, Any]: """ Remove UNSET before fields validation. @@ -64,12 +61,6 @@ class TelegramMethod(ABC, BaseModel, Generic[TelegramType]): def __api_method__(self) -> str: pass - def dict(self, **kwargs: Any) -> Any: - # override dict of pydantic.BaseModel to overcome exporting request_timeout field - exclude = kwargs.pop("exclude", set()) - - return super().dict(exclude=exclude, **kwargs) - def build_response(self, data: Dict[str, Any]) -> Response[TelegramType]: # noinspection PyTypeChecker return Response[self.__returning__](**data) # type: ignore @@ -77,8 +68,6 @@ class TelegramMethod(ABC, BaseModel, Generic[TelegramType]): async def emit(self, bot: Bot) -> TelegramType: return await bot(self) - as_ = emit - def __await__(self) -> Generator[Any, None, TelegramType]: from aiogram.client.bot import Bot diff --git a/aiogram/methods/close.py b/aiogram/methods/close.py index c8e9008d..7c33eca3 100644 --- a/aiogram/methods/close.py +++ b/aiogram/methods/close.py @@ -1,7 +1,5 @@ from __future__ import annotations -from typing import TYPE_CHECKING - from .base import TelegramMethod diff --git a/aiogram/methods/close_forum_topic.py b/aiogram/methods/close_forum_topic.py index 7ab5a479..3f9f50ea 100644 --- a/aiogram/methods/close_forum_topic.py +++ b/aiogram/methods/close_forum_topic.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Union +from typing import Union from .base import TelegramMethod diff --git a/aiogram/methods/close_general_forum_topic.py b/aiogram/methods/close_general_forum_topic.py index bc44bde5..3c836177 100644 --- a/aiogram/methods/close_general_forum_topic.py +++ b/aiogram/methods/close_general_forum_topic.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Union +from typing import Union from .base import TelegramMethod diff --git a/aiogram/methods/copy_message.py b/aiogram/methods/copy_message.py index 5e34bb7d..4fc4b5b9 100644 --- a/aiogram/methods/copy_message.py +++ b/aiogram/methods/copy_message.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, List, Optional, Union +from typing import List, Optional, Union from ..types import ( UNSET_PARSE_MODE, diff --git a/aiogram/methods/create_chat_invite_link.py b/aiogram/methods/create_chat_invite_link.py index 539115bb..1bdae992 100644 --- a/aiogram/methods/create_chat_invite_link.py +++ b/aiogram/methods/create_chat_invite_link.py @@ -1,7 +1,7 @@ from __future__ import annotations import datetime -from typing import TYPE_CHECKING, Optional, Union +from typing import Optional, Union from ..types import ChatInviteLink from .base import TelegramMethod diff --git a/aiogram/methods/create_forum_topic.py b/aiogram/methods/create_forum_topic.py index f4b3f4da..ece98d43 100644 --- a/aiogram/methods/create_forum_topic.py +++ b/aiogram/methods/create_forum_topic.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional, Union +from typing import Optional, Union from ..types import ForumTopic from .base import TelegramMethod diff --git a/aiogram/methods/create_invoice_link.py b/aiogram/methods/create_invoice_link.py index de6497c1..8b6fc883 100644 --- a/aiogram/methods/create_invoice_link.py +++ b/aiogram/methods/create_invoice_link.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, List, Optional +from typing import List, Optional from ..types import LabeledPrice from .base import TelegramMethod diff --git a/aiogram/methods/create_new_sticker_set.py b/aiogram/methods/create_new_sticker_set.py index 6406df81..abf25d79 100644 --- a/aiogram/methods/create_new_sticker_set.py +++ b/aiogram/methods/create_new_sticker_set.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, List, Optional +from typing import List, Optional from ..types import InputSticker from .base import TelegramMethod diff --git a/aiogram/methods/decline_chat_join_request.py b/aiogram/methods/decline_chat_join_request.py index 7861b7bb..0334c299 100644 --- a/aiogram/methods/decline_chat_join_request.py +++ b/aiogram/methods/decline_chat_join_request.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Union +from typing import Union from .base import TelegramMethod diff --git a/aiogram/methods/delete_chat_photo.py b/aiogram/methods/delete_chat_photo.py index 11a3836e..e146cdac 100644 --- a/aiogram/methods/delete_chat_photo.py +++ b/aiogram/methods/delete_chat_photo.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Union +from typing import Union from .base import TelegramMethod diff --git a/aiogram/methods/delete_chat_sticker_set.py b/aiogram/methods/delete_chat_sticker_set.py index 681293df..2162f860 100644 --- a/aiogram/methods/delete_chat_sticker_set.py +++ b/aiogram/methods/delete_chat_sticker_set.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Union +from typing import Union from .base import TelegramMethod diff --git a/aiogram/methods/delete_forum_topic.py b/aiogram/methods/delete_forum_topic.py index 4733c67d..1e4f9b46 100644 --- a/aiogram/methods/delete_forum_topic.py +++ b/aiogram/methods/delete_forum_topic.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Union +from typing import Union from .base import TelegramMethod diff --git a/aiogram/methods/delete_message.py b/aiogram/methods/delete_message.py index 468411d5..99c972d7 100644 --- a/aiogram/methods/delete_message.py +++ b/aiogram/methods/delete_message.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Union +from typing import Union from .base import TelegramMethod diff --git a/aiogram/methods/delete_my_commands.py b/aiogram/methods/delete_my_commands.py index d73814db..5fc1044e 100644 --- a/aiogram/methods/delete_my_commands.py +++ b/aiogram/methods/delete_my_commands.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional +from typing import Optional from ..types import BotCommandScope from .base import TelegramMethod diff --git a/aiogram/methods/delete_sticker_from_set.py b/aiogram/methods/delete_sticker_from_set.py index 96219c15..1ab3e3a8 100644 --- a/aiogram/methods/delete_sticker_from_set.py +++ b/aiogram/methods/delete_sticker_from_set.py @@ -1,7 +1,5 @@ from __future__ import annotations -from typing import TYPE_CHECKING - from .base import TelegramMethod diff --git a/aiogram/methods/delete_sticker_set.py b/aiogram/methods/delete_sticker_set.py index d5a0f67e..27b4cfc2 100644 --- a/aiogram/methods/delete_sticker_set.py +++ b/aiogram/methods/delete_sticker_set.py @@ -1,7 +1,5 @@ from __future__ import annotations -from typing import TYPE_CHECKING - from .base import TelegramMethod diff --git a/aiogram/methods/delete_webhook.py b/aiogram/methods/delete_webhook.py index b9d6cd7b..ef1bdc88 100644 --- a/aiogram/methods/delete_webhook.py +++ b/aiogram/methods/delete_webhook.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional +from typing import Optional from .base import TelegramMethod diff --git a/aiogram/methods/edit_chat_invite_link.py b/aiogram/methods/edit_chat_invite_link.py index 26f4ccc3..f94111ed 100644 --- a/aiogram/methods/edit_chat_invite_link.py +++ b/aiogram/methods/edit_chat_invite_link.py @@ -1,7 +1,7 @@ from __future__ import annotations import datetime -from typing import TYPE_CHECKING, Optional, Union +from typing import Optional, Union from ..types import ChatInviteLink from .base import TelegramMethod diff --git a/aiogram/methods/edit_forum_topic.py b/aiogram/methods/edit_forum_topic.py index f87d0cea..46ef0e58 100644 --- a/aiogram/methods/edit_forum_topic.py +++ b/aiogram/methods/edit_forum_topic.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional, Union +from typing import Optional, Union from .base import TelegramMethod diff --git a/aiogram/methods/edit_general_forum_topic.py b/aiogram/methods/edit_general_forum_topic.py index f35c2048..1de088cf 100644 --- a/aiogram/methods/edit_general_forum_topic.py +++ b/aiogram/methods/edit_general_forum_topic.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Union +from typing import Union from .base import TelegramMethod diff --git a/aiogram/methods/edit_message_caption.py b/aiogram/methods/edit_message_caption.py index 66cdeac9..ee2f8482 100644 --- a/aiogram/methods/edit_message_caption.py +++ b/aiogram/methods/edit_message_caption.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, List, Optional, Union +from typing import List, Optional, Union from ..types import UNSET_PARSE_MODE, InlineKeyboardMarkup, Message, MessageEntity from .base import TelegramMethod diff --git a/aiogram/methods/edit_message_live_location.py b/aiogram/methods/edit_message_live_location.py index e35c3225..43ff24e7 100644 --- a/aiogram/methods/edit_message_live_location.py +++ b/aiogram/methods/edit_message_live_location.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional, Union +from typing import Optional, Union from ..types import InlineKeyboardMarkup, Message from .base import TelegramMethod diff --git a/aiogram/methods/edit_message_media.py b/aiogram/methods/edit_message_media.py index f986a841..f6ab0166 100644 --- a/aiogram/methods/edit_message_media.py +++ b/aiogram/methods/edit_message_media.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional, Union +from typing import Optional, Union from ..types import InlineKeyboardMarkup, InputMedia, Message from .base import TelegramMethod diff --git a/aiogram/methods/edit_message_reply_markup.py b/aiogram/methods/edit_message_reply_markup.py index a828c9d8..7c8be63f 100644 --- a/aiogram/methods/edit_message_reply_markup.py +++ b/aiogram/methods/edit_message_reply_markup.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional, Union +from typing import Optional, Union from ..types import InlineKeyboardMarkup, Message from .base import TelegramMethod diff --git a/aiogram/methods/edit_message_text.py b/aiogram/methods/edit_message_text.py index 79887c97..357a757b 100644 --- a/aiogram/methods/edit_message_text.py +++ b/aiogram/methods/edit_message_text.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, List, Optional, Union +from typing import List, Optional, Union from ..types import UNSET_PARSE_MODE, InlineKeyboardMarkup, Message, MessageEntity from ..types.base import UNSET_DISABLE_WEB_PAGE_PREVIEW diff --git a/aiogram/methods/export_chat_invite_link.py b/aiogram/methods/export_chat_invite_link.py index ba4436ed..61642387 100644 --- a/aiogram/methods/export_chat_invite_link.py +++ b/aiogram/methods/export_chat_invite_link.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Union +from typing import Union from .base import TelegramMethod diff --git a/aiogram/methods/forward_message.py b/aiogram/methods/forward_message.py index 45c084a0..86d33f8d 100644 --- a/aiogram/methods/forward_message.py +++ b/aiogram/methods/forward_message.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional, Union +from typing import Optional, Union from ..types import Message from ..types.base import UNSET_PROTECT_CONTENT diff --git a/aiogram/methods/get_chat.py b/aiogram/methods/get_chat.py index a565529a..d0416238 100644 --- a/aiogram/methods/get_chat.py +++ b/aiogram/methods/get_chat.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Union +from typing import Union from ..types import Chat from .base import TelegramMethod diff --git a/aiogram/methods/get_chat_administrators.py b/aiogram/methods/get_chat_administrators.py index 3e0cac3c..b6479ec8 100644 --- a/aiogram/methods/get_chat_administrators.py +++ b/aiogram/methods/get_chat_administrators.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, List, Union +from typing import List, Union from ..types import ( ChatMemberAdministrator, diff --git a/aiogram/methods/get_chat_member.py b/aiogram/methods/get_chat_member.py index ab308024..9e8ba619 100644 --- a/aiogram/methods/get_chat_member.py +++ b/aiogram/methods/get_chat_member.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Union +from typing import Union from ..types import ( ChatMemberAdministrator, diff --git a/aiogram/methods/get_chat_member_count.py b/aiogram/methods/get_chat_member_count.py index c1b08e5b..a411d0c9 100644 --- a/aiogram/methods/get_chat_member_count.py +++ b/aiogram/methods/get_chat_member_count.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Union +from typing import Union from .base import TelegramMethod diff --git a/aiogram/methods/get_chat_menu_button.py b/aiogram/methods/get_chat_menu_button.py index 6679d5df..df280b66 100644 --- a/aiogram/methods/get_chat_menu_button.py +++ b/aiogram/methods/get_chat_menu_button.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional, Union +from typing import Optional, Union from ..types import MenuButtonCommands, MenuButtonDefault, MenuButtonWebApp from .base import TelegramMethod diff --git a/aiogram/methods/get_custom_emoji_stickers.py b/aiogram/methods/get_custom_emoji_stickers.py index 3522b539..a98582d9 100644 --- a/aiogram/methods/get_custom_emoji_stickers.py +++ b/aiogram/methods/get_custom_emoji_stickers.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, List +from typing import List from ..types import Sticker from .base import TelegramMethod diff --git a/aiogram/methods/get_file.py b/aiogram/methods/get_file.py index b84ff940..8358e250 100644 --- a/aiogram/methods/get_file.py +++ b/aiogram/methods/get_file.py @@ -1,7 +1,5 @@ from __future__ import annotations -from typing import TYPE_CHECKING - from ..types import File from .base import TelegramMethod diff --git a/aiogram/methods/get_forum_topic_icon_stickers.py b/aiogram/methods/get_forum_topic_icon_stickers.py index 31965661..5c233215 100644 --- a/aiogram/methods/get_forum_topic_icon_stickers.py +++ b/aiogram/methods/get_forum_topic_icon_stickers.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, List +from typing import List from ..types import Sticker from .base import TelegramMethod diff --git a/aiogram/methods/get_game_high_scores.py b/aiogram/methods/get_game_high_scores.py index aff1c56a..1251658c 100644 --- a/aiogram/methods/get_game_high_scores.py +++ b/aiogram/methods/get_game_high_scores.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, List, Optional +from typing import List, Optional from ..types import GameHighScore from .base import TelegramMethod diff --git a/aiogram/methods/get_me.py b/aiogram/methods/get_me.py index 1a7f1fe1..c2cc52f9 100644 --- a/aiogram/methods/get_me.py +++ b/aiogram/methods/get_me.py @@ -1,7 +1,5 @@ from __future__ import annotations -from typing import TYPE_CHECKING - from ..types import User from .base import TelegramMethod diff --git a/aiogram/methods/get_my_commands.py b/aiogram/methods/get_my_commands.py index d1e5c9c3..9d4a696f 100644 --- a/aiogram/methods/get_my_commands.py +++ b/aiogram/methods/get_my_commands.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, List, Optional +from typing import List, Optional from ..types import BotCommand, BotCommandScope from .base import TelegramMethod diff --git a/aiogram/methods/get_my_default_administrator_rights.py b/aiogram/methods/get_my_default_administrator_rights.py index d20e7a15..1c7c0195 100644 --- a/aiogram/methods/get_my_default_administrator_rights.py +++ b/aiogram/methods/get_my_default_administrator_rights.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional +from typing import Optional from ..types import ChatAdministratorRights from .base import TelegramMethod diff --git a/aiogram/methods/get_my_description.py b/aiogram/methods/get_my_description.py index 3b0534ff..db002daa 100644 --- a/aiogram/methods/get_my_description.py +++ b/aiogram/methods/get_my_description.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional +from typing import Optional from ..types import BotDescription from .base import TelegramMethod diff --git a/aiogram/methods/get_my_short_description.py b/aiogram/methods/get_my_short_description.py index 81731142..962642e4 100644 --- a/aiogram/methods/get_my_short_description.py +++ b/aiogram/methods/get_my_short_description.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional +from typing import Optional from ..types import BotShortDescription from .base import TelegramMethod diff --git a/aiogram/methods/get_sticker_set.py b/aiogram/methods/get_sticker_set.py index 87041172..43ab5311 100644 --- a/aiogram/methods/get_sticker_set.py +++ b/aiogram/methods/get_sticker_set.py @@ -1,7 +1,5 @@ from __future__ import annotations -from typing import TYPE_CHECKING - from ..types import StickerSet from .base import TelegramMethod diff --git a/aiogram/methods/get_updates.py b/aiogram/methods/get_updates.py index b22c9755..80abf78c 100644 --- a/aiogram/methods/get_updates.py +++ b/aiogram/methods/get_updates.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, List, Optional +from typing import List, Optional from ..types import Update from .base import TelegramMethod diff --git a/aiogram/methods/get_user_profile_photos.py b/aiogram/methods/get_user_profile_photos.py index 47abc196..e58bd970 100644 --- a/aiogram/methods/get_user_profile_photos.py +++ b/aiogram/methods/get_user_profile_photos.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional +from typing import Optional from ..types import UserProfilePhotos from .base import TelegramMethod diff --git a/aiogram/methods/get_webhook_info.py b/aiogram/methods/get_webhook_info.py index 5e4e194c..c9f0e46f 100644 --- a/aiogram/methods/get_webhook_info.py +++ b/aiogram/methods/get_webhook_info.py @@ -1,7 +1,5 @@ from __future__ import annotations -from typing import TYPE_CHECKING - from ..types import WebhookInfo from .base import TelegramMethod diff --git a/aiogram/methods/hide_general_forum_topic.py b/aiogram/methods/hide_general_forum_topic.py index 2587cf9e..25e6421b 100644 --- a/aiogram/methods/hide_general_forum_topic.py +++ b/aiogram/methods/hide_general_forum_topic.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Union +from typing import Union from .base import TelegramMethod diff --git a/aiogram/methods/leave_chat.py b/aiogram/methods/leave_chat.py index 5b2e15cf..f1784f65 100644 --- a/aiogram/methods/leave_chat.py +++ b/aiogram/methods/leave_chat.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Union +from typing import Union from .base import TelegramMethod diff --git a/aiogram/methods/log_out.py b/aiogram/methods/log_out.py index 3f3ea3de..2a626535 100644 --- a/aiogram/methods/log_out.py +++ b/aiogram/methods/log_out.py @@ -1,7 +1,5 @@ from __future__ import annotations -from typing import TYPE_CHECKING - from .base import TelegramMethod diff --git a/aiogram/methods/pin_chat_message.py b/aiogram/methods/pin_chat_message.py index d1641eea..24e7a7c1 100644 --- a/aiogram/methods/pin_chat_message.py +++ b/aiogram/methods/pin_chat_message.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional, Union +from typing import Optional, Union from .base import TelegramMethod diff --git a/aiogram/methods/promote_chat_member.py b/aiogram/methods/promote_chat_member.py index d8f6096f..c74d1de9 100644 --- a/aiogram/methods/promote_chat_member.py +++ b/aiogram/methods/promote_chat_member.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional, Union +from typing import Optional, Union from .base import TelegramMethod diff --git a/aiogram/methods/reopen_forum_topic.py b/aiogram/methods/reopen_forum_topic.py index efe1c31d..729db37c 100644 --- a/aiogram/methods/reopen_forum_topic.py +++ b/aiogram/methods/reopen_forum_topic.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Union +from typing import Union from .base import TelegramMethod diff --git a/aiogram/methods/reopen_general_forum_topic.py b/aiogram/methods/reopen_general_forum_topic.py index 381278a9..ea3a4a47 100644 --- a/aiogram/methods/reopen_general_forum_topic.py +++ b/aiogram/methods/reopen_general_forum_topic.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Union +from typing import Union from .base import TelegramMethod diff --git a/aiogram/methods/restrict_chat_member.py b/aiogram/methods/restrict_chat_member.py index efea2f97..9240ea60 100644 --- a/aiogram/methods/restrict_chat_member.py +++ b/aiogram/methods/restrict_chat_member.py @@ -1,7 +1,7 @@ from __future__ import annotations import datetime -from typing import TYPE_CHECKING, Optional, Union +from typing import Optional, Union from ..types import ChatPermissions from .base import TelegramMethod diff --git a/aiogram/methods/revoke_chat_invite_link.py b/aiogram/methods/revoke_chat_invite_link.py index ad31e77d..e7d9c50e 100644 --- a/aiogram/methods/revoke_chat_invite_link.py +++ b/aiogram/methods/revoke_chat_invite_link.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Union +from typing import Union from ..types import ChatInviteLink from .base import TelegramMethod diff --git a/aiogram/methods/send_animation.py b/aiogram/methods/send_animation.py index 14029d25..088ce252 100644 --- a/aiogram/methods/send_animation.py +++ b/aiogram/methods/send_animation.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, List, Optional, Union +from typing import List, Optional, Union from ..types import ( UNSET_PARSE_MODE, diff --git a/aiogram/methods/send_audio.py b/aiogram/methods/send_audio.py index e0f4b900..e947cbde 100644 --- a/aiogram/methods/send_audio.py +++ b/aiogram/methods/send_audio.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, List, Optional, Union +from typing import List, Optional, Union from ..types import ( UNSET_PARSE_MODE, diff --git a/aiogram/methods/send_chat_action.py b/aiogram/methods/send_chat_action.py index d21dc68c..009fea09 100644 --- a/aiogram/methods/send_chat_action.py +++ b/aiogram/methods/send_chat_action.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional, Union +from typing import Optional, Union from .base import TelegramMethod diff --git a/aiogram/methods/send_contact.py b/aiogram/methods/send_contact.py index 35473338..d0454674 100644 --- a/aiogram/methods/send_contact.py +++ b/aiogram/methods/send_contact.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional, Union +from typing import Optional, Union from ..types import ( ForceReply, diff --git a/aiogram/methods/send_dice.py b/aiogram/methods/send_dice.py index 9fa2ce70..bc58d53a 100644 --- a/aiogram/methods/send_dice.py +++ b/aiogram/methods/send_dice.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional, Union +from typing import Optional, Union from ..types import ( ForceReply, diff --git a/aiogram/methods/send_document.py b/aiogram/methods/send_document.py index 5c83beb3..cacb62a5 100644 --- a/aiogram/methods/send_document.py +++ b/aiogram/methods/send_document.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, List, Optional, Union +from typing import List, Optional, Union from ..types import ( UNSET_PARSE_MODE, diff --git a/aiogram/methods/send_game.py b/aiogram/methods/send_game.py index ab55a459..f713d6a6 100644 --- a/aiogram/methods/send_game.py +++ b/aiogram/methods/send_game.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional +from typing import Optional from ..types import InlineKeyboardMarkup, Message from ..types.base import UNSET_PROTECT_CONTENT diff --git a/aiogram/methods/send_invoice.py b/aiogram/methods/send_invoice.py index d08002a9..aca8aa71 100644 --- a/aiogram/methods/send_invoice.py +++ b/aiogram/methods/send_invoice.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, List, Optional, Union +from typing import List, Optional, Union from ..types import InlineKeyboardMarkup, LabeledPrice, Message from ..types.base import UNSET_PROTECT_CONTENT diff --git a/aiogram/methods/send_location.py b/aiogram/methods/send_location.py index 845b4741..ddfb3604 100644 --- a/aiogram/methods/send_location.py +++ b/aiogram/methods/send_location.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional, Union +from typing import Optional, Union from ..types import ( ForceReply, diff --git a/aiogram/methods/send_media_group.py b/aiogram/methods/send_media_group.py index fd8dbb25..a01e4de8 100644 --- a/aiogram/methods/send_media_group.py +++ b/aiogram/methods/send_media_group.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, List, Optional, Union +from typing import List, Optional, Union from ..types import ( InputMediaAudio, diff --git a/aiogram/methods/send_message.py b/aiogram/methods/send_message.py index 9b7dae7b..1e460239 100644 --- a/aiogram/methods/send_message.py +++ b/aiogram/methods/send_message.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, List, Optional, Union +from typing import List, Optional, Union from ..types import ( UNSET_PARSE_MODE, diff --git a/aiogram/methods/send_photo.py b/aiogram/methods/send_photo.py index 236d8710..6ce9d928 100644 --- a/aiogram/methods/send_photo.py +++ b/aiogram/methods/send_photo.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, List, Optional, Union +from typing import List, Optional, Union from ..types import ( UNSET_PARSE_MODE, diff --git a/aiogram/methods/send_poll.py b/aiogram/methods/send_poll.py index fca3dc58..41d7e4c5 100644 --- a/aiogram/methods/send_poll.py +++ b/aiogram/methods/send_poll.py @@ -1,7 +1,7 @@ from __future__ import annotations import datetime -from typing import TYPE_CHECKING, List, Optional, Union +from typing import List, Optional, Union from ..types import ( UNSET_PARSE_MODE, diff --git a/aiogram/methods/send_sticker.py b/aiogram/methods/send_sticker.py index 8429b105..384a5adb 100644 --- a/aiogram/methods/send_sticker.py +++ b/aiogram/methods/send_sticker.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional, Union +from typing import Optional, Union from ..types import ( ForceReply, diff --git a/aiogram/methods/send_venue.py b/aiogram/methods/send_venue.py index d0859770..ac69fdc6 100644 --- a/aiogram/methods/send_venue.py +++ b/aiogram/methods/send_venue.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional, Union +from typing import Optional, Union from ..types import ( ForceReply, diff --git a/aiogram/methods/send_video.py b/aiogram/methods/send_video.py index a894e335..1ee7c903 100644 --- a/aiogram/methods/send_video.py +++ b/aiogram/methods/send_video.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, List, Optional, Union +from typing import List, Optional, Union from ..types import ( UNSET_PARSE_MODE, diff --git a/aiogram/methods/send_video_note.py b/aiogram/methods/send_video_note.py index 761c91a2..cd270e94 100644 --- a/aiogram/methods/send_video_note.py +++ b/aiogram/methods/send_video_note.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional, Union +from typing import Optional, Union from ..types import ( ForceReply, diff --git a/aiogram/methods/send_voice.py b/aiogram/methods/send_voice.py index ae692ad6..d9c915f4 100644 --- a/aiogram/methods/send_voice.py +++ b/aiogram/methods/send_voice.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, List, Optional, Union +from typing import List, Optional, Union from ..types import ( UNSET_PARSE_MODE, diff --git a/aiogram/methods/set_chat_administrator_custom_title.py b/aiogram/methods/set_chat_administrator_custom_title.py index edf79d8c..5415594f 100644 --- a/aiogram/methods/set_chat_administrator_custom_title.py +++ b/aiogram/methods/set_chat_administrator_custom_title.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Union +from typing import Union from .base import TelegramMethod diff --git a/aiogram/methods/set_chat_description.py b/aiogram/methods/set_chat_description.py index 05b51a69..81eaf263 100644 --- a/aiogram/methods/set_chat_description.py +++ b/aiogram/methods/set_chat_description.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional, Union +from typing import Optional, Union from .base import TelegramMethod diff --git a/aiogram/methods/set_chat_menu_button.py b/aiogram/methods/set_chat_menu_button.py index 6eeb3a10..4fdd086b 100644 --- a/aiogram/methods/set_chat_menu_button.py +++ b/aiogram/methods/set_chat_menu_button.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional, Union +from typing import Optional, Union from ..types import MenuButtonCommands, MenuButtonDefault, MenuButtonWebApp from .base import TelegramMethod diff --git a/aiogram/methods/set_chat_permissions.py b/aiogram/methods/set_chat_permissions.py index af13ddb7..3c3ed008 100644 --- a/aiogram/methods/set_chat_permissions.py +++ b/aiogram/methods/set_chat_permissions.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional, Union +from typing import Optional, Union from ..types import ChatPermissions from .base import TelegramMethod diff --git a/aiogram/methods/set_chat_photo.py b/aiogram/methods/set_chat_photo.py index ba7b8de3..dc07a445 100644 --- a/aiogram/methods/set_chat_photo.py +++ b/aiogram/methods/set_chat_photo.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Union +from typing import Union from ..types import InputFile from .base import TelegramMethod diff --git a/aiogram/methods/set_chat_sticker_set.py b/aiogram/methods/set_chat_sticker_set.py index a7f3d216..6df42a0a 100644 --- a/aiogram/methods/set_chat_sticker_set.py +++ b/aiogram/methods/set_chat_sticker_set.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Union +from typing import Union from .base import TelegramMethod diff --git a/aiogram/methods/set_chat_title.py b/aiogram/methods/set_chat_title.py index 07507d0f..b4ce0a4a 100644 --- a/aiogram/methods/set_chat_title.py +++ b/aiogram/methods/set_chat_title.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Union +from typing import Union from .base import TelegramMethod diff --git a/aiogram/methods/set_custom_emoji_sticker_set_thumbnail.py b/aiogram/methods/set_custom_emoji_sticker_set_thumbnail.py index 10a4a267..8c8fa479 100644 --- a/aiogram/methods/set_custom_emoji_sticker_set_thumbnail.py +++ b/aiogram/methods/set_custom_emoji_sticker_set_thumbnail.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional +from typing import Optional from .base import TelegramMethod diff --git a/aiogram/methods/set_game_score.py b/aiogram/methods/set_game_score.py index 170988ec..590ca59d 100644 --- a/aiogram/methods/set_game_score.py +++ b/aiogram/methods/set_game_score.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional, Union +from typing import Optional, Union from ..types import Message from .base import TelegramMethod diff --git a/aiogram/methods/set_my_commands.py b/aiogram/methods/set_my_commands.py index a62e7a84..c668852d 100644 --- a/aiogram/methods/set_my_commands.py +++ b/aiogram/methods/set_my_commands.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, List, Optional +from typing import List, Optional from ..types import BotCommand, BotCommandScope from .base import TelegramMethod diff --git a/aiogram/methods/set_my_default_administrator_rights.py b/aiogram/methods/set_my_default_administrator_rights.py index 0b1468bc..8817a9dc 100644 --- a/aiogram/methods/set_my_default_administrator_rights.py +++ b/aiogram/methods/set_my_default_administrator_rights.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional +from typing import Optional from ..types import ChatAdministratorRights from .base import TelegramMethod diff --git a/aiogram/methods/set_my_description.py b/aiogram/methods/set_my_description.py index 2af2ed44..fba6b8d3 100644 --- a/aiogram/methods/set_my_description.py +++ b/aiogram/methods/set_my_description.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional +from typing import Optional from .base import TelegramMethod diff --git a/aiogram/methods/set_my_short_description.py b/aiogram/methods/set_my_short_description.py index 19e5b254..0c697d4b 100644 --- a/aiogram/methods/set_my_short_description.py +++ b/aiogram/methods/set_my_short_description.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional +from typing import Optional from .base import TelegramMethod diff --git a/aiogram/methods/set_passport_data_errors.py b/aiogram/methods/set_passport_data_errors.py index ae127d2b..f829fa47 100644 --- a/aiogram/methods/set_passport_data_errors.py +++ b/aiogram/methods/set_passport_data_errors.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, List +from typing import List from ..types import PassportElementError from .base import TelegramMethod diff --git a/aiogram/methods/set_sticker_emoji_list.py b/aiogram/methods/set_sticker_emoji_list.py index f23033c7..b88f609e 100644 --- a/aiogram/methods/set_sticker_emoji_list.py +++ b/aiogram/methods/set_sticker_emoji_list.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, List +from typing import List from .base import TelegramMethod diff --git a/aiogram/methods/set_sticker_keywords.py b/aiogram/methods/set_sticker_keywords.py index 0ebef118..1179613b 100644 --- a/aiogram/methods/set_sticker_keywords.py +++ b/aiogram/methods/set_sticker_keywords.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, List, Optional +from typing import List, Optional from .base import TelegramMethod diff --git a/aiogram/methods/set_sticker_mask_position.py b/aiogram/methods/set_sticker_mask_position.py index f3147f2d..7e82b061 100644 --- a/aiogram/methods/set_sticker_mask_position.py +++ b/aiogram/methods/set_sticker_mask_position.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional +from typing import Optional from ..types import MaskPosition from .base import TelegramMethod diff --git a/aiogram/methods/set_sticker_position_in_set.py b/aiogram/methods/set_sticker_position_in_set.py index ed5792ae..395d2e05 100644 --- a/aiogram/methods/set_sticker_position_in_set.py +++ b/aiogram/methods/set_sticker_position_in_set.py @@ -1,7 +1,5 @@ from __future__ import annotations -from typing import TYPE_CHECKING - from .base import TelegramMethod diff --git a/aiogram/methods/set_sticker_set_thumbnail.py b/aiogram/methods/set_sticker_set_thumbnail.py index 7da1c397..3624bce4 100644 --- a/aiogram/methods/set_sticker_set_thumbnail.py +++ b/aiogram/methods/set_sticker_set_thumbnail.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional, Union +from typing import Optional, Union from ..types import InputFile from .base import TelegramMethod diff --git a/aiogram/methods/set_sticker_set_title.py b/aiogram/methods/set_sticker_set_title.py index 978432ff..1136353f 100644 --- a/aiogram/methods/set_sticker_set_title.py +++ b/aiogram/methods/set_sticker_set_title.py @@ -1,7 +1,5 @@ from __future__ import annotations -from typing import TYPE_CHECKING - from .base import TelegramMethod diff --git a/aiogram/methods/set_webhook.py b/aiogram/methods/set_webhook.py index 6e63a75a..66ec86ff 100644 --- a/aiogram/methods/set_webhook.py +++ b/aiogram/methods/set_webhook.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, List, Optional +from typing import List, Optional from ..types import InputFile from .base import TelegramMethod diff --git a/aiogram/methods/stop_message_live_location.py b/aiogram/methods/stop_message_live_location.py index 8a16f586..9361dfae 100644 --- a/aiogram/methods/stop_message_live_location.py +++ b/aiogram/methods/stop_message_live_location.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional, Union +from typing import Optional, Union from ..types import InlineKeyboardMarkup, Message from .base import TelegramMethod diff --git a/aiogram/methods/stop_poll.py b/aiogram/methods/stop_poll.py index 19ef26ac..2e93f087 100644 --- a/aiogram/methods/stop_poll.py +++ b/aiogram/methods/stop_poll.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional, Union +from typing import Optional, Union from ..types import InlineKeyboardMarkup, Poll from .base import TelegramMethod diff --git a/aiogram/methods/unban_chat_member.py b/aiogram/methods/unban_chat_member.py index 768eea22..19ef9ef7 100644 --- a/aiogram/methods/unban_chat_member.py +++ b/aiogram/methods/unban_chat_member.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional, Union +from typing import Optional, Union from .base import TelegramMethod diff --git a/aiogram/methods/unban_chat_sender_chat.py b/aiogram/methods/unban_chat_sender_chat.py index fbd3f1d3..e81278d3 100644 --- a/aiogram/methods/unban_chat_sender_chat.py +++ b/aiogram/methods/unban_chat_sender_chat.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Union +from typing import Union from .base import TelegramMethod diff --git a/aiogram/methods/unhide_general_forum_topic.py b/aiogram/methods/unhide_general_forum_topic.py index 82524758..cebcec25 100644 --- a/aiogram/methods/unhide_general_forum_topic.py +++ b/aiogram/methods/unhide_general_forum_topic.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Union +from typing import Union from .base import TelegramMethod diff --git a/aiogram/methods/unpin_all_chat_messages.py b/aiogram/methods/unpin_all_chat_messages.py index f8566e33..76927e63 100644 --- a/aiogram/methods/unpin_all_chat_messages.py +++ b/aiogram/methods/unpin_all_chat_messages.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Union +from typing import Union from .base import TelegramMethod diff --git a/aiogram/methods/unpin_all_forum_topic_messages.py b/aiogram/methods/unpin_all_forum_topic_messages.py index 6b735e98..09729e2c 100644 --- a/aiogram/methods/unpin_all_forum_topic_messages.py +++ b/aiogram/methods/unpin_all_forum_topic_messages.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Union +from typing import Union from .base import TelegramMethod diff --git a/aiogram/methods/unpin_chat_message.py b/aiogram/methods/unpin_chat_message.py index 0d5d2b0a..3fb70154 100644 --- a/aiogram/methods/unpin_chat_message.py +++ b/aiogram/methods/unpin_chat_message.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional, Union +from typing import Optional, Union from .base import TelegramMethod diff --git a/aiogram/methods/upload_sticker_file.py b/aiogram/methods/upload_sticker_file.py index 2194e35f..fd1a229e 100644 --- a/aiogram/methods/upload_sticker_file.py +++ b/aiogram/methods/upload_sticker_file.py @@ -1,7 +1,5 @@ from __future__ import annotations -from typing import TYPE_CHECKING - from ..types import File, InputFile from .base import TelegramMethod diff --git a/aiogram/types/__init__.py b/aiogram/types/__init__.py index 4808f7fe..a669cbe8 100644 --- a/aiogram/types/__init__.py +++ b/aiogram/types/__init__.py @@ -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 diff --git a/aiogram/types/base.py b/aiogram/types/base.py index 707e328c..a9d3eb1a 100644 --- a/aiogram/types/base.py +++ b/aiogram/types/base.py @@ -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 diff --git a/aiogram/types/bot_command_scope_all_chat_administrators.py b/aiogram/types/bot_command_scope_all_chat_administrators.py index e9f6a969..ed3dd181 100644 --- a/aiogram/types/bot_command_scope_all_chat_administrators.py +++ b/aiogram/types/bot_command_scope_all_chat_administrators.py @@ -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*""" diff --git a/aiogram/types/bot_command_scope_all_group_chats.py b/aiogram/types/bot_command_scope_all_group_chats.py index f9675ad6..3393266a 100644 --- a/aiogram/types/bot_command_scope_all_group_chats.py +++ b/aiogram/types/bot_command_scope_all_group_chats.py @@ -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*""" diff --git a/aiogram/types/bot_command_scope_all_private_chats.py b/aiogram/types/bot_command_scope_all_private_chats.py index f13e2866..c53303d1 100644 --- a/aiogram/types/bot_command_scope_all_private_chats.py +++ b/aiogram/types/bot_command_scope_all_private_chats.py @@ -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*""" diff --git a/aiogram/types/bot_command_scope_chat.py b/aiogram/types/bot_command_scope_chat.py index d96bc6f4..f0ef7b58 100644 --- a/aiogram/types/bot_command_scope_chat.py +++ b/aiogram/types/bot_command_scope_chat.py @@ -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`)""" diff --git a/aiogram/types/bot_command_scope_chat_administrators.py b/aiogram/types/bot_command_scope_chat_administrators.py index 824dc5a1..65513db2 100644 --- a/aiogram/types/bot_command_scope_chat_administrators.py +++ b/aiogram/types/bot_command_scope_chat_administrators.py @@ -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`)""" diff --git a/aiogram/types/bot_command_scope_chat_member.py b/aiogram/types/bot_command_scope_chat_member.py index e9fb0dda..efb97870 100644 --- a/aiogram/types/bot_command_scope_chat_member.py +++ b/aiogram/types/bot_command_scope_chat_member.py @@ -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`)""" diff --git a/aiogram/types/bot_command_scope_default.py b/aiogram/types/bot_command_scope_default.py index 79825631..449665c9 100644 --- a/aiogram/types/bot_command_scope_default.py +++ b/aiogram/types/bot_command_scope_default.py @@ -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*""" diff --git a/aiogram/types/chat_member_administrator.py b/aiogram/types/chat_member_administrator.py index 94fc76c3..ae98e79d 100644 --- a/aiogram/types/chat_member_administrator.py +++ b/aiogram/types/chat_member_administrator.py @@ -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""" diff --git a/aiogram/types/chat_member_banned.py b/aiogram/types/chat_member_banned.py index 85c07f51..33e85f45 100644 --- a/aiogram/types/chat_member_banned.py +++ b/aiogram/types/chat_member_banned.py @@ -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""" diff --git a/aiogram/types/chat_member_left.py b/aiogram/types/chat_member_left.py index 6d7968c1..af501917 100644 --- a/aiogram/types/chat_member_left.py +++ b/aiogram/types/chat_member_left.py @@ -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""" diff --git a/aiogram/types/chat_member_member.py b/aiogram/types/chat_member_member.py index 303a7d9d..e2c7418e 100644 --- a/aiogram/types/chat_member_member.py +++ b/aiogram/types/chat_member_member.py @@ -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""" diff --git a/aiogram/types/chat_member_owner.py b/aiogram/types/chat_member_owner.py index e7c64fc1..66450550 100644 --- a/aiogram/types/chat_member_owner.py +++ b/aiogram/types/chat_member_owner.py @@ -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""" diff --git a/aiogram/types/chat_member_restricted.py b/aiogram/types/chat_member_restricted.py index b6f4f556..17db73fb 100644 --- a/aiogram/types/chat_member_restricted.py +++ b/aiogram/types/chat_member_restricted.py @@ -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""" diff --git a/aiogram/types/error_event.py b/aiogram/types/error_event.py index 1667d9e9..212bee56 100644 --- a/aiogram/types/error_event.py +++ b/aiogram/types/error_event.py @@ -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 diff --git a/aiogram/types/force_reply.py b/aiogram/types/force_reply.py index c27af31e..cd13b658 100644 --- a/aiogram/types/force_reply.py +++ b/aiogram/types/force_reply.py @@ -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""" diff --git a/aiogram/types/inline_query_result_article.py b/aiogram/types/inline_query_result_article.py index dd65b595..be084aed 100644 --- a/aiogram/types/inline_query_result_article.py +++ b/aiogram/types/inline_query_result_article.py @@ -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""" diff --git a/aiogram/types/inline_query_result_audio.py b/aiogram/types/inline_query_result_audio.py index 3b830fc8..74cea130 100644 --- a/aiogram/types/inline_query_result_audio.py +++ b/aiogram/types/inline_query_result_audio.py @@ -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""" diff --git a/aiogram/types/inline_query_result_cached_audio.py b/aiogram/types/inline_query_result_cached_audio.py index 8358f723..8d4819cc 100644 --- a/aiogram/types/inline_query_result_cached_audio.py +++ b/aiogram/types/inline_query_result_cached_audio.py @@ -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""" diff --git a/aiogram/types/inline_query_result_cached_document.py b/aiogram/types/inline_query_result_cached_document.py index 5513971f..cedb45a8 100644 --- a/aiogram/types/inline_query_result_cached_document.py +++ b/aiogram/types/inline_query_result_cached_document.py @@ -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""" diff --git a/aiogram/types/inline_query_result_cached_gif.py b/aiogram/types/inline_query_result_cached_gif.py index 7aa5c535..acbcb6fa 100644 --- a/aiogram/types/inline_query_result_cached_gif.py +++ b/aiogram/types/inline_query_result_cached_gif.py @@ -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""" diff --git a/aiogram/types/inline_query_result_cached_mpeg4_gif.py b/aiogram/types/inline_query_result_cached_mpeg4_gif.py index 539de025..f9605d68 100644 --- a/aiogram/types/inline_query_result_cached_mpeg4_gif.py +++ b/aiogram/types/inline_query_result_cached_mpeg4_gif.py @@ -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""" diff --git a/aiogram/types/inline_query_result_cached_photo.py b/aiogram/types/inline_query_result_cached_photo.py index fc892826..96b6d208 100644 --- a/aiogram/types/inline_query_result_cached_photo.py +++ b/aiogram/types/inline_query_result_cached_photo.py @@ -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""" diff --git a/aiogram/types/inline_query_result_cached_sticker.py b/aiogram/types/inline_query_result_cached_sticker.py index 3d75c29c..27f95c09 100644 --- a/aiogram/types/inline_query_result_cached_sticker.py +++ b/aiogram/types/inline_query_result_cached_sticker.py @@ -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""" diff --git a/aiogram/types/inline_query_result_cached_video.py b/aiogram/types/inline_query_result_cached_video.py index acda3962..c1afd26e 100644 --- a/aiogram/types/inline_query_result_cached_video.py +++ b/aiogram/types/inline_query_result_cached_video.py @@ -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""" diff --git a/aiogram/types/inline_query_result_cached_voice.py b/aiogram/types/inline_query_result_cached_voice.py index 3f03b2fe..354b6f39 100644 --- a/aiogram/types/inline_query_result_cached_voice.py +++ b/aiogram/types/inline_query_result_cached_voice.py @@ -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""" diff --git a/aiogram/types/inline_query_result_contact.py b/aiogram/types/inline_query_result_contact.py index 0f88bb9f..121dfba9 100644 --- a/aiogram/types/inline_query_result_contact.py +++ b/aiogram/types/inline_query_result_contact.py @@ -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""" diff --git a/aiogram/types/inline_query_result_document.py b/aiogram/types/inline_query_result_document.py index 7698e4c6..13a4e7c5 100644 --- a/aiogram/types/inline_query_result_document.py +++ b/aiogram/types/inline_query_result_document.py @@ -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""" diff --git a/aiogram/types/inline_query_result_game.py b/aiogram/types/inline_query_result_game.py index e4d92a61..b5ae90fc 100644 --- a/aiogram/types/inline_query_result_game.py +++ b/aiogram/types/inline_query_result_game.py @@ -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""" diff --git a/aiogram/types/inline_query_result_gif.py b/aiogram/types/inline_query_result_gif.py index b38cfa1a..1120369f 100644 --- a/aiogram/types/inline_query_result_gif.py +++ b/aiogram/types/inline_query_result_gif.py @@ -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""" diff --git a/aiogram/types/inline_query_result_location.py b/aiogram/types/inline_query_result_location.py index aa1f6d88..1dbda6a8 100644 --- a/aiogram/types/inline_query_result_location.py +++ b/aiogram/types/inline_query_result_location.py @@ -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""" diff --git a/aiogram/types/inline_query_result_mpeg4_gif.py b/aiogram/types/inline_query_result_mpeg4_gif.py index 06c73620..d14491c6 100644 --- a/aiogram/types/inline_query_result_mpeg4_gif.py +++ b/aiogram/types/inline_query_result_mpeg4_gif.py @@ -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""" diff --git a/aiogram/types/inline_query_result_photo.py b/aiogram/types/inline_query_result_photo.py index 6ed85276..086118f0 100644 --- a/aiogram/types/inline_query_result_photo.py +++ b/aiogram/types/inline_query_result_photo.py @@ -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""" diff --git a/aiogram/types/inline_query_result_venue.py b/aiogram/types/inline_query_result_venue.py index 0c92a008..6f0aeb66 100644 --- a/aiogram/types/inline_query_result_venue.py +++ b/aiogram/types/inline_query_result_venue.py @@ -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""" diff --git a/aiogram/types/inline_query_result_video.py b/aiogram/types/inline_query_result_video.py index ba14d066..b1c6775e 100644 --- a/aiogram/types/inline_query_result_video.py +++ b/aiogram/types/inline_query_result_video.py @@ -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""" diff --git a/aiogram/types/inline_query_result_voice.py b/aiogram/types/inline_query_result_voice.py index 7de1f6cf..e97a994e 100644 --- a/aiogram/types/inline_query_result_voice.py +++ b/aiogram/types/inline_query_result_voice.py @@ -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""" diff --git a/aiogram/types/inline_query_results_button.py b/aiogram/types/inline_query_results_button.py index 4a8f59df..0a6db30c 100644 --- a/aiogram/types/inline_query_results_button.py +++ b/aiogram/types/inline_query_results_button.py @@ -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 `_ 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 `_ 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 `_ inside the Web App.""" start_parameter: Optional[str] = None """*Optional*. `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.""" diff --git a/aiogram/types/input_file.py b/aiogram/types/input_file.py index 8b74fe03..e13c3379 100644 --- a/aiogram/types/input_file.py +++ b/aiogram/types/input_file.py @@ -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"" diff --git a/aiogram/types/input_media_animation.py b/aiogram/types/input_media_animation.py index eabc4b5e..f0e1b860 100644 --- a/aiogram/types/input_media_animation.py +++ b/aiogram/types/input_media_animation.py @@ -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://' to upload a new one using multipart/form-data under name. :ref:`More information on Sending Files » `""" diff --git a/aiogram/types/input_media_audio.py b/aiogram/types/input_media_audio.py index 8de62a6f..4bfa74c2 100644 --- a/aiogram/types/input_media_audio.py +++ b/aiogram/types/input_media_audio.py @@ -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://' to upload a new one using multipart/form-data under name. :ref:`More information on Sending Files » `""" diff --git a/aiogram/types/input_media_document.py b/aiogram/types/input_media_document.py index 9ef4d52f..b749cdcb 100644 --- a/aiogram/types/input_media_document.py +++ b/aiogram/types/input_media_document.py @@ -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://' to upload a new one using multipart/form-data under name. :ref:`More information on Sending Files » `""" diff --git a/aiogram/types/input_media_photo.py b/aiogram/types/input_media_photo.py index 0f9500e8..9128627b 100644 --- a/aiogram/types/input_media_photo.py +++ b/aiogram/types/input_media_photo.py @@ -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://' to upload a new one using multipart/form-data under name. :ref:`More information on Sending Files » `""" diff --git a/aiogram/types/input_media_video.py b/aiogram/types/input_media_video.py index 89d4df91..b7479607 100644 --- a/aiogram/types/input_media_video.py +++ b/aiogram/types/input_media_video.py @@ -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://' to upload a new one using multipart/form-data under name. :ref:`More information on Sending Files » `""" diff --git a/aiogram/types/menu_button_commands.py b/aiogram/types/menu_button_commands.py index 62a9061c..e37e48cd 100644 --- a/aiogram/types/menu_button_commands.py +++ b/aiogram/types/menu_button_commands.py @@ -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*""" diff --git a/aiogram/types/menu_button_default.py b/aiogram/types/menu_button_default.py index dc754ec0..7b68803e 100644 --- a/aiogram/types/menu_button_default.py +++ b/aiogram/types/menu_button_default.py @@ -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*""" diff --git a/aiogram/types/menu_button_web_app.py b/aiogram/types/menu_button_web_app.py index f77ed2ea..ab908afe 100644 --- a/aiogram/types/menu_button_web_app.py +++ b/aiogram/types/menu_button_web_app.py @@ -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""" diff --git a/aiogram/types/passport_element_error_data_field.py b/aiogram/types/passport_element_error_data_field.py index f5b0b67b..370a100a 100644 --- a/aiogram/types/passport_element_error_data_field.py +++ b/aiogram/types/passport_element_error_data_field.py @@ -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'""" diff --git a/aiogram/types/passport_element_error_file.py b/aiogram/types/passport_element_error_file.py index 217deaaa..e2016dd9 100644 --- a/aiogram/types/passport_element_error_file.py +++ b/aiogram/types/passport_element_error_file.py @@ -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'""" diff --git a/aiogram/types/passport_element_error_files.py b/aiogram/types/passport_element_error_files.py index 6f42d693..4b97c095 100644 --- a/aiogram/types/passport_element_error_files.py +++ b/aiogram/types/passport_element_error_files.py @@ -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'""" diff --git a/aiogram/types/passport_element_error_front_side.py b/aiogram/types/passport_element_error_front_side.py index 98e60acd..4d46cc94 100644 --- a/aiogram/types/passport_element_error_front_side.py +++ b/aiogram/types/passport_element_error_front_side.py @@ -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'""" diff --git a/aiogram/types/passport_element_error_reverse_side.py b/aiogram/types/passport_element_error_reverse_side.py index 0c6073ba..7584f567 100644 --- a/aiogram/types/passport_element_error_reverse_side.py +++ b/aiogram/types/passport_element_error_reverse_side.py @@ -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'""" diff --git a/aiogram/types/passport_element_error_selfie.py b/aiogram/types/passport_element_error_selfie.py index 4a3b2fe1..37cd1c95 100644 --- a/aiogram/types/passport_element_error_selfie.py +++ b/aiogram/types/passport_element_error_selfie.py @@ -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'""" diff --git a/aiogram/types/passport_element_error_translation_file.py b/aiogram/types/passport_element_error_translation_file.py index d4106453..92b82ad6 100644 --- a/aiogram/types/passport_element_error_translation_file.py +++ b/aiogram/types/passport_element_error_translation_file.py @@ -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'""" diff --git a/aiogram/types/passport_element_error_translation_files.py b/aiogram/types/passport_element_error_translation_files.py index df0db64f..a9dbece8 100644 --- a/aiogram/types/passport_element_error_translation_files.py +++ b/aiogram/types/passport_element_error_translation_files.py @@ -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'""" diff --git a/aiogram/types/passport_element_error_unspecified.py b/aiogram/types/passport_element_error_unspecified.py index 39d0c417..c287f96c 100644 --- a/aiogram/types/passport_element_error_unspecified.py +++ b/aiogram/types/passport_element_error_unspecified.py @@ -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""" diff --git a/aiogram/types/reply_keyboard_remove.py b/aiogram/types/reply_keyboard_remove.py index 1e2c2da9..0260ab6c 100644 --- a/aiogram/types/reply_keyboard_remove.py +++ b/aiogram/types/reply_keyboard_remove.py @@ -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.""" diff --git a/aiogram/utils/i18n/middleware.py b/aiogram/utils/i18n/middleware.py index 5968cf8a..68be22bc 100644 --- a/aiogram/utils/i18n/middleware.py +++ b/aiogram/utils/i18n/middleware.py @@ -1,5 +1,5 @@ from abc import ABC, abstractmethod -from typing import Any, Awaitable, Callable, Dict, Optional, Set, cast +from typing import Any, Awaitable, Callable, Dict, Optional, Set try: from babel import Locale, UnknownLocaleError diff --git a/pyproject.toml b/pyproject.toml index 8c926c6d..c0642a0a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,9 +42,9 @@ classifiers = [ dependencies = [ "magic-filter~=1.0.9", "aiohttp~=3.8.4", - "pydantic~=1.10.7", + "pydantic~=2.0.0", "aiofiles~=23.1.0", - "certifi>=2022.9.24", + "certifi>=2023.5.7", ] dynamic = ["version"] @@ -65,7 +65,7 @@ i18n = [ "Babel~=2.12.1", ] test = [ - "pytest~=7.3.1", + "pytest~=7.4.0", "pytest-html~=3.2.0", "pytest-asyncio~=0.21.0", "pytest-lazy-fixture~=0.6.3", @@ -94,13 +94,13 @@ docs = [ dev = [ "black~=23.3.0", "isort~=5.11", - "ruff~=0.0.262", - "mypy~=1.2.0", + "ruff~=0.0.275", + "mypy~=1.4.1", "toml~=0.10.2", - "pre-commit~=3.2.2", - "towncrier~=22.12.0", + "pre-commit~=3.3.3", + "towncrier~=23.6.0", "packaging~=23.0", - "typing-extensions~=4.5.0", + "typing-extensions~=4.6.0", ] [project.urls] @@ -149,7 +149,7 @@ features = [ "test", ] extra-dependencies = [ - "butcher @ git+https://github.com/aiogram/butcher.git@v0.1.14" + "butcher @ git+https://github.com/aiogram/butcher.git@v0.1.15" ] [tool.hatch.envs.dev.scripts] diff --git a/tests/test_api/test_methods/test_send_message.py b/tests/test_api/test_methods/test_send_message.py index 0210d73f..1458ed4e 100644 --- a/tests/test_api/test_methods/test_send_message.py +++ b/tests/test_api/test_methods/test_send_message.py @@ -1,7 +1,7 @@ import datetime from aiogram.methods import Request, SendMessage -from aiogram.types import Chat, ForceReply, Message +from aiogram.types import Chat, ForceReply, Message, ReplyKeyboardRemove from tests.mocked_bot import MockedBot @@ -24,5 +24,11 @@ class TestSendMessage: async def test_force_reply(self): # https://github.com/aiogram/aiogram/issues/901 + print("::::", SendMessage.__pydantic_core_schema__) method = SendMessage(text="test", chat_id=42, reply_markup=ForceReply()) assert isinstance(method.reply_markup, ForceReply) + + async def test_reply_keyboard_remove(self): + # https://github.com/aiogram/aiogram/issues/901 + method = SendMessage(text="test", chat_id=42, reply_markup=ReplyKeyboardRemove()) + assert isinstance(method.reply_markup, ReplyKeyboardRemove) diff --git a/tests/test_filters/test_chat_member_updated.py b/tests/test_filters/test_chat_member_updated.py index f3fdce66..8592792c 100644 --- a/tests/test_filters/test_chat_member_updated.py +++ b/tests/test_filters/test_chat_member_updated.py @@ -12,7 +12,16 @@ from aiogram.filters.chat_member_updated import ( _MemberStatusMarker, _MemberStatusTransition, ) -from aiogram.types import Chat, ChatMember, ChatMemberUpdated, User +from aiogram.types import ( + Chat, + ChatMember, + ChatMemberAdministrator, + ChatMemberLeft, + ChatMemberMember, + ChatMemberRestricted, + ChatMemberUpdated, + User, +) class TestMemberStatusMarker: @@ -267,84 +276,91 @@ class TestMemberStatusTransition: class TestChatMemberUpdatedStatusFilter: + USER = User(id=42, first_name="Test", is_bot=False) + PARAMS = { + "user": USER, + "until_date": datetime.now(), + "is_anonymous": True, + "custom_title": "title", + "can_be_edited": True, + "can_manage_chat": True, + "can_delete_messages": True, + "can_manage_video_chats": True, + "can_restrict_members": True, + "can_promote_members": True, + "can_change_info": True, + "can_invite_users": True, + "can_post_messages": True, + "can_edit_messages": True, + "can_pin_messages": True, + "can_manage_topics": True, + "can_send_messages": True, + "can_send_audios": True, + "can_send_documents": True, + "can_send_photos": True, + "can_send_videos": True, + "can_send_video_notes": True, + "can_send_voice_notes": True, + "can_send_polls": True, + "can_send_other_messages": True, + "can_add_web_page_previews": True, + } + @pytest.mark.parametrize( "transition,old,new,result", [ - [JOIN_TRANSITION, ChatMember(status="left"), ChatMember(status="member"), True], [ JOIN_TRANSITION, - ChatMember(status="restricted", is_member=True), - ChatMember(status="member"), - False, - ], - [ - JOIN_TRANSITION, - ChatMember(status="restricted", is_member=False), - ChatMember(status="member"), + ChatMemberLeft(status="left", **PARAMS), + ChatMemberMember(status="member", **PARAMS), True, ], [ JOIN_TRANSITION, - ChatMember(status="member"), - ChatMember(status="restricted", is_member=False), + ChatMemberRestricted(status="restricted", is_member=True, **PARAMS), + ChatMemberMember(status="member", **PARAMS), + False, + ], + [ + JOIN_TRANSITION, + ChatMemberRestricted(status="restricted", is_member=False, **PARAMS), + ChatMemberMember(status="member", **PARAMS), + True, + ], + [ + JOIN_TRANSITION, + ChatMemberMember(status="member", **PARAMS), + ChatMemberRestricted(status="restricted", is_member=False, **PARAMS), False, ], [ LEAVE_TRANSITION, - ChatMember(status="member"), - ChatMember(status="restricted", is_member=False), + ChatMemberMember(status="member", **PARAMS), + ChatMemberRestricted(status="restricted", is_member=False, **PARAMS), True, ], [ ADMINISTRATOR, - ChatMember(status="member"), - ChatMember(status="administrator"), + ChatMemberMember(status="member", **PARAMS), + ChatMemberAdministrator(status="administrator", **PARAMS), True, ], [ IS_MEMBER, - ChatMember(status="restricted", is_member=False), - ChatMember(status="member"), + ChatMemberRestricted(status="restricted", is_member=False, **PARAMS), + ChatMemberMember(status="member", **PARAMS), True, ], ], ) async def test_call(self, transition, old, new, result): updated_filter = ChatMemberUpdatedFilter(member_status_changed=transition) - user = User(id=42, first_name="Test", is_bot=False) - update = { - "user": user, - "until_date": datetime.now(), - "is_anonymous": True, - "custom_title": True, - "can_be_edited": True, - "can_manage_chat": True, - "can_delete_messages": True, - "can_manage_video_chats": True, - "can_restrict_members": True, - "can_promote_members": True, - "can_change_info": True, - "can_invite_users": True, - "can_post_messages": True, - "can_edit_messages": True, - "can_pin_messages": True, - "can_manage_topics": True, - "can_send_messages": True, - "can_send_audios": True, - "can_send_documents": True, - "can_send_photos": True, - "can_send_videos": True, - "can_send_video_notes": True, - "can_send_voice_notes": True, - "can_send_polls": True, - "can_send_other_messages": True, - "can_add_web_page_previews": True, - } + event = ChatMemberUpdated( chat=Chat(id=42, type="test"), - from_user=user, - old_chat_member=old.copy(update=update), - new_chat_member=new.copy(update=update), + from_user=self.USER, + old_chat_member=old, + new_chat_member=new, date=datetime.now(), )