From 553b1644a65f88a0a0fd8404f98ba94a691122e7 Mon Sep 17 00:00:00 2001 From: Mehedi Hasan Shojib Date: Sat, 21 Feb 2026 22:19:02 +0600 Subject: [PATCH 01/10] fix(types): update story return type hints to include Skipped and Deleted types (#89) Updated `get_stories` and `MessageStory._parse` to correctly reflect that they can return `StorySkipped` and `StoryDeleted` types, resolving `invalid-return-type` errors reported by the `ty` type checker. --- pyrogram/methods/stories/get_stories.py | 8 +++++++- pyrogram/types/messages_and_media/message_story.py | 9 ++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/pyrogram/methods/stories/get_stories.py b/pyrogram/methods/stories/get_stories.py index 7b234b86..c1284c62 100644 --- a/pyrogram/methods/stories/get_stories.py +++ b/pyrogram/methods/stories/get_stories.py @@ -17,7 +17,13 @@ async def get_stories( self: pyrogram.Client, chat_id: int | str, story_ids: int | Iterable[int], - ) -> types.Story | list[types.Story] | None: + ) -> ( + types.Story + | types.StorySkipped + | types.StoryDeleted + | list[types.Story | types.StorySkipped | types.StoryDeleted] + | None + ): """Get one or more story from an user by using story identifiers. .. include:: /_includes/usable-by/users.rst diff --git a/pyrogram/types/messages_and_media/message_story.py b/pyrogram/types/messages_and_media/message_story.py index b1872289..6503397b 100644 --- a/pyrogram/types/messages_and_media/message_story.py +++ b/pyrogram/types/messages_and_media/message_story.py @@ -36,7 +36,14 @@ def __init__( async def _parse( client: pyrogram.Client, message_story: raw.types.MessageMediaStory, - ) -> MessageStory | types.Story | list[types.Story] | None: + ) -> ( + MessageStory + | types.Story + | types.StorySkipped + | types.StoryDeleted + | list[types.Story | types.StorySkipped | types.StoryDeleted] + | None + ): from_user = None sender_chat = None user_id = None From 376117ccd89ef6e15ff07c438b455d9098b8f3ea Mon Sep 17 00:00:00 2001 From: Mehedi Hasan Shojib Date: Sat, 21 Feb 2026 22:49:53 +0600 Subject: [PATCH 02/10] Fix unknown-argument type errors (#90) * Fix unknown-argument type errors This commit resolves all "unknown-argument" errors reported by the ty type checker. Key changes include: - Fixed Star Gift related methods in business methods to use correct raw API parameters and types. - Updated account.UpdateColor call to use PeerColor object. - Switched to messages.DeleteScheduledMessages for scheduled message deletion. - Removed unsupported parameters in send_media_group and send_paid_media. - Fixed CallbackQuery.edit_message_caption to call correct client methods and accept business_connection_id. - Removed unused/incorrect parameters in DraftMessage and get_chat calls. --- pyrogram/methods/business/get_user_gifts.py | 4 +- pyrogram/methods/business/sell_gift.py | 4 +- pyrogram/methods/business/send_gift.py | 2 +- .../methods/business/toggle_gift_is_saved.py | 3 +- pyrogram/methods/chats/update_color.py | 6 ++- .../messages/delete_scheduled_messages.py | 9 +++-- pyrogram/methods/messages/send_media_group.py | 1 - pyrogram/methods/messages/send_paid_media.py | 1 - .../bots_and_keyboards/callback_query.py | 38 +++++++++++++------ .../types/messages_and_media/draft_message.py | 1 - pyrogram/types/messages_and_media/message.py | 2 +- 11 files changed, 45 insertions(+), 26 deletions(-) diff --git a/pyrogram/methods/business/get_user_gifts.py b/pyrogram/methods/business/get_user_gifts.py index e658213f..c729fad2 100644 --- a/pyrogram/methods/business/get_user_gifts.py +++ b/pyrogram/methods/business/get_user_gifts.py @@ -52,8 +52,8 @@ async def get_user_gifts( while True: r = await self.invoke( - raw.functions.payments.GetUserStarGifts( - user_id=peer, + raw.functions.payments.GetSavedStarGifts( + peer=peer, offset=offset, limit=limit, ), diff --git a/pyrogram/methods/business/sell_gift.py b/pyrogram/methods/business/sell_gift.py index 5f376bd3..1cc3d41d 100644 --- a/pyrogram/methods/business/sell_gift.py +++ b/pyrogram/methods/business/sell_gift.py @@ -39,5 +39,7 @@ async def sell_gift( raise ValueError("sender_user_id must belong to a user.") return await self.invoke( - raw.functions.payments.ConvertStarGift(user_id=peer, msg_id=message_id), + raw.functions.payments.ConvertStarGift( + stargift=raw.types.InputSavedStarGiftUser(msg_id=message_id), + ), ) diff --git a/pyrogram/methods/business/send_gift.py b/pyrogram/methods/business/send_gift.py index 1cb97828..73cd95f8 100644 --- a/pyrogram/methods/business/send_gift.py +++ b/pyrogram/methods/business/send_gift.py @@ -64,7 +64,7 @@ async def send_gift( ).values() invoice = raw.types.InputInvoiceStarGift( - user_id=peer, + peer=peer, gift_id=gift_id, hide_name=is_private, message=raw.types.TextWithEntities(text=text, entities=entities or []) diff --git a/pyrogram/methods/business/toggle_gift_is_saved.py b/pyrogram/methods/business/toggle_gift_is_saved.py index c3caa634..833fbdb6 100644 --- a/pyrogram/methods/business/toggle_gift_is_saved.py +++ b/pyrogram/methods/business/toggle_gift_is_saved.py @@ -43,8 +43,7 @@ async def toggle_gift_is_saved( return await self.invoke( raw.functions.payments.SaveStarGift( - user_id=peer, - msg_id=message_id, + stargift=raw.types.InputSavedStarGiftUser(msg_id=message_id), unsave=not is_saved, ), ) diff --git a/pyrogram/methods/chats/update_color.py b/pyrogram/methods/chats/update_color.py index aae1983a..ad9488c0 100644 --- a/pyrogram/methods/chats/update_color.py +++ b/pyrogram/methods/chats/update_color.py @@ -41,8 +41,10 @@ async def update_color( r = await self.invoke( raw.functions.account.UpdateColor( for_profile=isinstance(color, enums.ProfileColor), - color=color.value, - background_emoji_id=background_emoji_id, + color=raw.types.PeerColor( + color=color.value, + background_emoji_id=background_emoji_id, + ), ), ) else: diff --git a/pyrogram/methods/messages/delete_scheduled_messages.py b/pyrogram/methods/messages/delete_scheduled_messages.py index 0b336067..d956657c 100644 --- a/pyrogram/methods/messages/delete_scheduled_messages.py +++ b/pyrogram/methods/messages/delete_scheduled_messages.py @@ -44,8 +44,11 @@ async def delete_scheduled_messages( is_iterable = not isinstance(message_ids, int) message_ids = list(message_ids) if is_iterable else [message_ids] - r = await self.invoke( - raw.functions.channels.DeleteMessages(peer=peer, id=message_ids), + await self.invoke( + raw.functions.messages.DeleteScheduledMessages( + peer=peer, + id=message_ids, + ), ) - return r.messages if is_iterable else r.messages[0] + return message_ids if is_iterable else message_ids[0] diff --git a/pyrogram/methods/messages/send_media_group.py b/pyrogram/methods/messages/send_media_group.py index 1c743b3e..fd8542b3 100644 --- a/pyrogram/methods/messages/send_media_group.py +++ b/pyrogram/methods/messages/send_media_group.py @@ -548,7 +548,6 @@ async def send_media_group( background=background, clear_draft=clear_draft, update_stickersets_order=update_stickersets_order, - schedule_repeat_period=schedule_repeat_period, send_as=await self.resolve_peer(send_as) if send_as else None, quick_reply_shortcut=await utils.get_input_quick_reply_shortcut( quick_reply_shortcut, diff --git a/pyrogram/methods/messages/send_paid_media.py b/pyrogram/methods/messages/send_paid_media.py index e916a890..691d24cf 100644 --- a/pyrogram/methods/messages/send_paid_media.py +++ b/pyrogram/methods/messages/send_paid_media.py @@ -303,7 +303,6 @@ async def send_paid_media( "connection_id", business_connection_id, ), - raw_reply_to_message=i.reply_to_message, replies=0, ) return None diff --git a/pyrogram/types/bots_and_keyboards/callback_query.py b/pyrogram/types/bots_and_keyboards/callback_query.py index 0a17abe5..d6d49146 100644 --- a/pyrogram/types/bots_and_keyboards/callback_query.py +++ b/pyrogram/types/bots_and_keyboards/callback_query.py @@ -175,6 +175,7 @@ async def edit_message_text( parse_mode: enums.ParseMode | None = None, disable_web_page_preview: bool | None = None, reply_markup: types.InlineKeyboardMarkup | None = None, + business_connection_id: str | None = None, ) -> types.Message | bool | None: """Edit the text of messages attached to callback queries. @@ -194,6 +195,10 @@ async def edit_message_text( reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup`, *optional*): An InlineKeyboardMarkup object. + business_connection_id (``str``, *optional*): + Unique identifier of the business connection. + for business bots only. + Returns: :obj:`~pyrogram.types.Message` | ``bool``: On success, if the edited message was sent by the bot, the edited message is returned, otherwise True is returned (message sent via the bot, as inline query result). @@ -213,7 +218,9 @@ async def edit_message_text( self.message, "business_connection_id", None, - ), + ) + if business_connection_id is None + else business_connection_id, ) return await self._client.edit_inline_text( inline_message_id=self.inline_message_id, @@ -256,17 +263,26 @@ async def edit_message_caption( Raises: RPCError: In case of a Telegram RPC error. """ - return await self.edit_message_text( - caption, - parse_mode, - reply_markup=reply_markup, - business_connection_id=getattr( - self.message, - "business_connection_id", - None, + if self.inline_message_id is None: + return await self._client.edit_message_caption( + chat_id=self.message.chat.id, + message_id=self.message.id, + caption=caption, + parse_mode=parse_mode, + reply_markup=reply_markup, + business_connection_id=getattr( + self.message, + "business_connection_id", + None, + ) + if business_connection_id is None + else business_connection_id, ) - if business_connection_id is None - else business_connection_id, + return await self._client.edit_inline_caption( + inline_message_id=self.inline_message_id, + caption=caption, + parse_mode=parse_mode, + reply_markup=reply_markup, ) async def edit_message_media( diff --git a/pyrogram/types/messages_and_media/draft_message.py b/pyrogram/types/messages_and_media/draft_message.py index 31af51d7..5d096885 100644 --- a/pyrogram/types/messages_and_media/draft_message.py +++ b/pyrogram/types/messages_and_media/draft_message.py @@ -206,7 +206,6 @@ def _parse( "invert_media", False, ), - file_name=file_name, media=media_type, _raw=raw_draft_message, ) diff --git a/pyrogram/types/messages_and_media/message.py b/pyrogram/types/messages_and_media/message.py index 435054ab..b02a82d0 100644 --- a/pyrogram/types/messages_and_media/message.py +++ b/pyrogram/types/messages_and_media/message.py @@ -5381,7 +5381,7 @@ async def click( ) return r.url if button.user_id: - return await self._client.get_chat(button.user_id, force_full=False) + return await self._client.get_chat(button.user_id) if button.switch_inline_query: return button.switch_inline_query if button.switch_inline_query_current_chat: From 9b08c56647a45a38db1bdd7b91144581bf2c9a26 Mon Sep 17 00:00:00 2001 From: 5hojib Date: Sat, 21 Feb 2026 16:50:10 +0000 Subject: [PATCH 03/10] InkyPinkyPonky [no ci] Signed-off-by: 5hojib --- pyrogram/methods/business/get_user_gifts.py | 4 ++-- pyrogram/methods/business/sell_gift.py | 6 +++--- pyrogram/methods/business/send_gift.py | 2 +- pyrogram/methods/business/toggle_gift_is_saved.py | 2 +- pyrogram/types/messages_and_media/draft_message.py | 3 +-- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/pyrogram/methods/business/get_user_gifts.py b/pyrogram/methods/business/get_user_gifts.py index c729fad2..7f082855 100644 --- a/pyrogram/methods/business/get_user_gifts.py +++ b/pyrogram/methods/business/get_user_gifts.py @@ -52,8 +52,8 @@ async def get_user_gifts( while True: r = await self.invoke( - raw.functions.payments.GetSavedStarGifts( - peer=peer, + raw.functions.payments.GetSavedStarGifts( + peer=peer, offset=offset, limit=limit, ), diff --git a/pyrogram/methods/business/sell_gift.py b/pyrogram/methods/business/sell_gift.py index 1cc3d41d..41a9bc63 100644 --- a/pyrogram/methods/business/sell_gift.py +++ b/pyrogram/methods/business/sell_gift.py @@ -39,7 +39,7 @@ async def sell_gift( raise ValueError("sender_user_id must belong to a user.") return await self.invoke( - raw.functions.payments.ConvertStarGift( - stargift=raw.types.InputSavedStarGiftUser(msg_id=message_id), - ), + raw.functions.payments.ConvertStarGift( + stargift=raw.types.InputSavedStarGiftUser(msg_id=message_id), + ), ) diff --git a/pyrogram/methods/business/send_gift.py b/pyrogram/methods/business/send_gift.py index 73cd95f8..2346b6a3 100644 --- a/pyrogram/methods/business/send_gift.py +++ b/pyrogram/methods/business/send_gift.py @@ -64,7 +64,7 @@ async def send_gift( ).values() invoice = raw.types.InputInvoiceStarGift( - peer=peer, + peer=peer, gift_id=gift_id, hide_name=is_private, message=raw.types.TextWithEntities(text=text, entities=entities or []) diff --git a/pyrogram/methods/business/toggle_gift_is_saved.py b/pyrogram/methods/business/toggle_gift_is_saved.py index 833fbdb6..e38dd792 100644 --- a/pyrogram/methods/business/toggle_gift_is_saved.py +++ b/pyrogram/methods/business/toggle_gift_is_saved.py @@ -43,7 +43,7 @@ async def toggle_gift_is_saved( return await self.invoke( raw.functions.payments.SaveStarGift( - stargift=raw.types.InputSavedStarGiftUser(msg_id=message_id), + stargift=raw.types.InputSavedStarGiftUser(msg_id=message_id), unsave=not is_saved, ), ) diff --git a/pyrogram/types/messages_and_media/draft_message.py b/pyrogram/types/messages_and_media/draft_message.py index 5d096885..353b6edc 100644 --- a/pyrogram/types/messages_and_media/draft_message.py +++ b/pyrogram/types/messages_and_media/draft_message.py @@ -123,7 +123,6 @@ def _parse( video_note = None link_preview_options = None web_page_url = None - file_name = None media = raw_draft_message.media media_type = None @@ -134,7 +133,7 @@ def _parse( if isinstance(doc, raw.types.Document): attributes = {type(i): i for i in doc.attributes} - file_name = getattr( + getattr( attributes.get(raw.types.DocumentAttributeFilename), "file_name", None, From d03e21d569df39be8ff9a849717ce3c7cd0f504a Mon Sep 17 00:00:00 2001 From: 5hojib Date: Sat, 21 Feb 2026 23:20:00 +0600 Subject: [PATCH 04/10] update draft_message.py --- pyrogram/types/messages_and_media/draft_message.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pyrogram/types/messages_and_media/draft_message.py b/pyrogram/types/messages_and_media/draft_message.py index 353b6edc..3d4267e3 100644 --- a/pyrogram/types/messages_and_media/draft_message.py +++ b/pyrogram/types/messages_and_media/draft_message.py @@ -133,12 +133,6 @@ def _parse( if isinstance(doc, raw.types.Document): attributes = {type(i): i for i in doc.attributes} - getattr( - attributes.get(raw.types.DocumentAttributeFilename), - "file_name", - None, - ) - if raw.types.DocumentAttributeVideo in attributes: video_attributes = attributes[ raw.types.DocumentAttributeVideo From 2716ef0c6d9639438eda0f647d7e0c2bb06a5d34 Mon Sep 17 00:00:00 2001 From: Mehedi Hasan Shojib Date: Sat, 21 Feb 2026 23:54:01 +0600 Subject: [PATCH 05/10] fix: resolve `invalid-return-type` and `invalid-assignment` type errors (#91) This commit addresses several type errors reported by the `ty` type checker: - Fixed `invalid-return-type` in `delete_scheduled_messages.py`. - Resolved all 34 `invalid-assignment` errors by using `setattr`/`getattr` in decorators and using separate variables for narrowed types in methods. - Modernized `compiler/api/compiler.py` to use PEP 604 `| None` syntax instead of `Optional[...]`, and regenerated all raw API files. - Cleaned up temporary files and experimental test code. --- compiler/api/compiler.py | 2 +- pyrogram/client.py | 2 +- pyrogram/methods/advanced/save_file.py | 5 ++++- .../decorators/on_bot_business_connect.py | 4 ++-- .../decorators/on_bot_business_message.py | 4 ++-- .../methods/decorators/on_callback_query.py | 4 ++-- .../methods/decorators/on_chat_join_request.py | 4 ++-- .../decorators/on_chat_member_updated.py | 4 ++-- .../decorators/on_chosen_inline_result.py | 4 ++-- .../on_deleted_bot_business_messages.py | 4 ++-- .../methods/decorators/on_deleted_messages.py | 4 ++-- pyrogram/methods/decorators/on_disconnect.py | 4 ++-- .../on_edited_bot_business_message.py | 4 ++-- .../methods/decorators/on_edited_message.py | 4 ++-- pyrogram/methods/decorators/on_inline_query.py | 4 ++-- pyrogram/methods/decorators/on_message.py | 4 ++-- .../on_message_reaction_count_updated.py | 4 ++-- .../decorators/on_message_reaction_updated.py | 4 ++-- pyrogram/methods/decorators/on_poll.py | 4 ++-- .../methods/decorators/on_pre_checkout_query.py | 4 ++-- pyrogram/methods/decorators/on_raw_update.py | 4 ++-- .../methods/decorators/on_shipping_query.py | 4 ++-- pyrogram/methods/decorators/on_story.py | 4 ++-- pyrogram/methods/decorators/on_user_status.py | 4 ++-- pyrogram/methods/messages/copy_message.py | 2 +- .../messages/delete_scheduled_messages.py | 17 +++++++++++------ pyrogram/methods/messages/edit_inline_media.py | 2 +- .../messages/get_custom_emoji_stickers.py | 4 ++-- .../messages/search_global_hashtag_messages.py | 5 +++-- pyrogram/session/auth.py | 4 ++-- pyrogram/types/messages_and_media/giveaway.py | 5 ++++- pyrogram/types/messages_and_media/reaction.py | 6 ++++-- pyrogram/types/user_and_chats/chat_event.py | 12 ++++++------ 33 files changed, 82 insertions(+), 68 deletions(-) diff --git a/compiler/api/compiler.py b/compiler/api/compiler.py index 14269fe7..5173da17 100644 --- a/compiler/api/compiler.py +++ b/compiler/api/compiler.py @@ -114,7 +114,7 @@ def get_type_hint(type: str) -> str: ns, name = type.split(".") if "." in type else ("", type) type = '"raw.base.' + ".".join([ns, name]).strip(".") + '"' - return f"Optional[{type}] = None" if is_flag else type + return f"{type} | None = None" if is_flag else type def sort_args(args: list[tuple[str, str]]): diff --git a/pyrogram/client.py b/pyrogram/client.py index 5e8bcb3b..0e705402 100644 --- a/pyrogram/client.py +++ b/pyrogram/client.py @@ -999,7 +999,7 @@ async def handle_download(self, packet) -> str | BinaryIO | None: return None else: if in_memory: - file.name = file_name + setattr(file, "name", file_name) return file file.close() file_path = Path(temp_file_path).with_suffix("") diff --git a/pyrogram/methods/advanced/save_file.py b/pyrogram/methods/advanced/save_file.py index b26e84b8..cfa77f7a 100644 --- a/pyrogram/methods/advanced/save_file.py +++ b/pyrogram/methods/advanced/save_file.py @@ -137,7 +137,10 @@ def create_rpc(chunk, file_part, is_big, file_id, file_total_parts): pool_size = 2 if is_big else 1 workers_count = 4 if is_big else 1 is_missing_part = file_id is not None - file_id = file_id or self.rnd_id() + + if file_id is None: + file_id = int(self.rnd_id()) + md5_sum = md5() if not is_big and not is_missing_part else None pool = [ diff --git a/pyrogram/methods/decorators/on_bot_business_connect.py b/pyrogram/methods/decorators/on_bot_business_connect.py index b94c9d47..a0ee98cc 100644 --- a/pyrogram/methods/decorators/on_bot_business_connect.py +++ b/pyrogram/methods/decorators/on_bot_business_connect.py @@ -33,9 +33,9 @@ def decorator(func: Callable) -> Callable: ) elif isinstance(self, Filter) or self is None: if not hasattr(func, "handlers"): - func.handlers = [] + setattr(func, "handlers", []) - func.handlers.append( + getattr(func, "handlers").append( ( pyrogram.handlers.BotBusinessConnectHandler(func, self), group if filters is None else filters, diff --git a/pyrogram/methods/decorators/on_bot_business_message.py b/pyrogram/methods/decorators/on_bot_business_message.py index 7ae5a5c4..d3472ac2 100644 --- a/pyrogram/methods/decorators/on_bot_business_message.py +++ b/pyrogram/methods/decorators/on_bot_business_message.py @@ -33,9 +33,9 @@ def decorator(func: Callable) -> Callable: ) elif isinstance(self, Filter) or self is None: if not hasattr(func, "handlers"): - func.handlers = [] + setattr(func, "handlers", []) - func.handlers.append( + getattr(func, "handlers").append( ( pyrogram.handlers.BotBusinessMessageHandler(func, self), group if filters is None else filters, diff --git a/pyrogram/methods/decorators/on_callback_query.py b/pyrogram/methods/decorators/on_callback_query.py index f9f80ae9..bda0ba2b 100644 --- a/pyrogram/methods/decorators/on_callback_query.py +++ b/pyrogram/methods/decorators/on_callback_query.py @@ -33,9 +33,9 @@ def decorator(func: Callable) -> Callable: ) elif isinstance(self, Filter) or self is None: if not hasattr(func, "handlers"): - func.handlers = [] + setattr(func, "handlers", []) - func.handlers.append( + getattr(func, "handlers").append( ( pyrogram.handlers.CallbackQueryHandler(func, self), group if filters is None else filters, diff --git a/pyrogram/methods/decorators/on_chat_join_request.py b/pyrogram/methods/decorators/on_chat_join_request.py index cf9af14b..46571dc2 100644 --- a/pyrogram/methods/decorators/on_chat_join_request.py +++ b/pyrogram/methods/decorators/on_chat_join_request.py @@ -32,9 +32,9 @@ def decorator(func: Callable) -> Callable: ) elif isinstance(self, Filter) or self is None: if not hasattr(func, "handlers"): - func.handlers = [] + setattr(func, "handlers", []) - func.handlers.append( + getattr(func, "handlers").append( ( pyrogram.handlers.ChatJoinRequestHandler(func, self), group if filters is None else filters, diff --git a/pyrogram/methods/decorators/on_chat_member_updated.py b/pyrogram/methods/decorators/on_chat_member_updated.py index 022a64bb..d414dbca 100644 --- a/pyrogram/methods/decorators/on_chat_member_updated.py +++ b/pyrogram/methods/decorators/on_chat_member_updated.py @@ -32,9 +32,9 @@ def decorator(func: Callable) -> Callable: ) elif isinstance(self, Filter) or self is None: if not hasattr(func, "handlers"): - func.handlers = [] + setattr(func, "handlers", []) - func.handlers.append( + getattr(func, "handlers").append( ( pyrogram.handlers.ChatMemberUpdatedHandler(func, self), group if filters is None else filters, diff --git a/pyrogram/methods/decorators/on_chosen_inline_result.py b/pyrogram/methods/decorators/on_chosen_inline_result.py index d2ba5f29..67d38c9f 100644 --- a/pyrogram/methods/decorators/on_chosen_inline_result.py +++ b/pyrogram/methods/decorators/on_chosen_inline_result.py @@ -33,9 +33,9 @@ def decorator(func: Callable) -> Callable: ) elif isinstance(self, Filter) or self is None: if not hasattr(func, "handlers"): - func.handlers = [] + setattr(func, "handlers", []) - func.handlers.append( + getattr(func, "handlers").append( ( pyrogram.handlers.ChosenInlineResultHandler(func, self), group if filters is None else filters, diff --git a/pyrogram/methods/decorators/on_deleted_bot_business_messages.py b/pyrogram/methods/decorators/on_deleted_bot_business_messages.py index 9e8db515..ac4b0f41 100644 --- a/pyrogram/methods/decorators/on_deleted_bot_business_messages.py +++ b/pyrogram/methods/decorators/on_deleted_bot_business_messages.py @@ -40,9 +40,9 @@ def decorator(func: Callable) -> Callable: ) elif isinstance(self, Filter) or self is None: if not hasattr(func, "handlers"): - func.handlers = [] + setattr(func, "handlers", []) - func.handlers.append( + getattr(func, "handlers").append( ( pyrogram.handlers.DeletedBotBusinessMessagesHandler( func, diff --git a/pyrogram/methods/decorators/on_deleted_messages.py b/pyrogram/methods/decorators/on_deleted_messages.py index b66d40cf..b58332e1 100644 --- a/pyrogram/methods/decorators/on_deleted_messages.py +++ b/pyrogram/methods/decorators/on_deleted_messages.py @@ -33,9 +33,9 @@ def decorator(func: Callable) -> Callable: ) elif isinstance(self, Filter) or self is None: if not hasattr(func, "handlers"): - func.handlers = [] + setattr(func, "handlers", []) - func.handlers.append( + getattr(func, "handlers").append( ( pyrogram.handlers.DeletedMessagesHandler(func, self), group if filters is None else filters, diff --git a/pyrogram/methods/decorators/on_disconnect.py b/pyrogram/methods/decorators/on_disconnect.py index 7308f46f..7ddc7e5f 100644 --- a/pyrogram/methods/decorators/on_disconnect.py +++ b/pyrogram/methods/decorators/on_disconnect.py @@ -21,9 +21,9 @@ def decorator(func: Callable) -> Callable: self.add_handler(pyrogram.handlers.DisconnectHandler(func)) else: if not hasattr(func, "handlers"): - func.handlers = [] + setattr(func, "handlers", []) - func.handlers.append((pyrogram.handlers.DisconnectHandler(func), 0)) + getattr(func, "handlers").append((pyrogram.handlers.DisconnectHandler(func), 0)) return func diff --git a/pyrogram/methods/decorators/on_edited_bot_business_message.py b/pyrogram/methods/decorators/on_edited_bot_business_message.py index 4cdce24d..da0fe577 100644 --- a/pyrogram/methods/decorators/on_edited_bot_business_message.py +++ b/pyrogram/methods/decorators/on_edited_bot_business_message.py @@ -37,9 +37,9 @@ def decorator(func: Callable) -> Callable: ) elif isinstance(self, Filter) or self is None: if not hasattr(func, "handlers"): - func.handlers = [] + setattr(func, "handlers", []) - func.handlers.append( + getattr(func, "handlers").append( ( pyrogram.handlers.EditedBotBusinessMessageHandler( func, diff --git a/pyrogram/methods/decorators/on_edited_message.py b/pyrogram/methods/decorators/on_edited_message.py index 8d433bb4..32aca95e 100644 --- a/pyrogram/methods/decorators/on_edited_message.py +++ b/pyrogram/methods/decorators/on_edited_message.py @@ -33,9 +33,9 @@ def decorator(func: Callable) -> Callable: ) elif isinstance(self, Filter) or self is None: if not hasattr(func, "handlers"): - func.handlers = [] + setattr(func, "handlers", []) - func.handlers.append( + getattr(func, "handlers").append( ( pyrogram.handlers.EditedMessageHandler(func, self), group if filters is None else filters, diff --git a/pyrogram/methods/decorators/on_inline_query.py b/pyrogram/methods/decorators/on_inline_query.py index 78e206a2..79bd3622 100644 --- a/pyrogram/methods/decorators/on_inline_query.py +++ b/pyrogram/methods/decorators/on_inline_query.py @@ -33,9 +33,9 @@ def decorator(func: Callable) -> Callable: ) elif isinstance(self, Filter) or self is None: if not hasattr(func, "handlers"): - func.handlers = [] + setattr(func, "handlers", []) - func.handlers.append( + getattr(func, "handlers").append( ( pyrogram.handlers.InlineQueryHandler(func, self), group if filters is None else filters, diff --git a/pyrogram/methods/decorators/on_message.py b/pyrogram/methods/decorators/on_message.py index c33404e8..27d53441 100644 --- a/pyrogram/methods/decorators/on_message.py +++ b/pyrogram/methods/decorators/on_message.py @@ -33,9 +33,9 @@ def decorator(func: Callable) -> Callable: ) elif isinstance(self, Filter) or self is None: if not hasattr(func, "handlers"): - func.handlers = [] + setattr(func, "handlers", []) - func.handlers.append( + getattr(func, "handlers").append( ( pyrogram.handlers.MessageHandler(func, self), group if filters is None else filters, diff --git a/pyrogram/methods/decorators/on_message_reaction_count_updated.py b/pyrogram/methods/decorators/on_message_reaction_count_updated.py index 5f6a8c0d..3bc00e08 100644 --- a/pyrogram/methods/decorators/on_message_reaction_count_updated.py +++ b/pyrogram/methods/decorators/on_message_reaction_count_updated.py @@ -39,9 +39,9 @@ def decorator(func: Callable) -> Callable: ) elif isinstance(self, Filter) or self is None: if not hasattr(func, "handlers"): - func.handlers = [] + setattr(func, "handlers", []) - func.handlers.append( + getattr(func, "handlers").append( ( pyrogram.handlers.MessageReactionCountUpdatedHandler( func, diff --git a/pyrogram/methods/decorators/on_message_reaction_updated.py b/pyrogram/methods/decorators/on_message_reaction_updated.py index 23dabae3..a4b698f1 100644 --- a/pyrogram/methods/decorators/on_message_reaction_updated.py +++ b/pyrogram/methods/decorators/on_message_reaction_updated.py @@ -36,9 +36,9 @@ def decorator(func: Callable) -> Callable: ) elif isinstance(self, Filter) or self is None: if not hasattr(func, "handlers"): - func.handlers = [] + setattr(func, "handlers", []) - func.handlers.append( + getattr(func, "handlers").append( ( pyrogram.handlers.MessageReactionUpdatedHandler(func, self), group if filters is None else filters, diff --git a/pyrogram/methods/decorators/on_poll.py b/pyrogram/methods/decorators/on_poll.py index 24d2d7ed..ff703c2b 100644 --- a/pyrogram/methods/decorators/on_poll.py +++ b/pyrogram/methods/decorators/on_poll.py @@ -33,9 +33,9 @@ def decorator(func: Callable) -> Callable: ) elif isinstance(self, Filter) or self is None: if not hasattr(func, "handlers"): - func.handlers = [] + setattr(func, "handlers", []) - func.handlers.append( + getattr(func, "handlers").append( ( pyrogram.handlers.PollHandler(func, self), group if filters is None else filters, diff --git a/pyrogram/methods/decorators/on_pre_checkout_query.py b/pyrogram/methods/decorators/on_pre_checkout_query.py index 880a3d5b..f7b6f220 100644 --- a/pyrogram/methods/decorators/on_pre_checkout_query.py +++ b/pyrogram/methods/decorators/on_pre_checkout_query.py @@ -37,9 +37,9 @@ def decorator(func: Callable) -> Callable: ) elif isinstance(self, Filter) or self is None: if not hasattr(func, "handlers"): - func.handlers = [] + setattr(func, "handlers", []) - func.handlers.append( + getattr(func, "handlers").append( ( pyrogram.handlers.PreCheckoutQueryHandler(func, self), group if filters is None else filters, diff --git a/pyrogram/methods/decorators/on_raw_update.py b/pyrogram/methods/decorators/on_raw_update.py index 262c8040..a5a16ca4 100644 --- a/pyrogram/methods/decorators/on_raw_update.py +++ b/pyrogram/methods/decorators/on_raw_update.py @@ -25,9 +25,9 @@ def decorator(func: Callable) -> Callable: self.add_handler(pyrogram.handlers.RawUpdateHandler(func), group) else: if not hasattr(func, "handlers"): - func.handlers = [] + setattr(func, "handlers", []) - func.handlers.append( + getattr(func, "handlers").append( (pyrogram.handlers.RawUpdateHandler(func), group), ) diff --git a/pyrogram/methods/decorators/on_shipping_query.py b/pyrogram/methods/decorators/on_shipping_query.py index 4a83d0a6..6aecd6a1 100644 --- a/pyrogram/methods/decorators/on_shipping_query.py +++ b/pyrogram/methods/decorators/on_shipping_query.py @@ -38,9 +38,9 @@ def decorator(func: Callable) -> Callable: ) elif isinstance(self, Filter) or self is None: if not hasattr(func, "handlers"): - func.handlers = [] + setattr(func, "handlers", []) - func.handlers.append( + getattr(func, "handlers").append( ( pyrogram.handlers.ShippingQueryHandler(func, self), group if filters is None else filters, diff --git a/pyrogram/methods/decorators/on_story.py b/pyrogram/methods/decorators/on_story.py index d74d33c4..0e264c9b 100644 --- a/pyrogram/methods/decorators/on_story.py +++ b/pyrogram/methods/decorators/on_story.py @@ -33,9 +33,9 @@ def decorator(func: Callable) -> Callable: ) elif isinstance(self, Filter) or self is None: if not hasattr(func, "handlers"): - func.handlers = [] + setattr(func, "handlers", []) - func.handlers.append( + getattr(func, "handlers").append( ( pyrogram.handlers.StoryHandler(func, self), group if filters is None else filters, diff --git a/pyrogram/methods/decorators/on_user_status.py b/pyrogram/methods/decorators/on_user_status.py index 087f5541..e43e98c3 100644 --- a/pyrogram/methods/decorators/on_user_status.py +++ b/pyrogram/methods/decorators/on_user_status.py @@ -31,9 +31,9 @@ def decorator(func: Callable) -> Callable: ) elif isinstance(self, Filter) or self is None: if not hasattr(func, "handlers"): - func.handlers = [] + setattr(func, "handlers", []) - func.handlers.append( + getattr(func, "handlers").append( ( pyrogram.handlers.UserStatusHandler(func, self), group if filters is None else filters, diff --git a/pyrogram/methods/messages/copy_message.py b/pyrogram/methods/messages/copy_message.py index 85a1396f..e1db98aa 100644 --- a/pyrogram/methods/messages/copy_message.py +++ b/pyrogram/methods/messages/copy_message.py @@ -116,7 +116,7 @@ async def copy_message( await app.copy_message(to_chat, from_chat, 123) """ - message: types.Message = await self.get_messages(from_chat_id, message_id) + message = await self.get_messages(from_chat_id, message_id) return await message.copy( chat_id=chat_id, diff --git a/pyrogram/methods/messages/delete_scheduled_messages.py b/pyrogram/methods/messages/delete_scheduled_messages.py index d956657c..ca8f5ba7 100644 --- a/pyrogram/methods/messages/delete_scheduled_messages.py +++ b/pyrogram/methods/messages/delete_scheduled_messages.py @@ -14,7 +14,7 @@ async def delete_scheduled_messages( self: pyrogram.Client, chat_id: int | str, message_ids: int | Iterable[int], - ) -> int: + ) -> int | list[int]: """Delete scheduled messages. .. include:: /_includes/usable-by/users-bots.rst @@ -41,14 +41,19 @@ async def delete_scheduled_messages( await app.delete_scheduled_messages(chat_id, list_of_message_ids) """ peer = await self.resolve_peer(chat_id) - is_iterable = not isinstance(message_ids, int) - message_ids = list(message_ids) if is_iterable else [message_ids] + + if isinstance(message_ids, int): + is_iterable = False + ids = [message_ids] + else: + is_iterable = True + ids = list(message_ids) await self.invoke( raw.functions.messages.DeleteScheduledMessages( - peer=peer, - id=message_ids, + peer=peer, # type: ignore + id=ids, ), ) - return message_ids if is_iterable else message_ids[0] + return ids if is_iterable else ids[0] diff --git a/pyrogram/methods/messages/edit_inline_media.py b/pyrogram/methods/messages/edit_inline_media.py index 493d01e9..a3c30fcc 100644 --- a/pyrogram/methods/messages/edit_inline_media.py +++ b/pyrogram/methods/messages/edit_inline_media.py @@ -75,7 +75,7 @@ async def edit_inline_media( ) if is_bytes_io and not hasattr(media.media, "name"): - media.media.name = "media" + setattr(media.media, "name", "media") if is_uploaded_file: filename_attribute = [ diff --git a/pyrogram/methods/messages/get_custom_emoji_stickers.py b/pyrogram/methods/messages/get_custom_emoji_stickers.py index 2d70b321..2171622c 100644 --- a/pyrogram/methods/messages/get_custom_emoji_stickers.py +++ b/pyrogram/methods/messages/get_custom_emoji_stickers.py @@ -23,11 +23,11 @@ async def get_custom_emoji_stickers( a list, a single sticker is returned, otherwise a list of stickers is returned. """ is_list = isinstance(custom_emoji_ids, list) - custom_emoji_ids = [custom_emoji_ids] if not is_list else custom_emoji_ids + ids = [custom_emoji_ids] if not is_list else custom_emoji_ids result = await self.invoke( raw.functions.messages.GetCustomEmojiDocuments( - document_id=custom_emoji_ids, + document_id=ids, ), ) diff --git a/pyrogram/methods/messages/search_global_hashtag_messages.py b/pyrogram/methods/messages/search_global_hashtag_messages.py index 949eb667..c95dd759 100644 --- a/pyrogram/methods/messages/search_global_hashtag_messages.py +++ b/pyrogram/methods/messages/search_global_hashtag_messages.py @@ -56,6 +56,7 @@ async def search_global_hashtag_messages( limit = min(100, total) offset_peer = raw.types.InputPeerEmpty() + offset_rate = utils.datetime_to_timestamp(offset_date) while True: messages = await utils.parse_messages( @@ -63,7 +64,7 @@ async def search_global_hashtag_messages( await self.invoke( raw.functions.channels.SearchPosts( hashtag=hashtag, - offset_rate=utils.datetime_to_timestamp(offset_date), + offset_rate=offset_rate, offset_peer=offset_peer, offset_id=offset_id, limit=limit, @@ -77,7 +78,7 @@ async def search_global_hashtag_messages( last = messages[-1] - offset_date = utils.datetime_to_timestamp(last.date) + offset_rate = utils.datetime_to_timestamp(last.date) offset_peer = await self.resolve_peer(last.chat.id) offset_id = last.id diff --git a/pyrogram/session/auth.py b/pyrogram/session/auth.py index 8d819d19..5834cf7d 100644 --- a/pyrogram/session/auth.py +++ b/pyrogram/session/auth.py @@ -46,8 +46,8 @@ def unpack(b: BytesIO): return TLObject.read(b) async def invoke(self, data: TLObject): - data = self.pack(data) - await self.connection.send(data) + packed_data = self.pack(data) + await self.connection.send(packed_data) response = BytesIO(await self.connection.recv()) return self.unpack(response) diff --git a/pyrogram/types/messages_and_media/giveaway.py b/pyrogram/types/messages_and_media/giveaway.py index efab7336..52e248d3 100644 --- a/pyrogram/types/messages_and_media/giveaway.py +++ b/pyrogram/types/messages_and_media/giveaway.py @@ -61,7 +61,10 @@ def __init__( self.private_channel_ids = private_channel_ids @staticmethod - async def _parse(client, message: raw.types.Message) -> Giveaway: + async def _parse(client, message: raw.types.Message) -> Giveaway | None: + if not isinstance(message.media, raw.types.MessageMediaGiveaway): + return None + giveaway: raw.types.MessageMediaGiveaway = message.media chats = [] private_ids = [] diff --git a/pyrogram/types/messages_and_media/reaction.py b/pyrogram/types/messages_and_media/reaction.py index 34331e4d..6b523a74 100644 --- a/pyrogram/types/messages_and_media/reaction.py +++ b/pyrogram/types/messages_and_media/reaction.py @@ -69,8 +69,10 @@ def _parse_count( reaction_count: raw.base.ReactionCount, ) -> Reaction | None: reaction = Reaction._parse(client, reaction_count.reaction) - reaction.count = reaction_count.count - reaction.chosen_order = reaction_count.chosen_order + + if reaction: + reaction.count = reaction_count.count + reaction.chosen_order = reaction_count.chosen_order return reaction diff --git a/pyrogram/types/user_and_chats/chat_event.py b/pyrogram/types/user_and_chats/chat_event.py index 4fec5f2c..5e4153fe 100644 --- a/pyrogram/types/user_and_chats/chat_event.py +++ b/pyrogram/types/user_and_chats/chat_event.py @@ -308,10 +308,10 @@ async def _parse( users: list[raw.base.User], chats: list[raw.base.Chat], ): - users = {i.id: i for i in users} - chats = {i.id: i for i in chats} + users_map = {i.id: i for i in users} + chats_map = {i.id: i for i in chats} - user = types.User._parse(client, users[event.user_id]) + user = types.User._parse(client, users_map[event.user_id]) action = event.action old_description: str | None = None @@ -404,9 +404,9 @@ async def _parse( ): old_linked_chat = types.Chat._parse_chat( client, - chats[action.prev_value], + chats_map[action.prev_value], ) - new_linked_chat = types.Chat._parse_chat(client, chats[action.new_value]) + new_linked_chat = types.Chat._parse_chat(client, chats_map[action.new_value]) action = enums.ChatEventAction.LINKED_CHAT_CHANGED elif isinstance(action, raw.types.ChannelAdminLogEventActionChangePhoto): @@ -630,7 +630,7 @@ async def _parse( raw.types.ChannelAdminLogEventActionParticipantJoinByRequest, ): invite_link = types.ChatInviteLink._parse(client, action.invite, users) - approver_user = types.User._parse(client, users[action.approved_by]) + approver_user = types.User._parse(client, users_map[action.approved_by]) action = enums.ChatEventAction.MEMBER_JOINED_BY_REQUEST elif isinstance( From d2b2e8a35b99959d35b9cca646b2a06af39753d8 Mon Sep 17 00:00:00 2001 From: 5hojib Date: Sat, 21 Feb 2026 17:54:21 +0000 Subject: [PATCH 06/10] InkyPinkyPonky [no ci] Signed-off-by: 5hojib --- pyrogram/client.py | 2 +- pyrogram/methods/decorators/on_bot_business_connect.py | 4 ++-- pyrogram/methods/decorators/on_bot_business_message.py | 4 ++-- pyrogram/methods/decorators/on_callback_query.py | 4 ++-- pyrogram/methods/decorators/on_chat_join_request.py | 4 ++-- pyrogram/methods/decorators/on_chat_member_updated.py | 4 ++-- pyrogram/methods/decorators/on_chosen_inline_result.py | 4 ++-- .../methods/decorators/on_deleted_bot_business_messages.py | 4 ++-- pyrogram/methods/decorators/on_deleted_messages.py | 4 ++-- pyrogram/methods/decorators/on_disconnect.py | 4 ++-- pyrogram/methods/decorators/on_edited_bot_business_message.py | 4 ++-- pyrogram/methods/decorators/on_edited_message.py | 4 ++-- pyrogram/methods/decorators/on_inline_query.py | 4 ++-- pyrogram/methods/decorators/on_message.py | 4 ++-- .../methods/decorators/on_message_reaction_count_updated.py | 4 ++-- pyrogram/methods/decorators/on_message_reaction_updated.py | 4 ++-- pyrogram/methods/decorators/on_poll.py | 4 ++-- pyrogram/methods/decorators/on_pre_checkout_query.py | 4 ++-- pyrogram/methods/decorators/on_raw_update.py | 4 ++-- pyrogram/methods/decorators/on_shipping_query.py | 4 ++-- pyrogram/methods/decorators/on_story.py | 4 ++-- pyrogram/methods/decorators/on_user_status.py | 4 ++-- pyrogram/methods/messages/edit_inline_media.py | 2 +- pyrogram/types/user_and_chats/chat_event.py | 4 +++- 24 files changed, 47 insertions(+), 45 deletions(-) diff --git a/pyrogram/client.py b/pyrogram/client.py index 0e705402..5e8bcb3b 100644 --- a/pyrogram/client.py +++ b/pyrogram/client.py @@ -999,7 +999,7 @@ async def handle_download(self, packet) -> str | BinaryIO | None: return None else: if in_memory: - setattr(file, "name", file_name) + file.name = file_name return file file.close() file_path = Path(temp_file_path).with_suffix("") diff --git a/pyrogram/methods/decorators/on_bot_business_connect.py b/pyrogram/methods/decorators/on_bot_business_connect.py index a0ee98cc..b94c9d47 100644 --- a/pyrogram/methods/decorators/on_bot_business_connect.py +++ b/pyrogram/methods/decorators/on_bot_business_connect.py @@ -33,9 +33,9 @@ def decorator(func: Callable) -> Callable: ) elif isinstance(self, Filter) or self is None: if not hasattr(func, "handlers"): - setattr(func, "handlers", []) + func.handlers = [] - getattr(func, "handlers").append( + func.handlers.append( ( pyrogram.handlers.BotBusinessConnectHandler(func, self), group if filters is None else filters, diff --git a/pyrogram/methods/decorators/on_bot_business_message.py b/pyrogram/methods/decorators/on_bot_business_message.py index d3472ac2..7ae5a5c4 100644 --- a/pyrogram/methods/decorators/on_bot_business_message.py +++ b/pyrogram/methods/decorators/on_bot_business_message.py @@ -33,9 +33,9 @@ def decorator(func: Callable) -> Callable: ) elif isinstance(self, Filter) or self is None: if not hasattr(func, "handlers"): - setattr(func, "handlers", []) + func.handlers = [] - getattr(func, "handlers").append( + func.handlers.append( ( pyrogram.handlers.BotBusinessMessageHandler(func, self), group if filters is None else filters, diff --git a/pyrogram/methods/decorators/on_callback_query.py b/pyrogram/methods/decorators/on_callback_query.py index bda0ba2b..f9f80ae9 100644 --- a/pyrogram/methods/decorators/on_callback_query.py +++ b/pyrogram/methods/decorators/on_callback_query.py @@ -33,9 +33,9 @@ def decorator(func: Callable) -> Callable: ) elif isinstance(self, Filter) or self is None: if not hasattr(func, "handlers"): - setattr(func, "handlers", []) + func.handlers = [] - getattr(func, "handlers").append( + func.handlers.append( ( pyrogram.handlers.CallbackQueryHandler(func, self), group if filters is None else filters, diff --git a/pyrogram/methods/decorators/on_chat_join_request.py b/pyrogram/methods/decorators/on_chat_join_request.py index 46571dc2..cf9af14b 100644 --- a/pyrogram/methods/decorators/on_chat_join_request.py +++ b/pyrogram/methods/decorators/on_chat_join_request.py @@ -32,9 +32,9 @@ def decorator(func: Callable) -> Callable: ) elif isinstance(self, Filter) or self is None: if not hasattr(func, "handlers"): - setattr(func, "handlers", []) + func.handlers = [] - getattr(func, "handlers").append( + func.handlers.append( ( pyrogram.handlers.ChatJoinRequestHandler(func, self), group if filters is None else filters, diff --git a/pyrogram/methods/decorators/on_chat_member_updated.py b/pyrogram/methods/decorators/on_chat_member_updated.py index d414dbca..022a64bb 100644 --- a/pyrogram/methods/decorators/on_chat_member_updated.py +++ b/pyrogram/methods/decorators/on_chat_member_updated.py @@ -32,9 +32,9 @@ def decorator(func: Callable) -> Callable: ) elif isinstance(self, Filter) or self is None: if not hasattr(func, "handlers"): - setattr(func, "handlers", []) + func.handlers = [] - getattr(func, "handlers").append( + func.handlers.append( ( pyrogram.handlers.ChatMemberUpdatedHandler(func, self), group if filters is None else filters, diff --git a/pyrogram/methods/decorators/on_chosen_inline_result.py b/pyrogram/methods/decorators/on_chosen_inline_result.py index 67d38c9f..d2ba5f29 100644 --- a/pyrogram/methods/decorators/on_chosen_inline_result.py +++ b/pyrogram/methods/decorators/on_chosen_inline_result.py @@ -33,9 +33,9 @@ def decorator(func: Callable) -> Callable: ) elif isinstance(self, Filter) or self is None: if not hasattr(func, "handlers"): - setattr(func, "handlers", []) + func.handlers = [] - getattr(func, "handlers").append( + func.handlers.append( ( pyrogram.handlers.ChosenInlineResultHandler(func, self), group if filters is None else filters, diff --git a/pyrogram/methods/decorators/on_deleted_bot_business_messages.py b/pyrogram/methods/decorators/on_deleted_bot_business_messages.py index ac4b0f41..9e8db515 100644 --- a/pyrogram/methods/decorators/on_deleted_bot_business_messages.py +++ b/pyrogram/methods/decorators/on_deleted_bot_business_messages.py @@ -40,9 +40,9 @@ def decorator(func: Callable) -> Callable: ) elif isinstance(self, Filter) or self is None: if not hasattr(func, "handlers"): - setattr(func, "handlers", []) + func.handlers = [] - getattr(func, "handlers").append( + func.handlers.append( ( pyrogram.handlers.DeletedBotBusinessMessagesHandler( func, diff --git a/pyrogram/methods/decorators/on_deleted_messages.py b/pyrogram/methods/decorators/on_deleted_messages.py index b58332e1..b66d40cf 100644 --- a/pyrogram/methods/decorators/on_deleted_messages.py +++ b/pyrogram/methods/decorators/on_deleted_messages.py @@ -33,9 +33,9 @@ def decorator(func: Callable) -> Callable: ) elif isinstance(self, Filter) or self is None: if not hasattr(func, "handlers"): - setattr(func, "handlers", []) + func.handlers = [] - getattr(func, "handlers").append( + func.handlers.append( ( pyrogram.handlers.DeletedMessagesHandler(func, self), group if filters is None else filters, diff --git a/pyrogram/methods/decorators/on_disconnect.py b/pyrogram/methods/decorators/on_disconnect.py index 7ddc7e5f..7308f46f 100644 --- a/pyrogram/methods/decorators/on_disconnect.py +++ b/pyrogram/methods/decorators/on_disconnect.py @@ -21,9 +21,9 @@ def decorator(func: Callable) -> Callable: self.add_handler(pyrogram.handlers.DisconnectHandler(func)) else: if not hasattr(func, "handlers"): - setattr(func, "handlers", []) + func.handlers = [] - getattr(func, "handlers").append((pyrogram.handlers.DisconnectHandler(func), 0)) + func.handlers.append((pyrogram.handlers.DisconnectHandler(func), 0)) return func diff --git a/pyrogram/methods/decorators/on_edited_bot_business_message.py b/pyrogram/methods/decorators/on_edited_bot_business_message.py index da0fe577..4cdce24d 100644 --- a/pyrogram/methods/decorators/on_edited_bot_business_message.py +++ b/pyrogram/methods/decorators/on_edited_bot_business_message.py @@ -37,9 +37,9 @@ def decorator(func: Callable) -> Callable: ) elif isinstance(self, Filter) or self is None: if not hasattr(func, "handlers"): - setattr(func, "handlers", []) + func.handlers = [] - getattr(func, "handlers").append( + func.handlers.append( ( pyrogram.handlers.EditedBotBusinessMessageHandler( func, diff --git a/pyrogram/methods/decorators/on_edited_message.py b/pyrogram/methods/decorators/on_edited_message.py index 32aca95e..8d433bb4 100644 --- a/pyrogram/methods/decorators/on_edited_message.py +++ b/pyrogram/methods/decorators/on_edited_message.py @@ -33,9 +33,9 @@ def decorator(func: Callable) -> Callable: ) elif isinstance(self, Filter) or self is None: if not hasattr(func, "handlers"): - setattr(func, "handlers", []) + func.handlers = [] - getattr(func, "handlers").append( + func.handlers.append( ( pyrogram.handlers.EditedMessageHandler(func, self), group if filters is None else filters, diff --git a/pyrogram/methods/decorators/on_inline_query.py b/pyrogram/methods/decorators/on_inline_query.py index 79bd3622..78e206a2 100644 --- a/pyrogram/methods/decorators/on_inline_query.py +++ b/pyrogram/methods/decorators/on_inline_query.py @@ -33,9 +33,9 @@ def decorator(func: Callable) -> Callable: ) elif isinstance(self, Filter) or self is None: if not hasattr(func, "handlers"): - setattr(func, "handlers", []) + func.handlers = [] - getattr(func, "handlers").append( + func.handlers.append( ( pyrogram.handlers.InlineQueryHandler(func, self), group if filters is None else filters, diff --git a/pyrogram/methods/decorators/on_message.py b/pyrogram/methods/decorators/on_message.py index 27d53441..c33404e8 100644 --- a/pyrogram/methods/decorators/on_message.py +++ b/pyrogram/methods/decorators/on_message.py @@ -33,9 +33,9 @@ def decorator(func: Callable) -> Callable: ) elif isinstance(self, Filter) or self is None: if not hasattr(func, "handlers"): - setattr(func, "handlers", []) + func.handlers = [] - getattr(func, "handlers").append( + func.handlers.append( ( pyrogram.handlers.MessageHandler(func, self), group if filters is None else filters, diff --git a/pyrogram/methods/decorators/on_message_reaction_count_updated.py b/pyrogram/methods/decorators/on_message_reaction_count_updated.py index 3bc00e08..5f6a8c0d 100644 --- a/pyrogram/methods/decorators/on_message_reaction_count_updated.py +++ b/pyrogram/methods/decorators/on_message_reaction_count_updated.py @@ -39,9 +39,9 @@ def decorator(func: Callable) -> Callable: ) elif isinstance(self, Filter) or self is None: if not hasattr(func, "handlers"): - setattr(func, "handlers", []) + func.handlers = [] - getattr(func, "handlers").append( + func.handlers.append( ( pyrogram.handlers.MessageReactionCountUpdatedHandler( func, diff --git a/pyrogram/methods/decorators/on_message_reaction_updated.py b/pyrogram/methods/decorators/on_message_reaction_updated.py index a4b698f1..23dabae3 100644 --- a/pyrogram/methods/decorators/on_message_reaction_updated.py +++ b/pyrogram/methods/decorators/on_message_reaction_updated.py @@ -36,9 +36,9 @@ def decorator(func: Callable) -> Callable: ) elif isinstance(self, Filter) or self is None: if not hasattr(func, "handlers"): - setattr(func, "handlers", []) + func.handlers = [] - getattr(func, "handlers").append( + func.handlers.append( ( pyrogram.handlers.MessageReactionUpdatedHandler(func, self), group if filters is None else filters, diff --git a/pyrogram/methods/decorators/on_poll.py b/pyrogram/methods/decorators/on_poll.py index ff703c2b..24d2d7ed 100644 --- a/pyrogram/methods/decorators/on_poll.py +++ b/pyrogram/methods/decorators/on_poll.py @@ -33,9 +33,9 @@ def decorator(func: Callable) -> Callable: ) elif isinstance(self, Filter) or self is None: if not hasattr(func, "handlers"): - setattr(func, "handlers", []) + func.handlers = [] - getattr(func, "handlers").append( + func.handlers.append( ( pyrogram.handlers.PollHandler(func, self), group if filters is None else filters, diff --git a/pyrogram/methods/decorators/on_pre_checkout_query.py b/pyrogram/methods/decorators/on_pre_checkout_query.py index f7b6f220..880a3d5b 100644 --- a/pyrogram/methods/decorators/on_pre_checkout_query.py +++ b/pyrogram/methods/decorators/on_pre_checkout_query.py @@ -37,9 +37,9 @@ def decorator(func: Callable) -> Callable: ) elif isinstance(self, Filter) or self is None: if not hasattr(func, "handlers"): - setattr(func, "handlers", []) + func.handlers = [] - getattr(func, "handlers").append( + func.handlers.append( ( pyrogram.handlers.PreCheckoutQueryHandler(func, self), group if filters is None else filters, diff --git a/pyrogram/methods/decorators/on_raw_update.py b/pyrogram/methods/decorators/on_raw_update.py index a5a16ca4..262c8040 100644 --- a/pyrogram/methods/decorators/on_raw_update.py +++ b/pyrogram/methods/decorators/on_raw_update.py @@ -25,9 +25,9 @@ def decorator(func: Callable) -> Callable: self.add_handler(pyrogram.handlers.RawUpdateHandler(func), group) else: if not hasattr(func, "handlers"): - setattr(func, "handlers", []) + func.handlers = [] - getattr(func, "handlers").append( + func.handlers.append( (pyrogram.handlers.RawUpdateHandler(func), group), ) diff --git a/pyrogram/methods/decorators/on_shipping_query.py b/pyrogram/methods/decorators/on_shipping_query.py index 6aecd6a1..4a83d0a6 100644 --- a/pyrogram/methods/decorators/on_shipping_query.py +++ b/pyrogram/methods/decorators/on_shipping_query.py @@ -38,9 +38,9 @@ def decorator(func: Callable) -> Callable: ) elif isinstance(self, Filter) or self is None: if not hasattr(func, "handlers"): - setattr(func, "handlers", []) + func.handlers = [] - getattr(func, "handlers").append( + func.handlers.append( ( pyrogram.handlers.ShippingQueryHandler(func, self), group if filters is None else filters, diff --git a/pyrogram/methods/decorators/on_story.py b/pyrogram/methods/decorators/on_story.py index 0e264c9b..d74d33c4 100644 --- a/pyrogram/methods/decorators/on_story.py +++ b/pyrogram/methods/decorators/on_story.py @@ -33,9 +33,9 @@ def decorator(func: Callable) -> Callable: ) elif isinstance(self, Filter) or self is None: if not hasattr(func, "handlers"): - setattr(func, "handlers", []) + func.handlers = [] - getattr(func, "handlers").append( + func.handlers.append( ( pyrogram.handlers.StoryHandler(func, self), group if filters is None else filters, diff --git a/pyrogram/methods/decorators/on_user_status.py b/pyrogram/methods/decorators/on_user_status.py index e43e98c3..087f5541 100644 --- a/pyrogram/methods/decorators/on_user_status.py +++ b/pyrogram/methods/decorators/on_user_status.py @@ -31,9 +31,9 @@ def decorator(func: Callable) -> Callable: ) elif isinstance(self, Filter) or self is None: if not hasattr(func, "handlers"): - setattr(func, "handlers", []) + func.handlers = [] - getattr(func, "handlers").append( + func.handlers.append( ( pyrogram.handlers.UserStatusHandler(func, self), group if filters is None else filters, diff --git a/pyrogram/methods/messages/edit_inline_media.py b/pyrogram/methods/messages/edit_inline_media.py index a3c30fcc..493d01e9 100644 --- a/pyrogram/methods/messages/edit_inline_media.py +++ b/pyrogram/methods/messages/edit_inline_media.py @@ -75,7 +75,7 @@ async def edit_inline_media( ) if is_bytes_io and not hasattr(media.media, "name"): - setattr(media.media, "name", "media") + media.media.name = "media" if is_uploaded_file: filename_attribute = [ diff --git a/pyrogram/types/user_and_chats/chat_event.py b/pyrogram/types/user_and_chats/chat_event.py index 5e4153fe..c0b0a0db 100644 --- a/pyrogram/types/user_and_chats/chat_event.py +++ b/pyrogram/types/user_and_chats/chat_event.py @@ -406,7 +406,9 @@ async def _parse( client, chats_map[action.prev_value], ) - new_linked_chat = types.Chat._parse_chat(client, chats_map[action.new_value]) + new_linked_chat = types.Chat._parse_chat( + client, chats_map[action.new_value] + ) action = enums.ChatEventAction.LINKED_CHAT_CHANGED elif isinstance(action, raw.types.ChannelAdminLogEventActionChangePhoto): From 6923f7fce976652de2fbfc06b8bf0361b9907e15 Mon Sep 17 00:00:00 2001 From: 5hojib Date: Sun, 22 Feb 2026 03:18:34 +0600 Subject: [PATCH 07/10] update pyproject.toml --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 52cf52e9..f7139851 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -136,3 +136,4 @@ ignore = [ [tool.ty.rules] unresolved-import = "ignore" +invalid-assignment = "ignore" \ No newline at end of file From c5aafaa3cffb2f6540db985b8eb4fcb1b7451759 Mon Sep 17 00:00:00 2001 From: Mehedi Hasan Shojib Date: Sun, 22 Feb 2026 05:45:47 +0600 Subject: [PATCH 08/10] Fix ty type checker errors (invalid-argument-type) and API compiler improvements (#93) * fix(ty): resolve several invalid-argument-type errors - Update `ChatInviteLink._parse` and `Chat._parse_chat` to accept `None` for optional data. - Fix `dict.get()` calls with potentially `None` keys in `ChatJoinRequest` and `ChatJoiner`. - Filter `None` values from entity lists in `Message._parse`. - Update `Message.markdown` and `Message.html` to handle missing entities. - Fix `Message.click` to correctly access `button.text`. - Update `EditMessageCaption` and `EditMessageMedia` to accept `None` for `invert_media`. - Fix API compiler to generate valid type hints for forward references using PEP 604 syntax. - Add `from __future__ import annotations` to generated raw API files. - Use `list` instead of `typing.List` in raw API templates. * fix(ty): resolve several invalid-argument-type errors - Update `ChatInviteLink._parse` and `Chat._parse_chat` to accept `None` for optional data. - Fix `dict.get()` calls with potentially `None` keys in `ChatJoinRequest` and `ChatJoiner`. - Filter `None` values from entity lists in `Message._parse`. - Update `Message.markdown` and `Message.html` to handle missing entities. - Fix `Message.click` to correctly access `button.text`. - Update `EditMessageCaption` and `EditMessageMedia` to accept `None` for `invert_media`. - Fix API compiler to generate valid type hints for forward references using PEP 604 syntax. - Add `from __future__ import annotations` to generated raw API files. - Use `list` instead of `typing.List` in raw API templates. --- compiler/api/compiler.py | 50 +++++++++++-------- compiler/api/template/combinator.txt | 6 ++- compiler/api/template/type.txt | 2 + pyrogram/client.py | 2 +- .../methods/messages/edit_message_caption.py | 2 +- .../methods/messages/edit_message_media.py | 2 +- pyrogram/types/messages_and_media/message.py | 41 +++++++++------ pyrogram/types/user_and_chats/chat.py | 5 +- pyrogram/types/user_and_chats/chat_event.py | 9 ++-- .../types/user_and_chats/chat_invite_link.py | 2 +- .../types/user_and_chats/chat_join_request.py | 5 +- pyrogram/types/user_and_chats/chat_joiner.py | 7 ++- 12 files changed, 85 insertions(+), 48 deletions(-) diff --git a/compiler/api/compiler.py b/compiler/api/compiler.py index 5173da17..a672b7e1 100644 --- a/compiler/api/compiler.py +++ b/compiler/api/compiler.py @@ -89,32 +89,40 @@ def camel(s: str): def get_type_hint(type: str) -> str: - is_flag = FLAGS_RE.match(type) + is_flag = bool(FLAGS_RE.match(type)) if is_flag: type = type.split("?")[1] - if type in CORE_TYPES: - if type == "long" or "int" in type: - type = "int" - elif type == "double": - type = "float" - elif type == "string": - type = "str" - elif type in {"Bool", "true"}: - type = "bool" - else: # bytes and object - type = "bytes" - elif type in {"Object", "!X"}: - type = "TLObject" - elif re.match("^vector", type, re.IGNORECASE): - sub_type = type.split("<")[1][:-1] - type = f"List[{get_type_hint(sub_type)}]" - else: - ns, name = type.split(".") if "." in type else ("", type) - type = '"raw.base.' + ".".join([ns, name]).strip(".") + '"' + def get_hint(t: str) -> str: + if t in CORE_TYPES: + if t == "long" or "int" in t: + return "int" + if t == "double": + return "float" + if t == "string": + return "str" + if t in {"Bool", "true"}: + return "bool" + return "bytes" + if t in {"Object", "!X"}: + return "TLObject" + if re.match("^vector", t, re.IGNORECASE): + sub_type = t.split("<", 1)[1][:-1] + return f"list[{get_hint(sub_type)}]" + ns, name = t.split(".") if "." in t else ("", t) + return "raw.base." + ".".join([ns, name]).strip(".") + + hint = get_hint(type) + + if is_flag: + if "raw.base" in hint: + return f'"{hint} | None" = None' + return f"{hint} | None = None" - return f"{type} | None = None" if is_flag else type + if "raw.base" in hint: + return f'"{hint}"' + return hint def sort_args(args: list[tuple[str, str]]): diff --git a/compiler/api/template/combinator.txt b/compiler/api/template/combinator.txt index 9599d321..9e938771 100644 --- a/compiler/api/template/combinator.txt +++ b/compiler/api/template/combinator.txt @@ -1,9 +1,11 @@ +from __future__ import annotations + from io import BytesIO from pyrogram.raw.core.primitives import Int, Long, Int128, Int256, Bool, Bytes, String, Double, Vector from pyrogram.raw.core import TLObject from pyrogram import raw -from typing import List, Optional, Any +from typing import Any {warning} @@ -12,7 +14,7 @@ class {name}({base}): # type: ignore """{docstring} """ - __slots__: List[str] = [{slots}] + __slots__: list[str] = [{slots}] ID = {id} QUALNAME = "{qualname}" diff --git a/compiler/api/template/type.txt b/compiler/api/template/type.txt index 2178b29a..1eb49db3 100644 --- a/compiler/api/template/type.txt +++ b/compiler/api/template/type.txt @@ -1,5 +1,7 @@ {warning} +from __future__ import annotations + from pyrogram.raw.core import TLObject class {name}(TLObject): # type: ignore diff --git a/pyrogram/client.py b/pyrogram/client.py index 5e8bcb3b..92154e55 100644 --- a/pyrogram/client.py +++ b/pyrogram/client.py @@ -663,7 +663,7 @@ async def handle_updates(self, updates) -> None: diff = await self.invoke( raw.functions.updates.GetChannelDifference( channel=await self.resolve_peer( - utils.get_channel_id(channel_id), + utils.get_channel_id(channel_id or 0), ), filter=raw.types.ChannelMessagesFilter( ranges=[ diff --git a/pyrogram/methods/messages/edit_message_caption.py b/pyrogram/methods/messages/edit_message_caption.py index 8928963c..3403e1d3 100644 --- a/pyrogram/methods/messages/edit_message_caption.py +++ b/pyrogram/methods/messages/edit_message_caption.py @@ -15,7 +15,7 @@ async def edit_message_caption( caption: str, parse_mode: enums.ParseMode | None = None, caption_entities: list[types.MessageEntity] | None = None, - invert_media: bool = False, + invert_media: bool | None = None, reply_markup: types.InlineKeyboardMarkup | None = None, business_connection_id: str | None = None, ) -> types.Message | None: diff --git a/pyrogram/methods/messages/edit_message_media.py b/pyrogram/methods/messages/edit_message_media.py index 3cf94bca..8257a801 100644 --- a/pyrogram/methods/messages/edit_message_media.py +++ b/pyrogram/methods/messages/edit_message_media.py @@ -22,7 +22,7 @@ async def edit_message_media( file_name: str | None = None, parse_mode: enums.ParseMode | None = None, business_connection_id: str | None = None, - invert_media: bool = False, + invert_media: bool | None = None, ) -> types.Message | None: """Edit animation, audio, document, photo or video messages, or replace text with animation, audio, document, photo or video messages. diff --git a/pyrogram/types/messages_and_media/message.py b/pyrogram/types/messages_and_media/message.py index b02a82d0..972ed829 100644 --- a/pyrogram/types/messages_and_media/message.py +++ b/pyrogram/types/messages_and_media/message.py @@ -33,11 +33,11 @@ def init(self, entities): @property def markdown(self): - return Parser.unparse(self, self.entities, False) + return Parser.unparse(self, self.entities or [], False) @property def html(self): - return Parser.unparse(self, self.entities, True) + return Parser.unparse(self, self.entities or [], True) def __getitem__(self, item): return parser_utils.remove_surrogates( @@ -1130,11 +1130,16 @@ async def _parse( # noqa: C901 if isinstance(message, raw.types.Message): message_thread_id = None - entities = [ - types.MessageEntity._parse(client, entity, users) - for entity in (message.entities or []) - ] - entities = types.List(filter(lambda x: x is not None, entities)) + entities = types.List( + [ + e + for e in [ + types.MessageEntity._parse(client, entity, users) + for entity in (message.entities or []) + ] + if e is not None + ], + ) sender_business_bot = None forward_from = None @@ -1516,12 +1521,17 @@ async def _parse( # noqa: C901 if isinstance(message.reply_to, raw.types.MessageReplyHeader): parsed_message.quote_text = message.reply_to.quote_text if message.reply_to.quote_entities: - quote_entities = [ - types.MessageEntity._parse(client, entity, users) - for entity in message.reply_to.quote_entities - ] parsed_message.quote_entities = types.List( - filter(lambda x: x is not None, quote_entities), + [ + e + for e in [ + types.MessageEntity._parse( + client, entity, users + ) + for entity in message.reply_to.quote_entities + ] + if e is not None + ], ) if message.reply_to.forum_topic: if message.reply_to.reply_to_top_id: @@ -5134,7 +5144,7 @@ async def copy( return await self._client.send_web_page( chat_id, url=self.web_page_preview.webpage.url, - text=self.text, + text=self.text or "", entities=self.entities, parse_mode=enums.ParseMode.DISABLED, large_media=self.web_page_preview.force_large_media, @@ -5387,7 +5397,10 @@ async def click( if button.switch_inline_query_current_chat: return button.switch_inline_query_current_chat raise ValueError("This button is not supported yet") - await self.reply(text=button, quote=quote) + await self.reply( + text=button if isinstance(button, str) else button.text, + quote=quote, + ) return None async def react( diff --git a/pyrogram/types/user_and_chats/chat.py b/pyrogram/types/user_and_chats/chat.py index b4062957..ca4bdf25 100644 --- a/pyrogram/types/user_and_chats/chat.py +++ b/pyrogram/types/user_and_chats/chat.py @@ -768,8 +768,11 @@ async def _parse_full( @staticmethod def _parse_chat( client, - chat: raw.types.Chat | raw.types.User | raw.types.Channel, + chat: raw.types.Chat | raw.types.User | raw.types.Channel | None, ) -> Chat | None: + if chat is None: + return None + if isinstance(chat, raw.types.Chat | raw.types.ChatForbidden): return Chat._parse_chat_chat(client, chat) if isinstance(chat, raw.types.User): diff --git a/pyrogram/types/user_and_chats/chat_event.py b/pyrogram/types/user_and_chats/chat_event.py index c0b0a0db..5a21cfe9 100644 --- a/pyrogram/types/user_and_chats/chat_event.py +++ b/pyrogram/types/user_and_chats/chat_event.py @@ -311,7 +311,7 @@ async def _parse( users_map = {i.id: i for i in users} chats_map = {i.id: i for i in chats} - user = types.User._parse(client, users_map[event.user_id]) + user = types.User._parse(client, users_map.get(event.user_id)) action = event.action old_description: str | None = None @@ -404,10 +404,11 @@ async def _parse( ): old_linked_chat = types.Chat._parse_chat( client, - chats_map[action.prev_value], + chats_map.get(action.prev_value), ) new_linked_chat = types.Chat._parse_chat( - client, chats_map[action.new_value] + client, + chats_map.get(action.new_value), ) action = enums.ChatEventAction.LINKED_CHAT_CHANGED @@ -632,7 +633,7 @@ async def _parse( raw.types.ChannelAdminLogEventActionParticipantJoinByRequest, ): invite_link = types.ChatInviteLink._parse(client, action.invite, users) - approver_user = types.User._parse(client, users_map[action.approved_by]) + approver_user = types.User._parse(client, users_map.get(action.approved_by)) action = enums.ChatEventAction.MEMBER_JOINED_BY_REQUEST elif isinstance( diff --git a/pyrogram/types/user_and_chats/chat_invite_link.py b/pyrogram/types/user_and_chats/chat_invite_link.py index 0fa3f410..4c4f5824 100644 --- a/pyrogram/types/user_and_chats/chat_invite_link.py +++ b/pyrogram/types/user_and_chats/chat_invite_link.py @@ -102,7 +102,7 @@ def __init__( @staticmethod def _parse( client: pyrogram.Client, - invite: raw.base.ExportedChatInvite, + invite: raw.base.ExportedChatInvite | None, users: dict[int, raw.types.User] | None = None, ) -> ChatInviteLink | None: if not isinstance(invite, raw.types.ChatInviteExported): diff --git a/pyrogram/types/user_and_chats/chat_join_request.py b/pyrogram/types/user_and_chats/chat_join_request.py index 8c739c8e..c06e9a4f 100644 --- a/pyrogram/types/user_and_chats/chat_join_request.py +++ b/pyrogram/types/user_and_chats/chat_join_request.py @@ -59,7 +59,10 @@ def _parse( chat_id = utils.get_raw_peer_id(update.peer) return ChatJoinRequest( - chat=types.Chat._parse_chat(client, chats.get(chat_id)), + chat=types.Chat._parse_chat( + client, + chats.get(chat_id) if chat_id is not None else None, + ), from_user=types.User._parse(client, users.get(update.user_id)), date=utils.timestamp_to_datetime(getattr(update, "date", None)), bio=getattr(update, "about", None), diff --git a/pyrogram/types/user_and_chats/chat_joiner.py b/pyrogram/types/user_and_chats/chat_joiner.py index 0841946f..a16f0ab1 100644 --- a/pyrogram/types/user_and_chats/chat_joiner.py +++ b/pyrogram/types/user_and_chats/chat_joiner.py @@ -63,7 +63,12 @@ def _parse( pending=getattr(joiner, "requested", None), bio=getattr(joiner, "about", None), approved_by=( - types.User._parse(client, users.get(joiner.approved_by)) + types.User._parse( + client, + users.get(joiner.approved_by) + if joiner.approved_by is not None + else None, + ) if getattr(joiner, "approved_by", None) else None ), From 7f2a6169da83a0e4beeb3fa8aeab1b5f939e57e5 Mon Sep 17 00:00:00 2001 From: 5hojib Date: Sat, 21 Feb 2026 23:46:06 +0000 Subject: [PATCH 09/10] InkyPinkyPonky [no ci] Signed-off-by: 5hojib --- pyrogram/types/messages_and_media/message.py | 4 +--- pyrogram/types/user_and_chats/chat_event.py | 4 +++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pyrogram/types/messages_and_media/message.py b/pyrogram/types/messages_and_media/message.py index 972ed829..4619fc8e 100644 --- a/pyrogram/types/messages_and_media/message.py +++ b/pyrogram/types/messages_and_media/message.py @@ -1525,9 +1525,7 @@ async def _parse( # noqa: C901 [ e for e in [ - types.MessageEntity._parse( - client, entity, users - ) + types.MessageEntity._parse(client, entity, users) for entity in message.reply_to.quote_entities ] if e is not None diff --git a/pyrogram/types/user_and_chats/chat_event.py b/pyrogram/types/user_and_chats/chat_event.py index 5a21cfe9..f19a1351 100644 --- a/pyrogram/types/user_and_chats/chat_event.py +++ b/pyrogram/types/user_and_chats/chat_event.py @@ -633,7 +633,9 @@ async def _parse( raw.types.ChannelAdminLogEventActionParticipantJoinByRequest, ): invite_link = types.ChatInviteLink._parse(client, action.invite, users) - approver_user = types.User._parse(client, users_map.get(action.approved_by)) + approver_user = types.User._parse( + client, users_map.get(action.approved_by) + ) action = enums.ChatEventAction.MEMBER_JOINED_BY_REQUEST elif isinstance( From 00e7d9e392bd7fd94feba6c2f3253712dd545f2b Mon Sep 17 00:00:00 2001 From: Mehedi Hasan Shojib Date: Sun, 22 Feb 2026 10:17:39 +0600 Subject: [PATCH 10/10] Update compiler/api/compiler.py Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- compiler/api/compiler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/api/compiler.py b/compiler/api/compiler.py index a672b7e1..ae2ea999 100644 --- a/compiler/api/compiler.py +++ b/compiler/api/compiler.py @@ -96,7 +96,7 @@ def get_type_hint(type: str) -> str: def get_hint(t: str) -> str: if t in CORE_TYPES: - if t == "long" or "int" in t: + if t in {"long", "int", "int128", "int256"}: return "int" if t == "double": return "float"