Skip to content

Documentation Improvements #3103

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

Merged
merged 16 commits into from
Jun 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ The following wonderful people contributed directly or indirectly to this projec
- `Evan Haberecht <https://github.com/habereet>`_
- `Evgeny Denisov <https://github.com/eIGato>`_
- `evgfilim1 <https://github.com/evgfilim1>`_
- `ExalFabu <https://github.com/ExalFabu>`_
- `franciscod <https://github.com/franciscod>`_
- `gamgi <https://github.com/gamgi>`_
- `Gauthamram Ravichandran <https://github.com/GauthamramRavichandran>`_
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
:target: https://github.com/python-telegram-bot/python-telegram-bot/
:alt: Github Actions workflow

.. image:: https://app.codecov.io/gh/python-telegram-bot/python-telegram-bot/branch/master/graph/badge.svg
.. image:: https://codecov.io/gh/python-telegram-bot/python-telegram-bot/branch/master/graph/badge.svg
:target: https://app.codecov.io/gh/python-telegram-bot/python-telegram-bot
:alt: Code coverage

Expand Down Expand Up @@ -149,7 +149,7 @@ Resources
=========

- The `package documentation <https://docs.python-telegram-bot.org/>`_ is the technical reference for ``python-telegram-bot``.
It contains descriptions of all available classes, modules, methods and arguments.
It contains descriptions of all available classes, modules, methods and arguments as well as the `changelog <https://docs.python-telegram-bot.org/changelog.html>`_.
- The `wiki <https://github.com/python-telegram-bot/python-telegram-bot/wiki/>`_ is home to number of more elaborate introductions of the different features of ``python-telegram-bot`` and other useful resources that go beyond the technical documentation.
- Our `examples section <https://docs.python-telegram-bot.org/examples.html>`_ contains several examples that showcase the different features of both the Bot API and ``python-telegram-bot``.
Even if it is not your approach for learning, please take a look at ``echobot.py``. It is the de facto base for most of the bots out there.
Expand Down
4 changes: 2 additions & 2 deletions README_RAW.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
:target: https://github.com/python-telegram-bot/python-telegram-bot/
:alt: Github Actions workflow

.. image:: https://app.codecov.io/gh/python-telegram-bot/python-telegram-bot/branch/master/graph/badge.svg
.. image:: https://app.codecov.io/gh/python-telegram-bot/python-telegram-bot
:target: https://app.codecov.io/gh/python-telegram-bot/python-telegram-bot
:alt: Code coverage

Expand Down Expand Up @@ -146,7 +146,7 @@ Resources
=========

