Skip to content

Deprecate python-telegram-bot-raw #4270

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 5 commits into from
Jun 1, 2024
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
10 changes: 0 additions & 10 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
..
Make sure to apply any changes to this file to README_RAW.rst as well!

.. image:: https://raw.githubusercontent.com/python-telegram-bot/logos/master/logo-text/png/ptb-logo-text_768.png
:align: center
:target: https://python-telegram-bot.org
Expand Down Expand Up @@ -79,13 +76,6 @@ In addition to the pure API implementation, this library features a number of hi
make the development of bots easy and straightforward. These classes are contained in the
``telegram.ext`` submodule.

A pure API implementation *without* ``telegram.ext`` is available as the standalone package ``python-telegram-bot-raw``. `See here for details. <https://github.com/python-telegram-bot/python-telegram-bot/blob/master/README_RAW.rst>`_

Note
----

Installing both ``python-telegram-bot`` and ``python-telegram-bot-raw`` in conjunction will result in undesired side-effects, so only install *one* of both.

Telegram API support
====================

Expand Down
13 changes: 10 additions & 3 deletions README_RAW.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
..
Make sure to apply any changes to this file to README.rst as well!

.. image:: https://github.com/python-telegram-bot/logos/blob/master/logo-text/png/ptb-raw-logo-text_768.png?raw=true
:align: center
:target: https://python-telegram-bot.org
Expand Down Expand Up @@ -62,6 +59,16 @@
:target: https://telegram.me/pythontelegrambotgroup
:alt: Telegram Group

⚠️ Deprecation Notice
=====================

The ``python-telegram-bot-raw`` library will no longer be updated after NEXT.VERSION.
Please instead use the ``python-telegram-bot`` `library <https://pypi.org/python-telegram-bot>`_.
The change requires no changes in your code and requires no additional dependencies.
For additional information, please see this `channel post <https://t.me/pythontelegrambotchannel/145>`_.

----

We have made you a wrapper you can't refuse

We have a vibrant community of developers helping each other in our `Telegram group <https://telegram.me/pythontelegrambotgroup>`_. Join us!
Expand Down
27 changes: 27 additions & 0 deletions telegram/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@
"warnings",
)

from pathlib import Path

from . import _version, constants, error, helpers, request, warnings
from ._birthdate import Birthdate
Expand Down Expand Up @@ -442,6 +443,7 @@
from ._update import Update
from ._user import User
from ._userprofilephotos import UserProfilePhotos
from ._utils.warnings import warn
from ._videochat import (
VideoChatEnded,
VideoChatParticipantsInvited,
Expand Down Expand Up @@ -475,3 +477,28 @@
#:
#: .. versionadded:: 20.0
__bot_api_version_info__: constants._BotAPIVersion = _version.__bot_api_version_info__


if not (Path(__file__).parent.resolve().absolute() / "ext").exists():
_MESSAGE = (

Check warning on line 483 in telegram/__init__.py

View check run for this annotation

Codecov / codecov/patch

telegram/__init__.py#L483

Added line #L483 was not covered by tests
"Hey. You seem to be using the `python-telegram-bot-raw` library. "
"Please note that this libray has been deprecated and will no longer be updated. "
"Please instead use the `python-telegram-bot` library. The change requires no "
"changes in your code and requires no additional dependencies. For additional "
"information, please see the channel post at "
"https://t.me/pythontelegrambotchannel/145."
)

# DeprecationWarning is ignored by default in Python 3.7 and later by default outside
# __main__ modules. We use both warning categories to increase the chance of the user
# seeing the warning.

warn(

Check warning on line 496 in telegram/__init__.py

View check run for this annotation

Codecov / codecov/patch

telegram/__init__.py#L496

Added line #L496 was not covered by tests
warnings.PTBDeprecationWarning(version="NEXT.VERSION", message=_MESSAGE),
stacklevel=2,
)
warn(

Check warning on line 500 in telegram/__init__.py

View check run for this annotation

Codecov / codecov/patch

telegram/__init__.py#L500

Added line #L500 was not covered by tests
message=_MESSAGE,
category=warnings.PTBUserWarning,
stacklevel=2,
)
2 changes: 1 addition & 1 deletion telegram/_utils/datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def extract_tzinfo_from_defaults(bot: "Bot") -> Union[dtm.tzinfo, None]:
If the bot has no default values, :obj:`None` is returned.
"""
# We don't use `ininstance(bot, ExtBot)` here so that this works
# in `python-telegram-bot-raw` as well
# without the job-queue extra dependencies as well
if hasattr(bot, "defaults") and bot.defaults:
return bot.defaults.tzinfo
return None
Expand Down
Loading