-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Docs update #728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docs update #728
Conversation
WebhookInfo User UserProfilePhotos WebhookInfo Update User UserProfilePhotos WebhookInfo ReplyKeyboardRemove ReplyKeyboardRemove small typo ReplyKeyboardMarkup MessageEntity Message KeyboardButton ForceReply Errors Constants ChosenInlineResult ChatMember ChatAction MessageEntity.rst Chat CallbackQuery Base
InlineKeyboardButton InlineKeyboardMarkup InlineQuery InlineQueryResult InlineQueryResultArticle InlineQueryResultAudio InlineQueryResultArticle InlineQueryResultAudio InlineQueryResultCachedAudio InlineQueryResultCachedDocument InlineQueryResultCachedGif InlineQueryResultCachedMpeg4Gif InlineQueryResultCachedPhoto InlineQueryResultCachedSticker InlineQueryResultCachedVideo InlineQueryResultCachedVoice InlineQueryResultContact InlineQueryResultDocument InlineQueryResultGame InlineQueryResultGif InlineQueryResultLocation InlineQueryResultMpeg4Gif InlineQueryResultPhoto InlineQueryResultVenue InlineQueryResultVideo InlineQueryResultVoice InputContactMessageContent InputLocationMessageContent InputMessageContent InputTextMessageContent InputVenueMessageContent
CommandHandler InlineQueryHandler MessageHandler
Updated all new docs in new style
In #726 I added a note on where to find the max message length in |
@rahiel Because Max message length is now in the docstring for every text message method |
Regarding the questions @bomjacob asked:
|
|
I wasn't know with the typing stuff. Now I've seen it I aggree on 7 and 8. Will make try how it looks. |
All classes and methods now use the google style guide for docstrings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay that should be my last comments as far as docstring and code goes (haven't looked at rst files since you said those weren't done yet.
I know it looks like a butt-ton of comments, but most of them are fairly trivial :)
telegram/bot.py
Outdated
chat_id (:obj:`int` | :obj:`float`): Unique identifier for the target chat or username | ||
of the target channel (in the format @channelusername). | ||
text (:obj:`str`): Text of the message to be sent. Max 4096 characters. Also found as | ||
``telegram.constants.MAX_MESSAGE_LENGTH``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:const:`telegram.constants.MAX_MESSAGE_LENGTH`
(also found elsewhere, search for "4096")
telegram/bot.py
Outdated
@channelusername). | ||
message_id (int): Unique message identifier. | ||
timeout (Optional[int|float]): If this value is specified, use it as the read timeout | ||
chat_id (:obj:`int` | :obj:`float`): Unique identifier for the target chat or username |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you mean :obj:`int` | :obj:`str`
(also applies elsewhere)
telegram/bot.py
Outdated
"""As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute | ||
long. Use this method to send video messages | ||
""" | ||
As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first line should describe what the method does. Either flip around the lines or in this case simply remove it.
telegram/bot.py
Outdated
action(:class:`telegram.ChatAction` | :obj:`str`): Type of action to broadcast. Choose | ||
one, depending on what the user is about to receive: | ||
|
||
* typing for text messages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The constants are preferred here I'd say
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method doesn't care, so I put it this way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would very very much like to encourage our users to use the constants though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed doc to remove the list from this method and point to ChatAction
telegram/base.py
Outdated
@@ -84,7 +76,7 @@ def to_dict(self): | |||
def __eq__(self, other): | |||
if isinstance(other, self.__class__): | |||
return self._id_attrs == other._id_attrs | |||
return super(TelegramObject, self).__eq__(other) | |||
return super(TelegramObject, self).__eq__(other) # pylint: disable=E1101 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you maybe use the new named pylint names instead of the id?
# pylint: disable=no-member
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imo out of scope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of scope of this PR? You added the comment though... I'm not asking you to go back and find all our pylint lines, I'm just thinking that we should start slowly switching over so we make it easier for ourselves in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're right (forgot I put this in)
""" | ||
|
||
def __init__(self, | ||
id, | ||
first_name, | ||
type=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means that we break backwards compat doesn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
users are created by tg which does not send type. So I guess not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still technically do though... @tsnoam thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not break tests and users have no type, so I see no problem in just removing it. It's still captured with **kwargs if needed.
telegram/ext/typehandler.py
Outdated
|
||
|
||
class TypeHandler(Handler): | ||
""" | ||
Handler class to handle updates of custom types. | ||
|
||
Attributes: | ||
type (:obj:`class`): The ``type`` of updates this handler should process. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't that be of type type
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit of a weird handler. You use it like:
import InlineQuery
add_handler(TypeHandler(InlineQuery))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly you pass it a class which has the type type
>>> class Test:
... pass
...
>>> type(Test)
<class 'type'>
>>>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! ok, will change
Args: | ||
latitude (:obj:`float`): Latitude of the location in degrees. | ||
longitude (:obj:`float`): Longitude of the location in degrees. | ||
title (:obj:`str`); Name of the venue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Semi colon?
(also applies elsewhere (a search for ;
is fairly quick)
telegram/forcereply.py
Outdated
selective (:obj:`bool`, optional): Use this parameter if you want to force reply from | ||
specific users only. Targets: | ||
|
||
1) users that are @mentioned in the text of the Message object; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove semi colon
shipping_query (:class:`telegram.ShippingQuery`): New incoming shipping query. | ||
pre_checkout_query (:class:`telegram.PreCheckoutQuery`): New incoming pre-checkout query. | ||
Note: | ||
At most one of the optional parameters can be present in any given update. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- "With the exception of update_id which is always present."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's why it's "at most one of the optional parameters..."
@@ -44,7 +44,7 @@ class PreCheckoutQueryHandler(Handler): | |||
or in the same chat, it will be the same ``dict``. | |||
|
|||
Args: | |||
callback (:obj:`callable): A function that takes ``bot, update`` as positional arguments. | |||
callback (:obj:`callable'): A function that takes ``bot, update`` as positional arguments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that a ' instead of `?
@@ -27,7 +27,8 @@ class InlineKeyboardButton(TelegramObject): | |||
This object represents one button of an inline keyboard. | |||
|
|||
Note: | |||
You must use exactly one of the optional fields. | |||
You must use exactly one of the optional fields. Mind that :attr:`callback_game` is not |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't true though. callback_game the attribute is implemented, but it just accepts a games short name I think, otherwise there would be no way to launch games from custom keyboards.
restored old order of kwargs in regexhandler added deprecation warning
Parameter to StickerSet was flasely named on TG's docs as is_masks. It's fixed now.
Conflicts: CHANGES.rst telegram/base.py telegram/bot.py telegram/callbackquery.py telegram/chat.py telegram/chatmember.py telegram/choseninlineresult.py telegram/files/audio.py telegram/files/chatphoto.py telegram/files/contact.py telegram/files/document.py telegram/files/file.py telegram/files/location.py telegram/files/photosize.py telegram/files/sticker.py telegram/files/video.py telegram/files/videonote.py telegram/files/voice.py telegram/forcereply.py telegram/games/animation.py telegram/games/game.py telegram/games/gamehighscore.py telegram/inline/inlinekeyboardbutton.py telegram/inline/inlinekeyboardmarkup.py telegram/inline/inlinequery.py telegram/message.py telegram/messageentity.py telegram/payment/invoice.py telegram/payment/labeledprice.py telegram/payment/orderinfo.py telegram/payment/precheckoutquery.py telegram/payment/shippingaddress.py telegram/payment/shippingoption.py telegram/payment/shippingquery.py telegram/payment/successfulpayment.py telegram/replykeyboardmarkup.py telegram/replykeyboardremove.py telegram/replymarkup.py telegram/update.py telegram/user.py telegram/userprofilephotos.py telegram/webhookinfo.py
So here it is. All new and unified docs.
There might be some small spelling errors (if you find them please notify me).
It's a moloch of a pull request but I already included latest master (and updated the docstrings for new methods).