- The `package documentation <https://docs.python-telegram-bot.org/>`_ is the technical reference for ``python-telegram-bot``.
It contains descriptions of all available classes, modules, methods and arguments.
It contains descriptions of all available classes, modules, methods and arguments as well as the `changelog <https://docs.python-telegram-bot.org/changelog.html>`_.
- The `wiki <https://github.com/python-telegram-bot/python-telegram-bot/wiki/>`_ is home to number of more elaborate introductions of the different features of ``python-telegram-bot`` and other useful resources that go beyond the technical documentation.
- Our `examples section <https://docs.python-telegram-bot.org/examples.html>`_ contains several examples that showcase the different features of both the Bot API and ``python-telegram-bot``.
Even if it is not your approach for learning, please take a look at ``echobot.py``. It is the de facto base for most of the bots out there.
Expand Down
4 changes: 2 additions & 2 deletions docs/requirements-docs.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
sphinx==5.0.1
sphinx==5.0.2
sphinx-pypi-upload
furo==2022.6.4.1
furo==2022.6.21
sphinx-paramlinks==0.5.4
sphinxcontrib-mermaid==0.7.1
66 changes: 44 additions & 22 deletions telegram/_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1612,7 +1612,7 @@ async def send_animation(
changed in the future.

Note:
``thumb`` will be ignored for small files, for which Telegram can easily
:paramref:`thumb` will be ignored for small files, for which Telegram can easily
generate thumb nails. However, this behaviour is undocumented and might be changed
by Telegram.

Expand Down Expand Up @@ -3025,7 +3025,8 @@ async def ban_chat_member(
seconds from the current time they are considered to be banned forever. Applied
for supergroups and channels only.
For timezone naive :obj:`datetime.datetime` objects, the default timezone of the
bot will be used.
bot will be used, which is UTC unless :attr:`telegram.ext.Defaults.tzinfo` is
used.
revoke_messages (:obj:`bool`, optional): Pass :obj:`True` to delete all messages from
the chat for the user that is being removed. If :obj:`False`, the user will be able
to see messages in the group that were sent before the user was removed.
Expand Down Expand Up @@ -3373,6 +3374,10 @@ async def edit_message_text(
"""
Use this method to edit text and game messages.

Note:
It is currently only possible to edit messages without
:attr:`telegram.Message.reply_markup` or with inline keyboards.

Args:
chat_id (:obj:`int` | :obj:`str`, optional): Required if inline_message_id is not
specified. Unique identifier for the target chat or username of the target channel
Expand Down Expand Up @@ -3465,6 +3470,10 @@ async def edit_message_caption(
"""
Use this method to edit captions of messages.

Note:
It is currently only possible to edit messages without
:attr:`telegram.Message.reply_markup` or with inline keyboards

Args:
chat_id (:obj:`int` | :obj:`str`, optional): Required if inline_message_id is not
specified. Unique identifier for the target chat or username of the target channel
Expand Down Expand Up @@ -3553,7 +3562,11 @@ async def edit_message_media(
is part of a message album, then it can be edited only to an audio for audio albums, only
to a document for document albums and to a photo or a video otherwise. When an inline
message is edited, a new file can't be uploaded; use a previously uploaded file via its
``file_id`` or specify a URL.
:attr:`~telegram.File.file_id` or specify a URL.

Note:
It is currently only possible to edit messages without
:attr:`telegram.Message.reply_markup` or with inline keyboards

Args:
media (:class:`telegram.InputMedia`): An object for a new media content
Expand Down Expand Up @@ -3629,6 +3642,10 @@ async def edit_message_reply_markup(
Use this method to edit only the reply markup of messages sent by the bot or via the bot
(for inline bots).

Note:
It is currently only possible to edit messages without
:attr:`telegram.Message.reply_markup` or with inline keyboards

Args:
chat_id (:obj:`int` | :obj:`str`, optional): Required if inline_message_id is not
specified. Unique identifier for the target chat or username of the target channel
Expand Down Expand Up @@ -4632,7 +4649,7 @@ async def send_invoice(
suggested amounts of tips in the *smallest* units of the currency (integer, **not**
float/double). At most 4 suggested tip amounts can be specified. The suggested tip
amounts must be positive, passed in a strictly increased order and must not exceed
``max_tip_amount``.
:paramref:`max_tip_amount`.

.. versionadded:: 13.5
start_parameter (:obj:`str`, optional): Unique deep-linking parameter. If left empty,
Expand Down Expand Up @@ -4776,10 +4793,10 @@ async def answer_shipping_query( # pylint: disable=invalid-name
api_kwargs: JSONDict = None,
) -> bool:
"""
If you sent an invoice requesting a shipping address and the parameter ``is_flexible`` was
specified, the Bot API will send an :class:`telegram.Update` with a
:attr:`telegram.Update.shipping_query` field to the bot. Use this method to reply to
shipping queries.
If you sent an invoice requesting a shipping address and the parameter
:paramref:`send_invoice.is_flexible` was specified, the Bot API will send an
:class:`telegram.Update` with a :attr:`telegram.Update.shipping_query` field to the bot.
Use this method to reply to shipping queries.

Args:
shipping_query_id (:obj:`str`): Unique identifier for the query to be answered.
Expand Down Expand Up @@ -4999,7 +5016,8 @@ async def restrict_chat_member(
days or less than 30 seconds from the current time, they are considered to be
restricted forever.
For timezone naive :obj:`datetime.datetime` objects, the default timezone of the
bot will be used.
bot will be used, which is UTC unless :attr:`telegram.ext.Defaults.tzinfo` is
used.
permissions (:class:`telegram.ChatPermissions`): An object for new user
permissions.

Expand Down Expand Up @@ -5383,7 +5401,8 @@ async def create_chat_invite_link(
expire_date (:obj:`int` | :obj:`datetime.datetime`, optional): Date when the link will
expire. Integer input will be interpreted as Unix timestamp.
For timezone naive :obj:`datetime.datetime` objects, the default timezone of the
bot will be used.
bot will be used, which is UTC unless :attr:`telegram.ext.Defaults.tzinfo` is
used.
member_limit (:obj:`int`, optional): Maximum number of users that can be members of
the chat simultaneously after joining the chat via this invite link;
1-:tg-const:`telegram.constants.ChatInviteLinkLimit.MEMBER_LIMIT`.
Expand All @@ -5393,7 +5412,7 @@ async def create_chat_invite_link(
.. versionadded:: 13.8
creates_join_request (:obj:`bool`, optional): :obj:`True`, if users joining the chat
via the link need to be approved by chat administrators.
If :obj:`True`, ``member_limit`` can't be specified.
If :obj:`True`, :paramref:`member_limit` can't be specified.

.. versionadded:: 13.8

Expand Down Expand Up @@ -5484,7 +5503,8 @@ async def edit_chat_invite_link(
expire_date (:obj:`int` | :obj:`datetime.datetime`, optional): Date when the link will
expire.
For timezone naive :obj:`datetime.datetime` objects, the default timezone of the
bot will be used.
bot will be used, which is UTC unless :attr:`telegram.ext.Defaults.tzinfo` is
used.
member_limit (:obj:`int`, optional): Maximum number of users that can be members of
the chat simultaneously after joining the chat via this invite link;
1-:tg-const:`telegram.constants.ChatInviteLinkLimit.MEMBER_LIMIT`.
Expand All @@ -5494,7 +5514,7 @@ async def edit_chat_invite_link(
.. versionadded:: 13.8
creates_join_request (:obj:`bool`, optional): :obj:`True`, if users joining the chat
via the link need to be approved by chat administrators.
If :obj:`True`, ``member_limit`` can't be specified.
If :obj:`True`, :paramref:`member_limit` can't be specified.

.. versionadded:: 13.8

Expand Down Expand Up @@ -5981,8 +6001,9 @@ async def pin_chat_message(
"""
Use this method to add a message to the list of pinned messages in a chat. If the
chat is not a private chat, the bot must be an administrator in the chat for this to work
and must have the ``can_pin_messages`` admin right in a supergroup
or :attr:`telegram.ChatMemberAdministrator.can_edit_messages` admin right in a channel.
and must have the :paramref:`~telegram.ChatAdministratorRights.can_pin_messages` admin
right in a supergroup or :attr:`~telegram.ChatMemberAdministrator.can_edit_messages` admin
right in a channel.

Args:
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
Expand Down Expand Up @@ -6046,9 +6067,9 @@ async def unpin_chat_message(
"""
Use this method to remove a message from the list of pinned messages in a chat. If the
chat is not a private chat, the bot must be an administrator in the chat for this to work
and must have the ``can_pin_messages`` admin right in a
supergroup or :attr:`telegram.ChatMemberAdministrator.can_edit_messages` admin right in a
channel.
and must have the :paramref:`~telegram.ChatAdministratorRights.can_pin_messages` admin
right in a supergroup or :attr:`~telegram.ChatMemberAdministrator.can_edit_messages` admin
right in a channel.

Args:
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
Expand Down Expand Up @@ -6108,9 +6129,9 @@ async def unpin_all_chat_messages(
"""
Use this method to clear the list of pinned messages in a chat. If the
chat is not a private chat, the bot must be an administrator in the chat for this
to work and must have the ``can_pin_messages`` admin right in a
supergroup or :attr:`telegram.ChatMemberAdministrator.can_edit_messages` admin right in a
channel.
to work and must have the :paramref:`~telegram.ChatAdministratorRights.can_pin_messages`
admin right in a supergroup or :attr:`~telegram.ChatMemberAdministrator.can_edit_messages`
admin right in a channel.

Args:
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
Expand Down Expand Up @@ -6804,7 +6825,8 @@ async def send_poll(
more than 600 seconds in the future. Can't be used together with
:paramref:`open_period`.
For timezone naive :obj:`datetime.datetime` objects, the default timezone of the
bot will be used.
bot will be used, which is UTC unless :attr:`telegram.ext.Defaults.tzinfo` is
used.
is_closed (:obj:`bool`, optional): Pass :obj:`True`, if the poll needs to be
immediately closed. This can be useful for poll preview.
disable_notification (:obj:`bool`, optional): Sends the message silently. Users will
Expand Down
6 changes: 3 additions & 3 deletions telegram/_inline/inlinekeyboardbutton.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram InlineKeyboardButton."""

from typing import TYPE_CHECKING, Any, Optional
from typing import TYPE_CHECKING, Any, Optional, Union

from telegram._games.callbackgame import CallbackGame
from telegram._loginurl import LoginUrl
Expand Down Expand Up @@ -163,7 +163,7 @@ def __init__(
self,
text: str,
url: str = None,
callback_data: object = None,
callback_data: Union[str, object] = None,
switch_inline_query: str = None,
switch_inline_query_current_chat: str = None,
callback_game: CallbackGame = None,
Expand Down Expand Up @@ -214,7 +214,7 @@ def de_json(cls, data: Optional[JSONDict], bot: "Bot") -> Optional["InlineKeyboa

return cls(**data)

def update_callback_data(self, callback_data: object) -> None:
def update_callback_data(self, callback_data: Union[str, object]) -> None:
"""
Sets :attr:`callback_data` to the passed object. Intended to be used by
:class:`telegram.ext.CallbackDataCache`.
Expand Down
3 changes: 2 additions & 1 deletion telegram/ext/_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,8 @@ async def shutdown(self) -> None:

* :attr:`bot` by calling :meth:`telegram.Bot.shutdown`
* :attr:`updater` by calling :meth:`telegram.ext.Updater.shutdown`
* :attr:`persistence` by calling :meth:`update_persistence` and :meth`persistence.flush`
* :attr:`persistence` by calling :meth:`update_persistence` and
:meth:`BasePersistence.flush`

.. seealso::
:meth:`initialize`
Expand Down
3 changes: 2 additions & 1 deletion telegram/ext/_callbackdatacache.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,8 @@ def clear_callback_data(self, time_cutoff: Union[float, datetime] = None) -> Non
time_cutoff (:obj:`float` | :obj:`datetime.datetime`, optional): Pass a UNIX timestamp
or a :obj:`datetime.datetime` to clear only entries which are older.
For timezone naive :obj:`datetime.datetime` objects, the default timezone of the
bot will be used.
bot will be used, which is UTC unless :attr:`telegram.ext.Defaults.tzinfo` is
used.

"""
self.__clear(self._keyboard_data, time_cutoff=time_cutoff)
Expand Down
Loading