Add Quotes for Installation Instructions With Optional Dependencies (#3780)

This commit is contained in:
Bibo-Joshi 2023-06-29 07:46:00 +02:00 committed by GitHub
parent 623d2f7f0b
commit 4a6e0fd7a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 47 additions and 47 deletions

View file

@ -148,20 +148,20 @@ Optional Dependencies
PTB can be installed with optional dependencies: PTB can be installed with optional dependencies:
* ``pip install python-telegram-bot[passport]`` installs the `cryptography>=39.0.1 <https://cryptography.io/en/stable>`_ library. Use this, if you want to use Telegram Passport related functionality. * ``pip install "python-telegram-bot[passport]"`` installs the `cryptography>=39.0.1 <https://cryptography.io/en/stable>`_ library. Use this, if you want to use Telegram Passport related functionality.
* ``pip install python-telegram-bot[socks]`` installs `httpx[socks] <https://www.python-httpx.org/#dependencies>`_. Use this, if you want to work behind a Socks5 server. * ``pip install "python-telegram-bot[socks]"`` installs `httpx[socks] <https://www.python-httpx.org/#dependencies>`_. Use this, if you want to work behind a Socks5 server.
* ``pip install python-telegram-bot[http2]`` installs `httpx[http2] <https://www.python-httpx.org/#dependencies>`_. Use this, if you want to use HTTP/2. * ``pip install "python-telegram-bot[http2]"`` installs `httpx[http2] <https://www.python-httpx.org/#dependencies>`_. Use this, if you want to use HTTP/2.
* ``pip install python-telegram-bot[rate-limiter]`` installs `aiolimiter~=1.1.0 <https://aiolimiter.readthedocs.io/en/stable/>`_. Use this, if you want to use ``telegram.ext.AIORateLimiter``. * ``pip install "python-telegram-bot[rate-limiter]"`` installs `aiolimiter~=1.1.0 <https://aiolimiter.readthedocs.io/en/stable/>`_. Use this, if you want to use ``telegram.ext.AIORateLimiter``.
* ``pip install python-telegram-bot[webhooks]`` installs the `tornado~=6.2 <https://www.tornadoweb.org/en/stable/>`_ library. Use this, if you want to use ``telegram.ext.Updater.start_webhook``/``telegram.ext.Application.run_webhook``. * ``pip install "python-telegram-bot[webhooks]"`` installs the `tornado~=6.2 <https://www.tornadoweb.org/en/stable/>`_ library. Use this, if you want to use ``telegram.ext.Updater.start_webhook``/``telegram.ext.Application.run_webhook``.
* ``pip install python-telegram-bot[callback-data]`` installs the `cachetools~=5.3.1 <https://cachetools.readthedocs.io/en/latest/>`_ library. Use this, if you want to use `arbitrary callback_data <https://github.com/python-telegram-bot/python-telegram-bot/wiki/Arbitrary-callback_data>`_. * ``pip install "python-telegram-bot[callback-data]"`` installs the `cachetools~=5.3.1 <https://cachetools.readthedocs.io/en/latest/>`_ library. Use this, if you want to use `arbitrary callback_data <https://github.com/python-telegram-bot/python-telegram-bot/wiki/Arbitrary-callback_data>`_.
* ``pip install python-telegram-bot[job-queue]`` installs the `APScheduler~=3.10.1 <https://apscheduler.readthedocs.io/en/3.x/>`_ library and enforces `pytz>=2018.6 <https://pypi.org/project/pytz/>`_, where ``pytz`` is a dependency of ``APScheduler``. Use this, if you want to use the ``telegram.ext.JobQueue``. * ``pip install "python-telegram-bot[job-queue]"`` installs the `APScheduler~=3.10.1 <https://apscheduler.readthedocs.io/en/3.x/>`_ library and enforces `pytz>=2018.6 <https://pypi.org/project/pytz/>`_, where ``pytz`` is a dependency of ``APScheduler``. Use this, if you want to use the ``telegram.ext.JobQueue``.
To install multiple optional dependencies, separate them by commas, e.g. ``pip install python-telegram-bot[socks,webhooks]``. To install multiple optional dependencies, separate them by commas, e.g. ``pip install "python-telegram-bot[socks,webhooks]"``.
Additionally, two shortcuts are provided: Additionally, two shortcuts are provided:
* ``pip install python-telegram-bot[all]`` installs all optional dependencies. * ``pip install "python-telegram-bot[all]"`` installs all optional dependencies.
* ``pip install python-telegram-bot[ext]`` installs all optional dependencies that are related to ``telegram.ext``, i.e. ``[rate-limiter, webhooks, callback-data, job-queue]``. * ``pip install "python-telegram-bot[ext]"`` installs all optional dependencies that are related to ``telegram.ext``, i.e. ``[rate-limiter, webhooks, callback-data, job-queue]``.
Quick Start Quick Start
=========== ===========

View file

@ -149,13 +149,13 @@ Optional Dependencies
PTB can be installed with optional dependencies: PTB can be installed with optional dependencies:
* ``pip install python-telegram-bot-raw[passport]`` installs the `cryptography>=39.0.1 <https://cryptography.io/en/stable>`_ library. Use this, if you want to use Telegram Passport related functionality. * ``pip install "python-telegram-bot-raw[passport]"`` installs the `cryptography>=39.0.1 <https://cryptography.io/en/stable>`_ library. Use this, if you want to use Telegram Passport related functionality.
* ``pip install python-telegram-bot-raw[socks]`` installs `httpx[socks] <https://www.python-httpx.org/#dependencies>`_. Use this, if you want to work behind a Socks5 server. * ``pip install "python-telegram-bot-raw[socks]"`` installs `httpx[socks] <https://www.python-httpx.org/#dependencies>`_. Use this, if you want to work behind a Socks5 server.
* ``pip install python-telegram-bot[http2]`` installs `httpx[http2] <https://www.python-httpx.org/#dependencies>`_. Use this, if you want to use HTTP/2. * ``pip install "python-telegram-bot-raw[http2]"`` installs `httpx[http2] <https://www.python-httpx.org/#dependencies>`_. Use this, if you want to use HTTP/2.
To install multiple optional dependencies, separate them by commas, e.g. ``pip install python-telegram-bot-raw[passport,socks]``. To install multiple optional dependencies, separate them by commas, e.g. ``pip install "python-telegram-bot-raw[passport,socks]"``.
Additionally, the shortcut ``pip install python-telegram-bot-raw[all]`` installs all optional dependencies. Additionally, the shortcut ``pip install "python-telegram-bot-raw[all]"`` installs all optional dependencies.
Quick Start Quick Start
=========== ===========

View file

@ -40,7 +40,7 @@ up a job to send a message to that user after 30 seconds. The user can
also cancel the timer by sending ``/unset``. To learn more about the also cancel the timer by sending ``/unset``. To learn more about the
``JobQueue``, read `this wiki ``JobQueue``, read `this wiki
article <https://github.com/python-telegram-bot/python-telegram-bot/wiki/Extensions-%E2%80%93-JobQueue>`__. article <https://github.com/python-telegram-bot/python-telegram-bot/wiki/Extensions-%E2%80%93-JobQueue>`__.
Note: To use ``JobQueue``, you must install PTB via ``pip install python-telegram-bot[job-queue]`` Note: To use ``JobQueue``, you must install PTB via ``pip install "python-telegram-bot[job-queue]"``
:any:`examples.conversationbot` :any:`examples.conversationbot`
------------------------------- -------------------------------
@ -116,7 +116,7 @@ Dont forget to enable and configure payments with
`@BotFather <https://telegram.me/BotFather>`_. Check out this `@BotFather <https://telegram.me/BotFather>`_. Check out this
`guide <https://github.com/python-telegram-bot/python-telegram-bot/wiki/Telegram-Passport>`__ `guide <https://github.com/python-telegram-bot/python-telegram-bot/wiki/Telegram-Passport>`__
on Telegram passports in PTB. on Telegram passports in PTB.
Note: To use Telegram Passport, you must install PTB via ``pip install python-telegram-bot[passport]`` Note: To use Telegram Passport, you must install PTB via ``pip install "python-telegram-bot[passport]"``
:any:`examples.paymentbot` :any:`examples.paymentbot`
-------------------------- --------------------------
@ -164,7 +164,7 @@ combination with ``telegram.ext.Application``.
This example showcases how PTBs “arbitrary callback data” feature can be This example showcases how PTBs “arbitrary callback data” feature can be
used. used.
Note: To use arbitrary callback data, you must install PTB via ``pip install python-telegram-bot[callback-data]`` Note: To use arbitrary callback data, you must install PTB via ``pip install "python-telegram-bot[callback-data]"``
Pure API Pure API
-------- --------

View file

@ -9,7 +9,7 @@ https://github.com/python-telegram-bot/python-telegram-bot/wiki/Arbitrary-callba
Note: Note:
To use arbitrary callback data, you must install PTB via To use arbitrary callback data, you must install PTB via
`pip install python-telegram-bot[callback-data]` `pip install "python-telegram-bot[callback-data]"`
""" """
import logging import logging
from typing import List, Tuple, cast from typing import List, Tuple, cast

View file

@ -12,7 +12,7 @@ See https://github.com/python-telegram-bot/python-telegram-bot/wiki/Telegram-Pas
Note: Note:
To use Telegram Passport, you must install PTB via To use Telegram Passport, you must install PTB via
`pip install python-telegram-bot[passport]` `pip install "python-telegram-bot[passport]"`
""" """
import logging import logging
from pathlib import Path from pathlib import Path

View file

@ -19,7 +19,7 @@ bot.
Note: Note:
To use the JobQueue, you must install PTB via To use the JobQueue, you must install PTB via
`pip install python-telegram-bot[job-queue]` `pip install "python-telegram-bot[job-queue]"`
""" """
import logging import logging

View file

@ -287,7 +287,7 @@ class Bot(TelegramObject, AsyncContextManager["Bot"]):
if not CRYPTO_INSTALLED: if not CRYPTO_INSTALLED:
raise RuntimeError( raise RuntimeError(
"To use Telegram Passports, PTB must be installed via `pip install " "To use Telegram Passports, PTB must be installed via `pip install "
"python-telegram-bot[passport]`." '"python-telegram-bot[passport]"`.'
) )
self._private_key = serialization.load_pem_private_key( self._private_key = serialization.load_pem_private_key(
private_key, password=private_key_password, backend=default_backend() private_key, password=private_key_password, backend=default_backend()

View file

@ -71,7 +71,7 @@ def decrypt(secret, hash, data): # skipcq: PYL-W0622
if not CRYPTO_INSTALLED: if not CRYPTO_INSTALLED:
raise RuntimeError( raise RuntimeError(
"To use Telegram Passports, PTB must be installed via `pip install " "To use Telegram Passports, PTB must be installed via `pip install "
"python-telegram-bot[passport]`." '"python-telegram-bot[passport]"`.'
) )
# Make a SHA512 hash of secret + update # Make a SHA512 hash of secret + update
digest = Hash(SHA512(), backend=default_backend()) digest = Hash(SHA512(), backend=default_backend())
@ -171,7 +171,7 @@ class EncryptedCredentials(TelegramObject):
if not CRYPTO_INSTALLED: if not CRYPTO_INSTALLED:
raise RuntimeError( raise RuntimeError(
"To use Telegram Passports, PTB must be installed via `pip install " "To use Telegram Passports, PTB must be installed via `pip install "
"python-telegram-bot[passport]`." '"python-telegram-bot[passport]"`.'
) )
# Try decrypting according to step 1 at # Try decrypting according to step 1 at
# https://core.telegram.org/passport#decrypting-data # https://core.telegram.org/passport#decrypting-data

View file

@ -62,7 +62,7 @@ class AIORateLimiter(BaseRateLimiter[int]):
.. code-block:: bash .. code-block:: bash
pip install python-telegram-bot[rate-limiter] pip install "python-telegram-bot[rate-limiter]"
The rate limiting is applied by combining two levels of throttling and :meth:`process_request` The rate limiting is applied by combining two levels of throttling and :meth:`process_request`
roughly boils down to:: roughly boils down to::
@ -136,7 +136,7 @@ class AIORateLimiter(BaseRateLimiter[int]):
if not AIO_LIMITER_AVAILABLE: if not AIO_LIMITER_AVAILABLE:
raise RuntimeError( raise RuntimeError(
"To use `AIORateLimiter`, PTB must be installed via `pip install " "To use `AIORateLimiter`, PTB must be installed via `pip install "
"python-telegram-bot[rate-limiter]`." '"python-telegram-bot[rate-limiter]"`.'
) )
if overall_max_rate and overall_time_period: if overall_max_rate and overall_time_period:
self._base_limiter: Optional[AsyncLimiter] = AsyncLimiter( self._base_limiter: Optional[AsyncLimiter] = AsyncLimiter(

View file

@ -371,7 +371,7 @@ class Application(Generic[BT, CCT, UD, CD, BD, JQ], AsyncContextManager["Applica
if self._job_queue is None: if self._job_queue is None:
warn( warn(
"No `JobQueue` set up. To use `JobQueue`, you must install PTB via " "No `JobQueue` set up. To use `JobQueue`, you must install PTB via "
"`pip install python-telegram-bot[job-queue]`.", '`pip install "python-telegram-bot[job-queue]"`.',
stacklevel=2, stacklevel=2,
) )
return self._job_queue return self._job_queue
@ -807,7 +807,7 @@ class Application(Generic[BT, CCT, UD, CD, BD, JQ], AsyncContextManager["Applica
.. code-block:: bash .. code-block:: bash
pip install python-telegram-bot[webhooks] pip install "python-telegram-bot[webhooks]"
.. include:: inclusions/application_run_tip.rst .. include:: inclusions/application_run_tip.rst

View file

@ -582,7 +582,7 @@ class ApplicationBuilder(Generic[BT, CCT, UD, CD, BD, JQ]):
.. code-block:: bash .. code-block:: bash
pip install python-telegram-bot[http2] pip install "python-telegram-bot[http2]"
Keep in mind that the HTTP/1.1 implementation may be considered the `"more Keep in mind that the HTTP/1.1 implementation may be considered the `"more
robust option at this time" <https://www.python-httpx.org/http2#enabling-http2>`_. robust option at this time" <https://www.python-httpx.org/http2#enabling-http2>`_.
@ -827,7 +827,7 @@ class ApplicationBuilder(Generic[BT, CCT, UD, CD, BD, JQ]):
.. code-block:: bash .. code-block:: bash
pip install python-telegram-bot[callback-data] pip install "python-telegram-bot[callback-data]"
Examples: Examples:
:any:`Arbitrary callback_data Bot <examples.arbitrarycallbackdatabot>` :any:`Arbitrary callback_data Bot <examples.arbitrarycallbackdatabot>`

View file

@ -404,7 +404,7 @@ class CallbackContext(Generic[BT, UD, CD, BD]):
if self._application._job_queue is None: # pylint: disable=protected-access if self._application._job_queue is None: # pylint: disable=protected-access
warn( warn(
"No `JobQueue` set up. To use `JobQueue`, you must install PTB via " "No `JobQueue` set up. To use `JobQueue`, you must install PTB via "
"`pip install python-telegram-bot[job-queue]`.", '`pip install "python-telegram-bot[job-queue]"`.',
stacklevel=2, stacklevel=2,
) )
return self._application._job_queue # pylint: disable=protected-access return self._application._job_queue # pylint: disable=protected-access

View file

@ -113,7 +113,7 @@ class CallbackDataCache:
.. code-block:: bash .. code-block:: bash
pip install python-telegram-bot[callback-data] pip install "python-telegram-bot[callback-data]"
Examples: Examples:
:any:`Arbitrary Callback Data Bot <examples.arbitrarycallbackdatabot>` :any:`Arbitrary Callback Data Bot <examples.arbitrarycallbackdatabot>`
@ -125,7 +125,7 @@ class CallbackDataCache:
.. versionchanged:: 20.0 .. versionchanged:: 20.0
To use this class, PTB must be installed via To use this class, PTB must be installed via
``pip install python-telegram-bot[callback-data]``. ``pip install "python-telegram-bot[callback-data]"``.
Args: Args:
bot (:class:`telegram.ext.ExtBot`): The bot this cache is for. bot (:class:`telegram.ext.ExtBot`): The bot this cache is for.
@ -153,7 +153,7 @@ class CallbackDataCache:
if not CACHE_TOOLS_AVAILABLE: if not CACHE_TOOLS_AVAILABLE:
raise RuntimeError( raise RuntimeError(
"To use `CallbackDataCache`, PTB must be installed via `pip install " "To use `CallbackDataCache`, PTB must be installed via `pip install "
"python-telegram-bot[callback-data]`." '"python-telegram-bot[callback-data]"`.'
) )
self.bot: ExtBot[Any] = bot self.bot: ExtBot[Any] = bot

View file

@ -58,7 +58,7 @@ class JobQueue(Generic[CCT]):
.. code-block:: bash .. code-block:: bash
pip install python-telegram-bot[job-queue] pip install "python-telegram-bot[job-queue]"
Examples: Examples:
:any:`Timer Bot <examples.timerbot>` :any:`Timer Bot <examples.timerbot>`
@ -68,7 +68,7 @@ class JobQueue(Generic[CCT]):
.. versionchanged:: 20.0 .. versionchanged:: 20.0
To use this class, PTB must be installed via To use this class, PTB must be installed via
``pip install python-telegram-bot[job-queue]``. ``pip install "python-telegram-bot[job-queue]"``.
Attributes: Attributes:
scheduler (:class:`apscheduler.schedulers.asyncio.AsyncIOScheduler`): The scheduler. scheduler (:class:`apscheduler.schedulers.asyncio.AsyncIOScheduler`): The scheduler.
@ -86,7 +86,7 @@ class JobQueue(Generic[CCT]):
if not APS_AVAILABLE: if not APS_AVAILABLE:
raise RuntimeError( raise RuntimeError(
"To use `JobQueue`, PTB must be installed via `pip install " "To use `JobQueue`, PTB must be installed via `pip install "
"python-telegram-bot[job-queue]`." '"python-telegram-bot[job-queue]"`.'
) )
self._application: "Optional[weakref.ReferenceType[Application]]" = None self._application: "Optional[weakref.ReferenceType[Application]]" = None
@ -678,7 +678,7 @@ class Job(Generic[CCT]):
.. code-block:: bash .. code-block:: bash
pip install python-telegram-bot[job-queue] pip install "python-telegram-bot[job-queue]"
Note: Note:
All attributes and instance methods of :attr:`job` are also directly available as All attributes and instance methods of :attr:`job` are also directly available as
@ -696,7 +696,7 @@ class Job(Generic[CCT]):
* Renamed ``Job.context`` to :attr:`Job.data`. * Renamed ``Job.context`` to :attr:`Job.data`.
* Removed argument ``job`` * Removed argument ``job``
* To use this class, PTB must be installed via * To use this class, PTB must be installed via
``pip install python-telegram-bot[job-queue]``. ``pip install "python-telegram-bot[job-queue]"``.
Args: Args:
callback (:term:`coroutine function`): The callback function that should be executed by the callback (:term:`coroutine function`): The callback function that should be executed by the
@ -750,7 +750,7 @@ class Job(Generic[CCT]):
if not APS_AVAILABLE: if not APS_AVAILABLE:
raise RuntimeError( raise RuntimeError(
"To use `Job`, PTB must be installed via `pip install " "To use `Job`, PTB must be installed via `pip install "
"python-telegram-bot[job-queue]`." '"python-telegram-bot[job-queue]"`.'
) )
self.callback: JobCallback[CCT] = callback self.callback: JobCallback[CCT] = callback

View file

@ -401,7 +401,7 @@ class Updater(AsyncContextManager["Updater"]):
.. code-block:: bash .. code-block:: bash
pip install python-telegram-bot[webhooks] pip install "python-telegram-bot[webhooks]"
.. seealso:: :wiki:`Webhooks` .. seealso:: :wiki:`Webhooks`
@ -464,7 +464,7 @@ class Updater(AsyncContextManager["Updater"]):
if not WEBHOOKS_AVAILABLE: if not WEBHOOKS_AVAILABLE:
raise RuntimeError( raise RuntimeError(
"To use `start_webhook`, PTB must be installed via `pip install " "To use `start_webhook`, PTB must be installed via `pip install "
"python-telegram-bot[webhooks]`." '"python-telegram-bot[webhooks]"`.'
) )
async with self.__lock: async with self.__lock:

View file

@ -56,7 +56,7 @@ class HTTPXRequest(BaseRequest):
* The proxy URL can also be set via the environment variables ``HTTPS_PROXY`` or * The proxy URL can also be set via the environment variables ``HTTPS_PROXY`` or
``ALL_PROXY``. See `the docs of httpx`_ for more info. ``ALL_PROXY``. See `the docs of httpx`_ for more info.
* For Socks5 support, additional dependencies are required. Make sure to install * For Socks5 support, additional dependencies are required. Make sure to install
PTB via :command:`pip install python-telegram-bot[socks]` in this case. PTB via :command:`pip install "python-telegram-bot[socks]"` in this case.
* Socks5 proxies can not be set via environment variables. * Socks5 proxies can not be set via environment variables.
.. _the docs of httpx: https://www.python-httpx.org/environment_variables/#proxies .. _the docs of httpx: https://www.python-httpx.org/environment_variables/#proxies
@ -139,11 +139,11 @@ class HTTPXRequest(BaseRequest):
if "httpx[socks]" in str(exc): if "httpx[socks]" in str(exc):
raise RuntimeError( raise RuntimeError(
"To use Socks5 proxies, PTB must be installed via `pip install " "To use Socks5 proxies, PTB must be installed via `pip install "
"python-telegram-bot[socks]`." '"python-telegram-bot[socks]"`.'
) from exc ) from exc
raise RuntimeError( raise RuntimeError(
"To use HTTP/2, PTB must be installed via `pip install " "To use HTTP/2, PTB must be installed via `pip install "
"python-telegram-bot[http2]`." '"python-telegram-bot[http2]"`.'
) from exc ) from exc
@property @property

View file

@ -203,7 +203,7 @@ class TestApplication:
def test_job_queue(self, one_time_bot, app, recwarn): def test_job_queue(self, one_time_bot, app, recwarn):
expected_warning = ( expected_warning = (
"No `JobQueue` set up. To use `JobQueue`, you must install PTB via " "No `JobQueue` set up. To use `JobQueue`, you must install PTB via "
"`pip install python-telegram-bot[job-queue]`." '`pip install "python-telegram-bot[job-queue]"`.'
) )
assert app.job_queue is app._job_queue assert app.job_queue is app._job_queue
application = ApplicationBuilder().bot(one_time_bot).job_queue(None).build() application = ApplicationBuilder().bot(one_time_bot).job_queue(None).build()

View file

@ -63,7 +63,7 @@ class TestCallbackContext:
def test_job_queue(self, bot, app, recwarn): def test_job_queue(self, bot, app, recwarn):
expected_warning = ( expected_warning = (
"No `JobQueue` set up. To use `JobQueue`, you must install PTB via " "No `JobQueue` set up. To use `JobQueue`, you must install PTB via "
"`pip install python-telegram-bot[job-queue]`." '`pip install "python-telegram-bot[job-queue]"`.'
) )
callback_context = CallbackContext(app) callback_context = CallbackContext(app)