pre-commit autoupdate (#3824)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
This commit is contained in:
pre-commit-ci[bot] 2023-08-02 11:51:17 +02:00 committed by GitHub
parent ed3acd4b81
commit aaadc70fcc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 66 additions and 60 deletions

View file

@ -6,14 +6,14 @@ ci:
repos:
- repo: https://github.com/psf/black
rev: 23.3.0
rev: 23.7.0
hooks:
- id: black
args:
- --diff
- --check
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
rev: 6.1.0
hooks:
- id: flake8
- repo: https://github.com/PyCQA/pylint
@ -62,7 +62,7 @@ repos:
- cachetools~=5.3.1
- . # this basically does `pip install -e .`
- repo: https://github.com/asottile/pyupgrade
rev: v3.8.0
rev: v3.10.1
hooks:
- id: pyupgrade
files: ^(telegram|examples|tests|docs)/.*\.py$
@ -77,7 +77,7 @@ repos:
- --diff
- --check
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.0.277'
rev: 'v0.0.281'
hooks:
- id: ruff
name: ruff

View file

@ -12,7 +12,7 @@ target-version = "py38"
show-fixes = true
ignore = ["PLR2004", "PLR0911", "PLR0912", "PLR0913", "PLR0915", "PERF203"]
select = ["E", "F", "I", "PL", "UP", "RUF", "PTH", "C4", "B", "PIE", "SIM", "RET", "RSE",
"G", "ISC", "PT", "ASYNC", "TCH", "CPY", "SLOT", "PERF",]
"G", "ISC", "PT", "ASYNC", "TCH", "CPY", "SLOT", "PERF", "PYI"]
[tool.ruff.per-file-ignores]
"tests/*.py" = ["B018"]

View file

@ -2746,7 +2746,7 @@ class Bot(TelegramObject, AsyncContextManager["Bot"]):
if callable(results):
callable_output = results(current_offset_int)
if not callable_output:
effective_results: Sequence["InlineQueryResult"] = []
effective_results: Sequence[InlineQueryResult] = []
else:
effective_results = callable_output
# the callback *might* return more results on the next call, so we increment

View file

@ -100,7 +100,7 @@ class BotCommandScope(TelegramObject):
if not data:
return None
_class_mapping: Dict[str, Type["BotCommandScope"]] = {
_class_mapping: Dict[str, Type[BotCommandScope]] = {
cls.DEFAULT: BotCommandScopeDefault,
cls.ALL_PRIVATE_CHATS: BotCommandScopeAllPrivateChats,
cls.ALL_GROUP_CHATS: BotCommandScopeAllGroupChats,

View file

@ -111,7 +111,7 @@ class ChatMember(TelegramObject):
if not data:
return None
_class_mapping: Dict[str, Type["ChatMember"]] = {
_class_mapping: Dict[str, Type[ChatMember]] = {
cls.OWNER: ChatMemberOwner,
cls.ADMINISTRATOR: ChatMemberAdministrator,
cls.MEMBER: ChatMemberMember,

View file

@ -99,7 +99,7 @@ class File(TelegramObject):
self.file_size: Optional[int] = file_size
self.file_path: Optional[str] = file_path
self._credentials: Optional["FileCredentials"] = None
self._credentials: Optional[FileCredentials] = None
self._id_attrs = (self.file_unique_id,)

View file

@ -85,7 +85,7 @@ class MenuButton(TelegramObject):
if not data and cls is MenuButton:
return None
_class_mapping: Dict[str, Type["MenuButton"]] = {
_class_mapping: Dict[str, Type[MenuButton]] = {
cls.COMMANDS: MenuButtonCommands,
cls.WEB_APP: MenuButtonWebApp,
cls.DEFAULT: MenuButtonDefault,

View file

@ -766,8 +766,8 @@ class Message(TelegramObject):
self.edit_date: Optional[datetime.datetime] = edit_date
self.has_protected_content: Optional[bool] = has_protected_content
self.text: Optional[str] = text
self.entities: Tuple["MessageEntity", ...] = parse_sequence_arg(entities)
self.caption_entities: Tuple["MessageEntity", ...] = parse_sequence_arg(caption_entities)
self.entities: Tuple[MessageEntity, ...] = parse_sequence_arg(entities)
self.caption_entities: Tuple[MessageEntity, ...] = parse_sequence_arg(caption_entities)
self.audio: Optional[Audio] = audio
self.game: Optional[Game] = game
self.document: Optional[Document] = document

View file

@ -154,7 +154,7 @@ class EncryptedCredentials(TelegramObject):
self._id_attrs = (self.data, self.hash, self.secret)
self._decrypted_secret: Optional[str] = None
self._decrypted_data: Optional["Credentials"] = None
self._decrypted_data: Optional[Credentials] = None
self._freeze()
@ -442,8 +442,8 @@ class SecureValue(TelegramObject):
self.front_side: Optional[FileCredentials] = front_side
self.reverse_side: Optional[FileCredentials] = reverse_side
self.selfie: Optional[FileCredentials] = selfie
self.files: Tuple["FileCredentials", ...] = parse_sequence_arg(files)
self.translation: Tuple["FileCredentials", ...] = parse_sequence_arg(translation)
self.files: Tuple[FileCredentials, ...] = parse_sequence_arg(files)
self.translation: Tuple[FileCredentials, ...] = parse_sequence_arg(translation)
self._freeze()

View file

@ -68,7 +68,7 @@ class ShippingOption(TelegramObject):
self.id: str = id # pylint: disable=invalid-name
self.title: str = title
self.prices: Tuple["LabeledPrice", ...] = parse_sequence_arg(prices)
self.prices: Tuple[LabeledPrice, ...] = parse_sequence_arg(prices)
self._id_attrs = (self.id,)

View file

@ -106,7 +106,7 @@ class TelegramObject:
# classes than classes with arguments.
self._frozen: bool = False
self._id_attrs: Tuple[object, ...] = ()
self._bot: Optional["Bot"] = None
self._bot: Optional[Bot] = None
# We don't do anything with api_kwargs here - see docstring of _apply_api_kwargs
self.api_kwargs: Mapping[str, Any] = MappingProxyType(api_kwargs or {})

View file

@ -271,8 +271,8 @@ class Update(TelegramObject):
self.chat_member: Optional[ChatMemberUpdated] = chat_member
self.chat_join_request: Optional[ChatJoinRequest] = chat_join_request
self._effective_user: Optional["User"] = None
self._effective_chat: Optional["Chat"] = None
self._effective_user: Optional[User] = None
self._effective_chat: Optional[Chat] = None
self._effective_message: Optional[Message] = None
self._id_attrs = (self.update_id,)

View file

@ -294,7 +294,7 @@ class Application(Generic[BT, CCT, UD, CD, BD, JQ], AsyncContextManager["Applica
)
self.bot: BT = bot
self.update_queue: "asyncio.Queue[object]" = update_queue
self.update_queue: asyncio.Queue[object] = update_queue
self.context_types: ContextTypes[CCT, UD, CD, BD] = context_types
self.updater: Optional[Updater] = updater
self.handlers: Dict[int, List[BaseHandler[Any, CCT]]] = {}
@ -302,13 +302,13 @@ class Application(Generic[BT, CCT, UD, CD, BD, JQ], AsyncContextManager["Applica
HandlerCallback[object, CCT, None], Union[bool, DefaultValue[bool]]
] = {}
self.post_init: Optional[
Callable[["Application[BT, CCT, UD, CD, BD, JQ]"], Coroutine[Any, Any, None]]
Callable[[Application[BT, CCT, UD, CD, BD, JQ]], Coroutine[Any, Any, None]]
] = post_init
self.post_shutdown: Optional[
Callable[["Application[BT, CCT, UD, CD, BD, JQ]"], Coroutine[Any, Any, None]]
Callable[[Application[BT, CCT, UD, CD, BD, JQ]], Coroutine[Any, Any, None]]
] = post_shutdown
self.post_stop: Optional[
Callable[["Application[BT, CCT, UD, CD, BD, JQ]"], Coroutine[Any, Any, None]]
Callable[[Application[BT, CCT, UD, CD, BD, JQ]], Coroutine[Any, Any, None]]
] = post_stop
self._update_processor = update_processor
self.bot_data: BD = self.context_types.bot_data()
@ -1012,7 +1012,7 @@ class Application(Generic[BT, CCT, UD, CD, BD, JQ], AsyncContextManager["Applica
# but by passing `is_error_handler=True` from `process_error`, we can make sure that we
# get at most one recursion of the user calls `create_task` manually with an error handler
# function
task: "asyncio.Task[RT]" = asyncio.create_task(
task: asyncio.Task[RT] = asyncio.create_task(
self.__create_task_callback(
coroutine=coroutine, update=update, is_error_handler=is_error_handler
),
@ -1671,7 +1671,7 @@ class Application(Generic[BT, CCT, UD, CD, BD, JQ], AsyncContextManager["Applica
update: Optional[object],
error: Exception,
job: Optional["Job[CCT]"] = None,
coroutine: _ErrorCoroType[RT] = None, # noqa: RUF013
coroutine: _ErrorCoroType[RT] = None,
) -> bool:
"""Processes an error by passing it to all error handlers registered with
:meth:`add_error_handler`. If one of the error handlers raises

View file

@ -171,42 +171,42 @@ class ApplicationBuilder(Generic[BT, CCT, UD, CD, BD, JQ]):
self._read_timeout: ODVInput[float] = DEFAULT_NONE
self._write_timeout: ODVInput[float] = DEFAULT_NONE
self._pool_timeout: ODVInput[float] = DEFAULT_NONE
self._request: DVInput["BaseRequest"] = DEFAULT_NONE
self._request: DVInput[BaseRequest] = DEFAULT_NONE
self._get_updates_connection_pool_size: DVInput[int] = DEFAULT_NONE
self._get_updates_proxy_url: DVInput[str] = DEFAULT_NONE
self._get_updates_connect_timeout: ODVInput[float] = DEFAULT_NONE
self._get_updates_read_timeout: ODVInput[float] = DEFAULT_NONE
self._get_updates_write_timeout: ODVInput[float] = DEFAULT_NONE
self._get_updates_pool_timeout: ODVInput[float] = DEFAULT_NONE
self._get_updates_request: DVInput["BaseRequest"] = DEFAULT_NONE
self._get_updates_request: DVInput[BaseRequest] = DEFAULT_NONE
self._get_updates_http_version: DVInput[str] = DefaultValue("1.1")
self._private_key: ODVInput[bytes] = DEFAULT_NONE
self._private_key_password: ODVInput[bytes] = DEFAULT_NONE
self._defaults: ODVInput["Defaults"] = DEFAULT_NONE
self._defaults: ODVInput[Defaults] = DEFAULT_NONE
self._arbitrary_callback_data: Union[DefaultValue[bool], int] = DEFAULT_FALSE
self._local_mode: DVType[bool] = DEFAULT_FALSE
self._bot: DVInput[Bot] = DEFAULT_NONE
self._update_queue: DVType[Queue] = DefaultValue(Queue())
try:
self._job_queue: ODVInput["JobQueue"] = DefaultValue(JobQueue())
self._job_queue: ODVInput[JobQueue] = DefaultValue(JobQueue())
except RuntimeError as exc:
if "PTB must be installed via" not in str(exc):
raise exc
self._job_queue = DEFAULT_NONE
self._persistence: ODVInput["BasePersistence"] = DEFAULT_NONE
self._persistence: ODVInput[BasePersistence] = DEFAULT_NONE
self._context_types: DVType[ContextTypes] = DefaultValue(ContextTypes())
self._application_class: DVType[Type[Application]] = DefaultValue(Application)
self._application_kwargs: Dict[str, object] = {}
self._update_processor: "BaseUpdateProcessor" = SimpleUpdateProcessor(
self._update_processor: BaseUpdateProcessor = SimpleUpdateProcessor(
max_concurrent_updates=1
)
self._updater: ODVInput[Updater] = DEFAULT_NONE
self._post_init: Optional[Callable[[Application], Coroutine[Any, Any, None]]] = None
self._post_shutdown: Optional[Callable[[Application], Coroutine[Any, Any, None]]] = None
self._post_stop: Optional[Callable[[Application], Coroutine[Any, Any, None]]] = None
self._rate_limiter: ODVInput["BaseRateLimiter"] = DEFAULT_NONE
self._rate_limiter: ODVInput[BaseRateLimiter] = DEFAULT_NONE
self._http_version: DVInput[str] = DefaultValue("1.1")
def _build_request(self, get_updates: bool) -> BaseRequest:

View file

@ -144,9 +144,9 @@ class CallbackContext(Generic[BT, UD, CD, BD]):
self.args: Optional[List[str]] = None
self.matches: Optional[List[Match[str]]] = None
self.error: Optional[Exception] = None
self.job: Optional["Job[CCT]"] = None
self.job: Optional[Job[CCT]] = None
self.coroutine: Optional[
Union[Generator[Optional["Future[object]"], None, Any], Awaitable[Any]]
Union[Generator[Optional[Future[object]], None, Any], Awaitable[Any]]
] = None
@property

View file

@ -339,10 +339,10 @@ class ConversationHandler(BaseHandler[Update, CCT]):
# if conversation_timeout is used, this dict is used to schedule a job which runs when the
# conv has timed out.
self.timeout_jobs: Dict[ConversationKey, "Job[Any]"] = {}
self.timeout_jobs: Dict[ConversationKey, Job[Any]] = {}
self._timeout_jobs_lock = asyncio.Lock()
self._conversations: ConversationDict = {}
self._child_conversations: Set["ConversationHandler"] = set()
self._child_conversations: Set[ConversationHandler] = set()
if persistent and not self.name:
raise ValueError("Conversations can't be persistent when handler is unnamed.")

View file

@ -91,7 +91,7 @@ class JobQueue(Generic[CCT]):
'"python-telegram-bot[job-queue]"`.'
)
self._application: "Optional[weakref.ReferenceType[Application]]" = None
self._application: Optional[weakref.ReferenceType[Application]] = None
self._executor = AsyncIOExecutor()
self.scheduler: AsyncIOScheduler = AsyncIOScheduler(
timezone=pytz.utc, executors={"default": self._executor}

View file

@ -113,7 +113,7 @@ class Updater(AsyncContextManager["Updater"]):
update_queue: "asyncio.Queue[object]",
):
self.bot: Bot = bot
self.update_queue: "asyncio.Queue[object]" = update_queue
self.update_queue: asyncio.Queue[object] = update_queue
self._last_update_id = 0
self._running = False

View file

@ -156,7 +156,7 @@ class TestAnimationWithoutRequest(TestAnimationBase):
async def test_send_animation_custom_filename(self, bot, chat_id, animation_file, monkeypatch):
async def make_assertion(url, request_data: RequestData, *args, **kwargs):
return list(request_data.multipart_data.values())[0][0] == "custom_filename"
return next(iter(request_data.multipart_data.values()))[0] == "custom_filename"
monkeypatch.setattr(bot.request, "post", make_assertion)
assert await bot.send_animation(chat_id, animation_file, filename="custom_filename")

View file

@ -176,7 +176,7 @@ class TestAudioWithoutRequest(TestAudioBase):
async def test_send_audio_custom_filename(self, bot, chat_id, audio_file, monkeypatch):
async def make_assertion(url, request_data: RequestData, *args, **kwargs):
return list(request_data.multipart_data.values())[0][0] == "custom_filename"
return next(iter(request_data.multipart_data.values()))[0] == "custom_filename"
monkeypatch.setattr(bot.request, "post", make_assertion)
assert await bot.send_audio(chat_id, audio_file, filename="custom_filename")

View file

@ -162,7 +162,7 @@ class TestPhotoWithoutRequest(TestPhotoBase):
async def test_send_photo_custom_filename(self, bot, chat_id, photo_file, monkeypatch):
async def make_assertion(url, request_data: RequestData, *args, **kwargs):
return list(request_data.multipart_data.values())[0][0] == "custom_filename"
return next(iter(request_data.multipart_data.values()))[0] == "custom_filename"
monkeypatch.setattr(bot.request, "post", make_assertion)
assert await bot.send_photo(chat_id, photo_file, filename="custom_filename")

View file

@ -189,7 +189,7 @@ class TestVideoWithoutRequest(TestVideoBase):
async def test_send_video_custom_filename(self, bot, chat_id, video_file, monkeypatch):
async def make_assertion(url, request_data: RequestData, *args, **kwargs):
return list(request_data.multipart_data.values())[0][0] == "custom_filename"
return next(iter(request_data.multipart_data.values()))[0] == "custom_filename"
monkeypatch.setattr(bot.request, "post", make_assertion)

View file

@ -169,7 +169,7 @@ class TestVideoNoteWithoutRequest(TestVideoNoteBase):
self, bot, chat_id, video_note_file, monkeypatch
):
async def make_assertion(url, request_data: RequestData, *args, **kwargs):
return list(request_data.multipart_data.values())[0][0] == "custom_filename"
return next(iter(request_data.multipart_data.values()))[0] == "custom_filename"
monkeypatch.setattr(bot.request, "post", make_assertion)

View file

@ -129,7 +129,7 @@ class TestVoiceWithoutRequest(TestVoiceBase):
async def test_send_voice_custom_filename(self, bot, chat_id, voice_file, monkeypatch):
async def make_assertion(url, request_data: RequestData, *args, **kwargs):
return list(request_data.multipart_data.values())[0][0] == "custom_filename"
return next(iter(request_data.multipart_data.values()))[0] == "custom_filename"
monkeypatch.setattr(bot.request, "post", make_assertion)

View file

@ -418,7 +418,7 @@ class TestPassportWithoutRequest(TestPassportBase):
with pytest.raises(TypeError):
Bot(bot.token, private_key="Invalid key!")
with pytest.raises(ValueError):
with pytest.raises(ValueError, match="Could not deserialize key data"):
Bot(bot.token, private_key=b"Invalid key!")
def test_all_types(self, passport_data, bot, all_passport_data):
@ -474,7 +474,6 @@ class TestPassportWithoutRequest(TestPassportBase):
with pytest.raises(PassportDecryptionError):
assert passport_data.decrypted_data
wrong_key = b"-----BEGIN RSA PRIVATE KEY-----\r\nMIIEogIBAAKCAQB4qCFltuvHakZze86TUweU7E/SB3VLGEHAe7GJlBmrou9SSWsL\r\nH7E++157X6UqWFl54LOE9MeHZnoW7rZ+DxLKhk6NwAHTxXPnvw4CZlvUPC3OFxg3\r\nhEmNen6ojSM4sl4kYUIa7F+Q5uMEYaboxoBen9mbj4zzMGsG4aY/xBOb2ewrXQyL\r\nRh//tk1Px4ago+lUPisAvQVecz7/6KU4Xj4Lpv2z20f3cHlZX6bb7HlE1vixCMOf\r\nxvfC5SkWEGZMR/ZoWQUsoDkrDSITF/S3GtLfg083TgtCKaOF3mCT27sJ1og77npP\r\n0cH/qdlbdoFtdrRj3PvBpaj/TtXRhmdGcJBxAgMBAAECggEAYSq1Sp6XHo8dkV8B\r\nK2/QSURNu8y5zvIH8aUrgqo8Shb7OH9bryekrB3vJtgNwR5JYHdu2wHttcL3S4SO\r\nftJQxbyHgmxAjHUVNGqOM6yPA0o7cR70J7FnMoKVgdO3q68pVY7ll50IET9/T0X9\r\nDrTdKFb+/eILFsXFS1NpeSzExdsKq3zM0sP/vlJHHYVTmZDGaGEvny/eLAS+KAfG\r\nrKP96DeO4C/peXEJzALZ/mG1ReBB05Qp9Dx1xEC20yreRk5MnnBA5oiHVG5ZLOl9\r\nEEHINidqN+TMNSkxv67xMfQ6utNu5IpbklKv/4wqQOJOO50HZ+qBtSurTN573dky\r\nzslbCQKBgQDHDUBYyKN/v69VLmvNVcxTgrOcrdbqAfefJXb9C3dVXhS8/oRkCRU/\r\ndzxYWNT7hmQyWUKor/izh68rZ/M+bsTnlaa7IdAgyChzTfcZL/2pxG9pq05GF1Q4\r\nBSJ896ZEe3jEhbpJXRlWYvz7455svlxR0H8FooCTddTmkU3nsQSx0wKBgQCbLSa4\r\nyZs2QVstQQerNjxAtLi0IvV8cJkuvFoNC2Q21oqQc7BYU7NJL7uwriprZr5nwkCQ\r\nOFQXi4N3uqimNxuSng31ETfjFZPp+pjb8jf7Sce7cqU66xxR+anUzVZqBG1CJShx\r\nVxN7cWN33UZvIH34gA2Ax6AXNnJG42B5Gn1GKwKBgQCZ/oh/p4nGNXfiAK3qB6yy\r\nFvX6CwuvsqHt/8AUeKBz7PtCU+38roI/vXF0MBVmGky+HwxREQLpcdl1TVCERpIT\r\nUFXThI9OLUwOGI1IcTZf9tby+1LtKvM++8n4wGdjp9qAv6ylQV9u09pAzZItMwCd\r\nUx5SL6wlaQ2y60tIKk0lfQKBgBJS+56YmA6JGzY11qz+I5FUhfcnpauDNGOTdGLT\r\n9IqRPR2fu7RCdgpva4+KkZHLOTLReoRNUojRPb4WubGfEk93AJju5pWXR7c6k3Bt\r\novS2mrJk8GQLvXVksQxjDxBH44sLDkKMEM3j7uYJqDaZNKbyoCWT7TCwikAau5qx\r\naRevAoGAAKZV705dvrpJuyoHFZ66luANlrAwG/vNf6Q4mBEXB7guqMkokCsSkjqR\r\nhsD79E6q06zA0QzkLCavbCn5kMmDS/AbA80+B7El92iIN6d3jRdiNZiewkhlWhEG\r\nm4N0gQRfIu+rUjsS/4xk8UuQUT/Ossjn/hExi7ejpKdCc7N++bc=\r\n-----END RSA PRIVATE KEY-----"
async with make_bot(token=bot.token, private_key=short_key) as b:
passport_data = PassportData.de_json(RAW_PASSPORT_DATA, bot=b)
with pytest.raises(PassportDecryptionError):

View file

@ -228,7 +228,7 @@ class TestCallbackContext:
),
)
keyboard_uuid = app.bot.callback_data_cache.persistence_data[0][0][0]
button_uuid = list(app.bot.callback_data_cache.persistence_data[0][0][2])[0]
button_uuid = next(iter(app.bot.callback_data_cache.persistence_data[0][0][2]))
callback_data = keyboard_uuid + button_uuid
callback_query = CallbackQuery(
id="1",

View file

@ -202,9 +202,8 @@ class TestCallbackDataCache:
assert callback_query.data == "some data 1"
# make sure that we stored the mapping CallbackQuery.id -> keyboard_uuid correctly
assert len(callback_data_cache._keyboard_data) == 1
assert (
callback_data_cache._callback_queries[cq_id]
== list(callback_data_cache._keyboard_data.keys())[0]
assert callback_data_cache._callback_queries[cq_id] == next(
iter(callback_data_cache._keyboard_data.keys())
)
else:
assert callback_query.data is None
@ -399,6 +398,6 @@ class TestCallbackDataCache:
assert len(callback_data_cache.persistence_data[0]) == 50
assert len(callback_data_cache.persistence_data[1]) == 100
callback_data = [
list(data[2].values())[0] for data in callback_data_cache.persistence_data[0]
next(iter(data[2].values())) for data in callback_data_cache.persistence_data[0]
]
assert callback_data == [str(i) for i in range(50, 100)]

View file

@ -543,7 +543,7 @@ class TestHTTPXRequestWithoutRequest:
assert code == HTTPStatus.OK
async def test_do_request_params_with_data(
self, monkeypatch, httpx_request, mixed_rqs # noqa: 9811
self, monkeypatch, httpx_request, mixed_rqs # noqa: F811
):
async def make_assertion(self, **kwargs):
method_assertion = kwargs.get("method") == "method"

View file

@ -3251,8 +3251,10 @@ class TestBotWithRequest:
assert inline_keyboard[0][1] == no_replace_button
assert inline_keyboard[0][0] == replace_button
keyboard = list(bot.callback_data_cache._keyboard_data)[0]
data = list(bot.callback_data_cache._keyboard_data[keyboard].button_data.values())[0]
keyboard = next(iter(bot.callback_data_cache._keyboard_data))
data = next(
iter(bot.callback_data_cache._keyboard_data[keyboard].button_data.values())
)
assert data == "replace_test"
finally:
bot.callback_data_cache.clear_callback_data()
@ -3280,8 +3282,10 @@ class TestBotWithRequest:
assert inline_keyboard[0][1] == no_replace_button
assert inline_keyboard[0][0] == replace_button
keyboard = list(bot.callback_data_cache._keyboard_data)[0]
data = list(bot.callback_data_cache._keyboard_data[keyboard].button_data.values())[0]
keyboard = next(iter(bot.callback_data_cache._keyboard_data))
data = next(
iter(bot.callback_data_cache._keyboard_data[keyboard].button_data.values())
)
assert data == "replace_test"
finally:
bot.callback_data_cache.clear_callback_data()
@ -3313,8 +3317,10 @@ class TestBotWithRequest:
assert inline_keyboard[0][1] == no_replace_button
assert inline_keyboard[0][0] == replace_button
keyboard = list(bot.callback_data_cache._keyboard_data)[0]
data = list(bot.callback_data_cache._keyboard_data[keyboard].button_data.values())[0]
keyboard = next(iter(bot.callback_data_cache._keyboard_data))
data = next(
iter(bot.callback_data_cache._keyboard_data[keyboard].button_data.values())
)
assert data == "replace_test"
finally:
bot.callback_data_cache.clear_callback_data()
@ -3333,8 +3339,10 @@ class TestBotWithRequest:
)
await message.pin()
keyboard = list(bot.callback_data_cache._keyboard_data)[0]
data = list(bot.callback_data_cache._keyboard_data[keyboard].button_data.values())[0]
keyboard = next(iter(bot.callback_data_cache._keyboard_data))
data = next(
iter(bot.callback_data_cache._keyboard_data[keyboard].button_data.values())
)
assert data == "callback_data"
chat = await bot.get_chat(channel_id)