+ contributing
+ coc
From 90f381db323db76722fa7d4e74c28b7b6b404fcd Mon Sep 17 00:00:00 2001
From: Harshil <37377066+harshil21@users.noreply.github.com>
Date: Sun, 1 May 2022 22:19:34 +0530
Subject: [PATCH 14/19] don't encourage mentioning the admins
---
.github/CONTRIBUTING.rst | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/CONTRIBUTING.rst b/.github/CONTRIBUTING.rst
index 9e57a275e3e..03044145b48 100644
--- a/.github/CONTRIBUTING.rst
+++ b/.github/CONTRIBUTING.rst
@@ -42,7 +42,7 @@ If you already know what you'd like to work on, you can skip this section.
If you have an idea for something to do, first check if it's already been filed on the `issue tracker`_. If so, add a comment to the issue saying you'd like to work on it, and we'll help you get started! Otherwise, please file a new issue and assign yourself to it.
-Another great way to start contributing is by writing tests. Tests are really important because they help prevent developers from accidentally breaking existing code, allowing them to build cool things faster. If you're interested in helping out, let the development team know by posting to the `Telegram group`_ (use `@admins` to mention the maintainers), and we'll help you get started.
+Another great way to start contributing is by writing tests. Tests are really important because they help prevent developers from accidentally breaking existing code, allowing them to build cool things faster. If you're interested in helping out, let the development team know by posting to the `Telegram group`_, and we'll help you get started.
That being said, we want to mention that we are very hesitant about adding new requirements to our projects. If you intend to do this, please state this in an issue and get a verification from one of the maintainers.
From 779738f0ca85373b0b25ea416a3b921219c8c70a Mon Sep 17 00:00:00 2001
From: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
Date: Tue, 3 May 2022 10:42:35 +0200
Subject: [PATCH 15/19] Add pre-commit CI badge
---
README.rst | 7 ++++++-
README_RAW.rst | 7 ++++++-
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/README.rst b/README.rst
index f79aeb6e78a..2197f04dbb7 100644
--- a/README.rst
+++ b/README.rst
@@ -50,12 +50,17 @@
:target: https://deepsource.io/gh/python-telegram-bot/python-telegram-bot/?ref=repository-badge
:alt: Code quality: DeepSource
+.. image:: https://results.pre-commit.ci/badge/github/python-telegram-bot/python-telegram-bot/master.svg
+ :target: https://results.pre-commit.ci/latest/github/python-telegram-bot/python-telegram-bot/master
+ :alt: pre-commit.ci status
+
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/psf/black
+ :alt: Code Style: Black
.. image:: https://img.shields.io/badge/Telegram-Channel-blue.svg?logo=telegram
:target: https://t.me/pythontelegrambotchannel
- :alt: Telegram Group
+ :alt: Telegram Channel
.. image:: https://img.shields.io/badge/Telegram-Group-blue.svg?logo=telegram
:target: https://telegram.me/pythontelegrambotgroup
diff --git a/README_RAW.rst b/README_RAW.rst
index dc318f95123..d2d18c0d975 100644
--- a/README_RAW.rst
+++ b/README_RAW.rst
@@ -50,12 +50,17 @@
:target: https://deepsource.io/gh/python-telegram-bot/python-telegram-bot/?ref=repository-badge
:alt: Code quality: DeepSource
+.. image:: https://results.pre-commit.ci/badge/github/python-telegram-bot/python-telegram-bot/master.svg
+ :target: https://results.pre-commit.ci/latest/github/python-telegram-bot/python-telegram-bot/master
+ :alt: pre-commit.ci status
+
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/psf/black
+ :alt: Code Style: Black
.. image:: https://img.shields.io/badge/Telegram-Channel-blue.svg?logo=telegram
:target: https://t.me/pythontelegrambotchannel
- :alt: Telegram Group
+ :alt: Telegram Channel
.. image:: https://img.shields.io/badge/Telegram-Group-blue.svg?logo=telegram
:target: https://telegram.me/pythontelegrambotgroup
From bfb014ec7023a40527f1098532f9085b9c56d477 Mon Sep 17 00:00:00 2001
From: Harshil <37377066+harshil21@users.noreply.github.com>
Date: Wed, 4 May 2022 23:45:55 +0530
Subject: [PATCH 16/19] add seealso for Bot.initalize and shutdown
---
telegram/_bot.py | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/telegram/_bot.py b/telegram/_bot.py
index ca267788f66..a3ec594d22c 100644
--- a/telegram/_bot.py
+++ b/telegram/_bot.py
@@ -369,6 +369,8 @@ async def initialize(self) -> None:
cache :attr:`bot` and calls :meth:`telegram.request.BaseRequest.initialize` for
the request objects used by this bot.
+ .. seealso:: :meth:`shutdown`
+
.. versionadded:: 20.0
"""
if self._initialized:
@@ -382,6 +384,8 @@ async def initialize(self) -> None:
async def shutdown(self) -> None:
"""Stop & clear resources used by this class. Currently just calls
:meth:`telegram.request.BaseRequest.shutdown` for the request objects used by this bot.
+
+ .. seealso:: :meth:`initialize`
.. versionadded:: 20.0
"""
From 8b8e355e61a462fbf99f15bdd5c2770c8fa3bdb8 Mon Sep 17 00:00:00 2001
From: Harshil <37377066+harshil21@users.noreply.github.com>
Date: Thu, 5 May 2022 00:03:20 +0530
Subject: [PATCH 17/19] black
---
telegram/_bot.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/telegram/_bot.py b/telegram/_bot.py
index a3ec594d22c..9e9954f2a0b 100644
--- a/telegram/_bot.py
+++ b/telegram/_bot.py
@@ -384,7 +384,7 @@ async def initialize(self) -> None:
async def shutdown(self) -> None:
"""Stop & clear resources used by this class. Currently just calls
:meth:`telegram.request.BaseRequest.shutdown` for the request objects used by this bot.
-
+
.. seealso:: :meth:`initialize`
.. versionadded:: 20.0
From 252f0985a6de509a77db005892e28e329d7c1991 Mon Sep 17 00:00:00 2001
From: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
Date: Thu, 5 May 2022 18:14:38 +0200
Subject: [PATCH 18/19] get started on documenting generics
---
telegram/ext/_basepersistence.py | 13 +++++++++++++
telegram/ext/_handler.py | 10 ++++++++++
2 files changed, 23 insertions(+)
diff --git a/telegram/ext/_basepersistence.py b/telegram/ext/_basepersistence.py
index e34c7cc8dec..09c82f7e729 100644
--- a/telegram/ext/_basepersistence.py
+++ b/telegram/ext/_basepersistence.py
@@ -98,7 +98,20 @@ class BasePersistence(Generic[UD, CD, BD], ABC):
:class:`telegram.TelegramObject`, one may call :meth:`set_bot` to ensure that shortcuts like
:meth:`telegram.Message.reply_text` are available.
+ This class is a :class:`~typing.Generic` class and accepts three type variables:
+
+ 1. The type of the second argument of :meth:`update_user_data`, which must coincide with the
+ type of the second argument of :meth:`refresh_user_data` and the values in the dictionary
+ returned by :meth:`get_user_data`.
+ 2. The type of the second argument of :meth:`update_chat_data`, which must coincide with the
+ type of the second argument of :meth:`refresh_chat_data` and the values in the dictionary
+ returned by :meth:`get_chat_data`.
+ 3. The type of the argument of :meth:`update_bot_data`, which must coincide with the
+ type of the argument of :meth:`refresh_bot_data` and the return value of
+ :meth:`get_bot_data`.
+
.. versionchanged:: 20.0
+
* The parameters and attributes ``store_*_data`` were replaced by :attr:`store_data`.
* ``insert/replace_bot`` was dropped. Serialization of bot instances now needs to be
handled by the specific implementation - see above note.
diff --git a/telegram/ext/_handler.py b/telegram/ext/_handler.py
index d7ad6e381fd..d18add06d57 100644
--- a/telegram/ext/_handler.py
+++ b/telegram/ext/_handler.py
@@ -38,6 +38,16 @@ class Handler(Generic[UT, CCT], ABC):
When setting :paramref:`block` to :obj:`False`, you cannot rely on adding custom
attributes to :class:`telegram.ext.CallbackContext`. See its docs for more info.
+ This class is a :class:`~typing.Generic` class and accepts two type variables:
+
+ 1. The type of the updates that this handler will handle. :meth:`check_update` must only accept
+ updates of this type and the first argument of the :paramref:`callback` function will be
+ handled this type of objects.
+ 2. The type of the second argument of :paramref:`callback`. For this type variable, one should
+ usually provide a :class:`~typing.TypeVar` that is also used in the annotation for
+ :paramref:`callback`. That way, a type checker can check whether this handler and the
+ :attr:`callback` fit the definition of the :class:`~Application`.
+
.. versionchanged:: 20.0
The attribute ``run_async`` is now :paramref:`block`.
From b9d34e1e82a4f86bc4f4c0609fa3e34f404ad77e Mon Sep 17 00:00:00 2001
From: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
Date: Fri, 6 May 2022 08:26:02 +0200
Subject: [PATCH 19/19] finish documentation of generic classes - documented
only those that may reasonably be subclassed by users
---
telegram/ext/_callbackcontext.py | 7 +++++++
telegram/ext/_handler.py | 20 +++++++++++++-------
2 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/telegram/ext/_callbackcontext.py b/telegram/ext/_callbackcontext.py
index d292dbcc364..a02ffddace5 100644
--- a/telegram/ext/_callbackcontext.py
+++ b/telegram/ext/_callbackcontext.py
@@ -70,6 +70,13 @@ class CallbackContext(Generic[BT, UD, CD, BD]):
:obj:`True`. Due to how those work, it will almost certainly execute the callbacks for an
update out of order, and the attributes that you think you added will not be present.
+ This class is a :class:`~typing.Generic` class and accepts four type variables:
+
+ 1. The type of :attr:`bot`. Must be :class:`telegram.Bot` or a subclass of that class.
+ 2. The type of :attr:`user_data` (if :attr:`user_data` is not :obj:`None`).
+ 3. The type of :attr:`chat_data` (if :attr:`chat_data` is not :obj:`None`).
+ 4. The type of :attr:`bot_data` (if :attr:`bot_data` is not :obj:`None`).
+
Args:
application (:class:`telegram.ext.Application`): The application associated with this
context.
diff --git a/telegram/ext/_handler.py b/telegram/ext/_handler.py
index d18add06d57..d5dccd0fed7 100644
--- a/telegram/ext/_handler.py
+++ b/telegram/ext/_handler.py
@@ -40,13 +40,19 @@ class Handler(Generic[UT, CCT], ABC):
This class is a :class:`~typing.Generic` class and accepts two type variables:
- 1. The type of the updates that this handler will handle. :meth:`check_update` must only accept
- updates of this type and the first argument of the :paramref:`callback` function will be
- handled this type of objects.
- 2. The type of the second argument of :paramref:`callback`. For this type variable, one should
- usually provide a :class:`~typing.TypeVar` that is also used in the annotation for
- :paramref:`callback`. That way, a type checker can check whether this handler and the
- :attr:`callback` fit the definition of the :class:`~Application`.
+ 1. The type of the updates that this handler will handle. Must coincide with the type of the
+ first argument of :paramref:`callback`. :meth:`check_update` must only accept
+ updates of this type.
+ 2. The type of the second argument of :paramref:`callback`. Must coincide with the type of the
+ parameters :paramref:`handle_update.context` and
+ :paramref:`collect_additional_context.context` as well as the second argument of
+ :paramref:`callback`. Must be either :class:`~telegram.ext.CallbackContext` or a subclass
+ of that class.
+
+ .. tip::
+ For this type variable, one should usually provide a :class:`~typing.TypeVar` that is
+ also used for the mentioned method arguments. That way, a type checker can check whether
+ this handler fits the definition of the :class:`~Application`.
.. versionchanged:: 20.0
The attribute ``run_async`` is now :paramref:`block`.
pFad - Phonifier reborn
Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy