From 921800f90252a60c946abee710039e3222343561 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Fri, 22 Mar 2019 11:53:25 +0100 Subject: [PATCH] Clean up docstrings --- .../methods/bots/request_callback_answer.py | 4 ++-- pyrogram/client/methods/chats/get_chat.py | 5 +++-- pyrogram/client/methods/chats/get_dialogs.py | 2 +- .../methods/chats/restrict_chat_member.py | 7 ++++--- .../methods/contacts/delete_contacts.py | 2 +- .../methods/decorators/on_callback_query.py | 5 ++--- .../methods/decorators/on_deleted_messages.py | 5 ++--- .../methods/decorators/on_disconnect.py | 5 ++--- .../methods/decorators/on_inline_query.py | 5 ++--- .../client/methods/decorators/on_message.py | 5 ++--- .../methods/decorators/on_raw_update.py | 5 ++--- .../methods/decorators/on_user_status.py | 5 ++--- .../methods/messages/delete_messages.py | 4 +++- .../client/methods/messages/download_media.py | 2 +- .../users/delete_user_profile_photos.py | 2 +- pyrogram/client/types/bots/force_reply.py | 5 +++-- .../types/bots/reply_keyboard_remove.py | 7 +++---- .../client/types/input_media/input_media.py | 21 ++++++++++++------- .../types/input_media/input_phone_contact.py | 12 ++++------- .../types/messages_and_media/video_note.py | 2 +- .../client/types/user_and_chats/dialogs.py | 2 +- 21 files changed, 56 insertions(+), 56 deletions(-) diff --git a/pyrogram/client/methods/bots/request_callback_answer.py b/pyrogram/client/methods/bots/request_callback_answer.py index 0d440fd9..87247126 100644 --- a/pyrogram/client/methods/bots/request_callback_answer.py +++ b/pyrogram/client/methods/bots/request_callback_answer.py @@ -29,8 +29,8 @@ class RequestCallbackAnswer(BaseClient): message_id: int, callback_data: bytes ): - """Use this method to request a callback answer from bots. This is the equivalent of clicking an - inline button containing callback data. + """Use this method to request a callback answer from bots. + This is the equivalent of clicking an inline button containing callback data. Args: chat_id (``int`` | ``str``): diff --git a/pyrogram/client/methods/chats/get_chat.py b/pyrogram/client/methods/chats/get_chat.py index 89a72722..31e0a293 100644 --- a/pyrogram/client/methods/chats/get_chat.py +++ b/pyrogram/client/methods/chats/get_chat.py @@ -28,8 +28,9 @@ class GetChat(BaseClient): self, chat_id: Union[int, str] ) -> "pyrogram.Chat": - """Use this method to get up to date information about the chat (current name of the user for - one-on-one conversations, current username of a user, group or channel, etc.) + """Use this method to get up to date information about the chat. + Information include current name of the user for one-on-one conversations, current username of a user, group or + channel, etc. Args: chat_id (``int`` | ``str``): diff --git a/pyrogram/client/methods/chats/get_dialogs.py b/pyrogram/client/methods/chats/get_dialogs.py index b73d0efa..e062a00b 100644 --- a/pyrogram/client/methods/chats/get_dialogs.py +++ b/pyrogram/client/methods/chats/get_dialogs.py @@ -34,7 +34,7 @@ class GetDialogs(BaseClient): limit: int = 100, pinned_only: bool = False ) -> "pyrogram.Dialogs": - """Use this method to get a chunk of the user's dialogs + """Use this method to get a chunk of the user's dialogs. You can get up to 100 dialogs at once. For a more convenient way of getting a user's dialogs see :meth:`iter_dialogs`. diff --git a/pyrogram/client/methods/chats/restrict_chat_member.py b/pyrogram/client/methods/chats/restrict_chat_member.py index d75d1fa4..72788188 100644 --- a/pyrogram/client/methods/chats/restrict_chat_member.py +++ b/pyrogram/client/methods/chats/restrict_chat_member.py @@ -38,9 +38,10 @@ class RestrictChatMember(BaseClient): can_invite_users: bool = False, can_pin_messages: bool = False ) -> Chat: - """Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for - this to work and must have the appropriate admin rights. Pass True for all boolean parameters to lift - restrictions from a user. + """Use this method to restrict a user in a supergroup. + + The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights. + Pass True for all boolean parameters to lift restrictions from a user. Args: chat_id (``int`` | ``str``): diff --git a/pyrogram/client/methods/contacts/delete_contacts.py b/pyrogram/client/methods/contacts/delete_contacts.py index c7e7c0e6..7ac6d02a 100644 --- a/pyrogram/client/methods/contacts/delete_contacts.py +++ b/pyrogram/client/methods/contacts/delete_contacts.py @@ -28,7 +28,7 @@ class DeleteContacts(BaseClient): self, ids: List[int] ): - """Use this method to delete contacts from your Telegram address book + """Use this method to delete contacts from your Telegram address book. Args: ids (List of ``int``): diff --git a/pyrogram/client/methods/decorators/on_callback_query.py b/pyrogram/client/methods/decorators/on_callback_query.py index f030f929..18aed7d5 100644 --- a/pyrogram/client/methods/decorators/on_callback_query.py +++ b/pyrogram/client/methods/decorators/on_callback_query.py @@ -30,9 +30,8 @@ class OnCallbackQuery(BaseClient): filters=None, group: int = 0 ) -> callable: - """Use this decorator to automatically register a function for handling - callback queries. This does the same thing as :meth:`add_handler` using the - :class:`CallbackQueryHandler`. + """Use this decorator to automatically register a function for handling callback queries. + This does the same thing as :meth:`add_handler` using the :class:`CallbackQueryHandler`. .. note:: This decorator will wrap your defined function in a tuple consisting of *(Handler, group)*. diff --git a/pyrogram/client/methods/decorators/on_deleted_messages.py b/pyrogram/client/methods/decorators/on_deleted_messages.py index b5a95381..b32889ef 100644 --- a/pyrogram/client/methods/decorators/on_deleted_messages.py +++ b/pyrogram/client/methods/decorators/on_deleted_messages.py @@ -30,9 +30,8 @@ class OnDeletedMessages(BaseClient): filters=None, group: int = 0 ) -> callable: - """Use this decorator to automatically register a function for handling - deleted messages. This does the same thing as :meth:`add_handler` using the - :class:`DeletedMessagesHandler`. + """Use this decorator to automatically register a function for handling deleted messages. + This does the same thing as :meth:`add_handler` using the :class:`DeletedMessagesHandler`. .. note:: This decorator will wrap your defined function in a tuple consisting of *(Handler, group)*. diff --git a/pyrogram/client/methods/decorators/on_disconnect.py b/pyrogram/client/methods/decorators/on_disconnect.py index 4657af3b..515a28c1 100644 --- a/pyrogram/client/methods/decorators/on_disconnect.py +++ b/pyrogram/client/methods/decorators/on_disconnect.py @@ -23,9 +23,8 @@ from ...ext import BaseClient class OnDisconnect(BaseClient): def on_disconnect(self=None) -> callable: - """Use this decorator to automatically register a function for handling - disconnections. This does the same thing as :meth:`add_handler` using the - :class:`DisconnectHandler`. + """Use this decorator to automatically register a function for handling disconnections. + This does the same thing as :meth:`add_handler` using the :class:`DisconnectHandler`. """ def decorator(func: callable) -> Handler: diff --git a/pyrogram/client/methods/decorators/on_inline_query.py b/pyrogram/client/methods/decorators/on_inline_query.py index d4e96261..81f0f676 100644 --- a/pyrogram/client/methods/decorators/on_inline_query.py +++ b/pyrogram/client/methods/decorators/on_inline_query.py @@ -30,9 +30,8 @@ class OnInlineQuery(BaseClient): filters=None, group: int = 0 ) -> callable: - """Use this decorator to automatically register a function for handling - inline queries. This does the same thing as :meth:`add_handler` using the - :class:`InlineQueryHandler`. + """Use this decorator to automatically register a function for handling inline queries. + This does the same thing as :meth:`add_handler` using the :class:`InlineQueryHandler`. Args: filters (:obj:`Filters `): diff --git a/pyrogram/client/methods/decorators/on_message.py b/pyrogram/client/methods/decorators/on_message.py index 41eb73e5..9bbd96c1 100644 --- a/pyrogram/client/methods/decorators/on_message.py +++ b/pyrogram/client/methods/decorators/on_message.py @@ -30,9 +30,8 @@ class OnMessage(BaseClient): filters=None, group: int = 0 ) -> callable: - """Use this decorator to automatically register a function for handling - messages. This does the same thing as :meth:`add_handler` using the - :class:`MessageHandler`. + """Use this decorator to automatically register a function for handling messages. + This does the same thing as :meth:`add_handler` using the :class:`MessageHandler`. .. note:: This decorator will wrap your defined function in a tuple consisting of *(Handler, group)*. diff --git a/pyrogram/client/methods/decorators/on_raw_update.py b/pyrogram/client/methods/decorators/on_raw_update.py index a176ab50..cf1da94d 100644 --- a/pyrogram/client/methods/decorators/on_raw_update.py +++ b/pyrogram/client/methods/decorators/on_raw_update.py @@ -28,9 +28,8 @@ class OnRawUpdate(BaseClient): self=None, group: int = 0 ) -> callable: - """Use this decorator to automatically register a function for handling - raw updates. This does the same thing as :meth:`add_handler` using the - :class:`RawUpdateHandler`. + """Use this decorator to automatically register a function for handling raw updates. + This does the same thing as :meth:`add_handler` using the :class:`RawUpdateHandler`. .. note:: This decorator will wrap your defined function in a tuple consisting of *(Handler, group)*. diff --git a/pyrogram/client/methods/decorators/on_user_status.py b/pyrogram/client/methods/decorators/on_user_status.py index 580dc498..5f962270 100644 --- a/pyrogram/client/methods/decorators/on_user_status.py +++ b/pyrogram/client/methods/decorators/on_user_status.py @@ -30,9 +30,8 @@ class OnUserStatus(BaseClient): filters=None, group: int = 0 ) -> callable: - """Use this decorator to automatically register a function for handling - user status updates. This does the same thing as :meth:`add_handler` using the - :class:`UserStatusHandler`. + """Use this decorator to automatically register a function for handling user status updates. + This does the same thing as :meth:`add_handler` using the :class:`UserStatusHandler`. .. note:: This decorator will wrap your defined function in a tuple consisting of *(Handler, group)*. diff --git a/pyrogram/client/methods/messages/delete_messages.py b/pyrogram/client/methods/messages/delete_messages.py index 8ea729ff..df26aff6 100644 --- a/pyrogram/client/methods/messages/delete_messages.py +++ b/pyrogram/client/methods/messages/delete_messages.py @@ -29,7 +29,9 @@ class DeleteMessages(BaseClient): message_ids: Iterable[int], revoke: bool = True ) -> bool: - """Use this method to delete messages, including service messages, with the following limitations: + """Use this method to delete messages, including service messages. + + Deleting messages have the following limitations: - A message can only be deleted if it was sent less than 48 hours ago. - Users can delete outgoing messages in groups and supergroups. diff --git a/pyrogram/client/methods/messages/download_media.py b/pyrogram/client/methods/messages/download_media.py index 29ba7af5..6fc47601 100644 --- a/pyrogram/client/methods/messages/download_media.py +++ b/pyrogram/client/methods/messages/download_media.py @@ -32,7 +32,7 @@ class DownloadMedia(BaseClient): progress: callable = None, progress_args: tuple = () ) -> Union[str, None]: - """Use this method to download the media from a Message. + """Use this method to download the media from a message. Args: message (:obj:`Message ` | ``str``): diff --git a/pyrogram/client/methods/users/delete_user_profile_photos.py b/pyrogram/client/methods/users/delete_user_profile_photos.py index 84c68dd4..6c0eb8d2 100644 --- a/pyrogram/client/methods/users/delete_user_profile_photos.py +++ b/pyrogram/client/methods/users/delete_user_profile_photos.py @@ -29,7 +29,7 @@ class DeleteUserProfilePhotos(BaseClient): self, id: Union[str, List[str]] ) -> bool: - """Use this method to delete your own profile photos + """Use this method to delete your own profile photos. Args: id (``str`` | ``list``): diff --git a/pyrogram/client/types/bots/force_reply.py b/pyrogram/client/types/bots/force_reply.py index fca2c061..12969742 100644 --- a/pyrogram/client/types/bots/force_reply.py +++ b/pyrogram/client/types/bots/force_reply.py @@ -21,8 +21,9 @@ from ..pyrogram_type import PyrogramType class ForceReply(PyrogramType): - """Upon receiving a message with this object, Telegram clients will display a reply interface to the user - (act as if the user has selected the bot's message and tapped 'Reply'). + """Upon receiving a message with this object, Telegram clients will display a reply interface to the user. + + This acts as if the user has selected the bot's message and tapped "Reply". This can be extremely useful if you want to create user-friendly step-by-step interfaces without having to sacrifice privacy mode. diff --git a/pyrogram/client/types/bots/reply_keyboard_remove.py b/pyrogram/client/types/bots/reply_keyboard_remove.py index 3298ab6f..75f2a7b5 100644 --- a/pyrogram/client/types/bots/reply_keyboard_remove.py +++ b/pyrogram/client/types/bots/reply_keyboard_remove.py @@ -21,10 +21,9 @@ from ..pyrogram_type import PyrogramType class ReplyKeyboardRemove(PyrogramType): - """Upon receiving a message with this object, Telegram clients will remove the current custom keyboard and - display the default letter-keyboard. By default, custom keyboards are displayed until a new keyboard is sent - by a bot. An exception is made for one-time keyboards that are hidden immediately after the user presses a - button (see ReplyKeyboardMarkup). + """Upon receiving a message with this object, Telegram clients will remove the current custom keyboard and display the default letter-keyboard. + By default, custom keyboards are displayed until a new keyboard is sent by a bot. An exception is made for one-time + keyboards that are hidden immediately after the user presses a button (see ReplyKeyboardMarkup). Args: selective (``bool``, *optional*): diff --git a/pyrogram/client/types/input_media/input_media.py b/pyrogram/client/types/input_media/input_media.py index aeeef350..3062f136 100644 --- a/pyrogram/client/types/input_media/input_media.py +++ b/pyrogram/client/types/input_media/input_media.py @@ -16,16 +16,23 @@ # You should have received a copy of the GNU Lesser General Public License # along with Pyrogram. If not, see . +from ..pyrogram_type import PyrogramType -class InputMedia: + +class InputMedia(PyrogramType): + """This object represents the content of a media message to be sent. It should be one of: + + - :obj:`InputMediaAnimation ` + - :obj:`InputMediaDocument ` + - :obj:`InputMediaAudio ` + - :obj:`InputMediaPhoto ` + - :obj:`InputMediaVideo ` + """ __slots__ = ["media", "caption", "parse_mode"] - def __init__( - self, - media: str, - caption: str, - parse_mode: str - ): + def __init__(self, media: str, caption: str, parse_mode: str): + super().__init__(None) + self.media = media self.caption = caption self.parse_mode = parse_mode diff --git a/pyrogram/client/types/input_media/input_phone_contact.py b/pyrogram/client/types/input_media/input_phone_contact.py index 4fe7ee60..d2ac8012 100644 --- a/pyrogram/client/types/input_media/input_phone_contact.py +++ b/pyrogram/client/types/input_media/input_phone_contact.py @@ -18,9 +18,10 @@ from pyrogram.api.types import InputPhoneContact as RawInputPhoneContact from pyrogram.session.internals import MsgId +from ..pyrogram_type import PyrogramType -class InputPhoneContact: +class InputPhoneContact(PyrogramType): """This object represents a Phone Contact to be added in your Telegram address book. It is intended to be used with :meth:`add_contacts() ` @@ -37,13 +38,8 @@ class InputPhoneContact: __slots__ = [] - def __init__( - self, - phone: str, - first_name: str, - last_name: str = "" - ): - pass + def __init__(self, phone: str, first_name: str, last_name: str = ""): + super().__init__(None) def __new__(cls, phone: str, diff --git a/pyrogram/client/types/messages_and_media/video_note.py b/pyrogram/client/types/messages_and_media/video_note.py index a1b3856c..e6c2ab31 100644 --- a/pyrogram/client/types/messages_and_media/video_note.py +++ b/pyrogram/client/types/messages_and_media/video_note.py @@ -26,7 +26,7 @@ from ...ext.utils import encode class VideoNote(PyrogramType): - """This object represents a video message (available in Telegram apps as of v.4.0). + """This object represents a video note. Args: file_id (``str``): diff --git a/pyrogram/client/types/user_and_chats/dialogs.py b/pyrogram/client/types/user_and_chats/dialogs.py index bd29ea83..431cca8d 100644 --- a/pyrogram/client/types/user_and_chats/dialogs.py +++ b/pyrogram/client/types/user_and_chats/dialogs.py @@ -26,7 +26,7 @@ from ..pyrogram_type import PyrogramType class Dialogs(PyrogramType): - """This object represents a user's dialogs chunk + """This object represents a user's dialogs chunk. Args: total_count (``int``):