diff --git a/.github/CONTRIBUTING.rst b/.github/CONTRIBUTING.rst index c73dc34dd07..11cb69378db 100644 --- a/.github/CONTRIBUTING.rst +++ b/.github/CONTRIBUTING.rst @@ -71,7 +71,7 @@ Here's how to make a one-off code change. - Your code should adhere to the `PEP 8 Style Guide`_, with the exception that we have a maximum line length of 99. - - Provide static typing with signature annotations. The documentation of `MyPy`_ will be a good start, the cheat sheet is `here`_. We also have some custom type aliases in ``telegram.utils.helpers.typing``. + - Provide static typing with signature annotations. The documentation of `MyPy`_ will be a good start, the cheat sheet is `here`_. We also have some custom type aliases in ``telegram._utils.types``. - Document your code. This step is pretty important to us, so it has its own `section`_. diff --git a/.gitignore b/.gitignore index 85a61e2b5c0..2ff4df6a62b 100644 --- a/.gitignore +++ b/.gitignore @@ -69,6 +69,9 @@ target/ # Sublime Text 2 *.sublime* +# VS Code +.vscode + # unitests files game.gif telegram.mp3 diff --git a/AUTHORS.rst b/AUTHORS.rst index 942a0e8d31e..2c8951e920a 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -68,6 +68,7 @@ The following wonderful people contributed directly or indirectly to this projec - `Joscha Götzer `_ - `jossalgon `_ - `JRoot3D `_ +- `kennethcheo `_ - `Kirill Vasin `_ - `Kjwon15 `_ - `Li-aung Yip `_ diff --git a/docs/source/telegram.ext.rst b/docs/source/telegram.ext.rst index 7dc2af0af41..e339b3e84ab 100644 --- a/docs/source/telegram.ext.rst +++ b/docs/source/telegram.ext.rst @@ -55,12 +55,3 @@ Arbitrary Callback Data telegram.ext.callbackdatacache telegram.ext.invalidcallbackdata - -utils ------ - -.. toctree:: - - telegram.ext.utils.promise - telegram.ext.utils.stack - telegram.ext.utils.types \ No newline at end of file diff --git a/docs/source/telegram.ext.utils.promise.rst b/docs/source/telegram.ext.utils.promise.rst deleted file mode 100644 index aee183d015c..00000000000 --- a/docs/source/telegram.ext.utils.promise.rst +++ /dev/null @@ -1,8 +0,0 @@ -:github_url: https://github.com/python-telegram-bot/python-telegram-bot/blob/master/telegram/ext/utils/promise.py - -telegram.ext.utils.promise.Promise -================================== - -.. autoclass:: telegram.ext.utils.promise.Promise - :members: - :show-inheritance: diff --git a/docs/source/telegram.ext.utils.types.rst b/docs/source/telegram.ext.utils.types.rst deleted file mode 100644 index 5c501ecf840..00000000000 --- a/docs/source/telegram.ext.utils.types.rst +++ /dev/null @@ -1,8 +0,0 @@ -:github_url: https://github.com/python-telegram-bot/python-telegram-bot/blob/master/telegram/ext/utils/types.py - -telegram.ext.utils.types Module -================================ - -.. automodule:: telegram.ext.utils.types - :members: - :show-inheritance: diff --git a/docs/source/telegram.rst b/docs/source/telegram.rst index d0685fc6853..a38e5a07e60 100644 --- a/docs/source/telegram.rst +++ b/docs/source/telegram.rst @@ -180,14 +180,3 @@ Auxiliary modules telegram.helpers telegram.request telegram.warnings - -utils ------ - -.. toctree:: - - telegram.utils.datetime - telegram.utils.defaultvalue - telegram.utils.files - telegram.utils.types - telegram.utils.warnings diff --git a/docs/source/telegram.utils.datetime.rst b/docs/source/telegram.utils.datetime.rst deleted file mode 100644 index 52786a29793..00000000000 --- a/docs/source/telegram.utils.datetime.rst +++ /dev/null @@ -1,8 +0,0 @@ -:github_url: https://github.com/python-telegram-bot/python-telegram-bot/blob/master/telegram/utils/datetime.py - -telegram.utils.datetime Module -============================== - -.. automodule:: telegram.utils.datetime - :members: - :show-inheritance: diff --git a/docs/source/telegram.utils.defaultvalue.rst b/docs/source/telegram.utils.defaultvalue.rst deleted file mode 100644 index 09ae5a0f671..00000000000 --- a/docs/source/telegram.utils.defaultvalue.rst +++ /dev/null @@ -1,8 +0,0 @@ -:github_url: https://github.com/python-telegram-bot/python-telegram-bot/blob/master/telegram/utils/defaultvalue.py - -telegram.utils.defaultvalue Module -================================== - -.. automodule:: telegram.utils.defaultvalue - :members: - :show-inheritance: diff --git a/docs/source/telegram.utils.files.rst b/docs/source/telegram.utils.files.rst deleted file mode 100644 index 565081eec8f..00000000000 --- a/docs/source/telegram.utils.files.rst +++ /dev/null @@ -1,8 +0,0 @@ -:github_url: https://github.com/python-telegram-bot/python-telegram-bot/blob/master/telegram/utils/files.py - -telegram.utils.files Module -=========================== - -.. automodule:: telegram.utils.files - :members: - :show-inheritance: diff --git a/docs/source/telegram.utils.types.rst b/docs/source/telegram.utils.types.rst deleted file mode 100644 index 97f88ce4303..00000000000 --- a/docs/source/telegram.utils.types.rst +++ /dev/null @@ -1,8 +0,0 @@ -:github_url: https://github.com/python-telegram-bot/python-telegram-bot/blob/master/telegram/utils/types.py - -telegram.utils.types Module -=========================== - -.. automodule:: telegram.utils.types - :members: - :show-inheritance: diff --git a/docs/source/telegram.utils.warnings.rst b/docs/source/telegram.utils.warnings.rst deleted file mode 100644 index 7c754b0effc..00000000000 --- a/docs/source/telegram.utils.warnings.rst +++ /dev/null @@ -1,8 +0,0 @@ -:github_url: https://github.com/python-telegram-bot/python-telegram-bot/blob/master/telegram/utils/warnings.py - -telegram.utils.warnings Module -============================== - -.. automodule:: telegram.utils.warnings - :members: - :show-inheritance: diff --git a/setup.cfg b/setup.cfg index 98748321afb..48e29600f7b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -61,11 +61,11 @@ ignore_errors = True # Disable strict optional for telegram objects with class methods # We don't want to clutter the code with 'if self.bot is None: raise RuntimeError()' -[mypy-telegram.callbackquery,telegram.chat,telegram.message,telegram.user,telegram.files.*,telegram.inline.inlinequery,telegram.payment.precheckoutquery,telegram.payment.shippingquery,telegram.passport.passportdata,telegram.passport.credentials,telegram.passport.passportfile,telegram.ext.filters] +[mypy-telegram._callbackquery,telegram._chat,telegram._message,telegram._user,telegram._files.*,telegram._inline.inlinequery,telegram._payment.precheckoutquery,telegram._payment.shippingquery,telegram._passport.passportdata,telegram._passport.credentials,telegram._passport.passportfile,telegram.ext.filters] strict_optional = False # type hinting for asyncio in webhookhandler is a bit tricky because it depends on the OS -[mypy-telegram.ext.utils.webhookhandler] +[mypy-telegram.ext._utils.webhookhandler] warn_unused_ignores = False [mypy-urllib3.*] diff --git a/setup.py b/setup.py index cce41c4cd94..d29c4f919c6 100644 --- a/setup.py +++ b/setup.py @@ -49,7 +49,7 @@ def get_setup_kwargs(raw=False): raw_ext = "-raw" if raw else "" readme = Path(f'README{"_RAW" if raw else ""}.rst') - with Path('telegram/version.py').open() as fh: + with Path('telegram/_version.py').open() as fh: for line in fh.readlines(): if line.startswith('__version__'): exec(line) @@ -76,7 +76,6 @@ def get_setup_kwargs(raw=False): long_description=readme.read_text(), long_description_content_type='text/x-rst', packages=packages, - install_requires=requirements, extras_require={ 'json': 'ujson', @@ -99,7 +98,7 @@ def get_setup_kwargs(raw=False): 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', ], - python_requires='>=3.7' + python_requires='>=3.7', ) return kwargs diff --git a/telegram/__init__.py b/telegram/__init__.py index 0e957e63715..de33041f682 100644 --- a/telegram/__init__.py +++ b/telegram/__init__.py @@ -18,14 +18,14 @@ # along with this program. If not, see [http://www.gnu.org/licenses/]. """A library that provides a Python interface to the Telegram Bot API""" -from .telegramobject import TelegramObject -from .botcommand import BotCommand -from .user import User -from .files.chatphoto import ChatPhoto -from .chat import Chat -from .chatlocation import ChatLocation -from .chatinvitelink import ChatInviteLink -from .chatmember import ( +from ._telegramobject import TelegramObject +from ._botcommand import BotCommand +from ._user import User +from ._files.chatphoto import ChatPhoto +from ._chat import Chat +from ._chatlocation import ChatLocation +from ._chatinvitelink import ChatInviteLink +from ._chatmember import ( ChatMember, ChatMemberOwner, ChatMemberAdministrator, @@ -34,95 +34,95 @@ ChatMemberLeft, ChatMemberBanned, ) -from .chatmemberupdated import ChatMemberUpdated -from .chatpermissions import ChatPermissions -from .files.photosize import PhotoSize -from .files.audio import Audio -from .files.voice import Voice -from .files.document import Document -from .files.animation import Animation -from .files.sticker import Sticker, StickerSet, MaskPosition -from .files.video import Video -from .files.contact import Contact -from .files.location import Location -from .files.venue import Venue -from .files.videonote import VideoNote -from .chataction import ChatAction -from .dice import Dice -from .userprofilephotos import UserProfilePhotos -from .keyboardbuttonpolltype import KeyboardButtonPollType -from .keyboardbutton import KeyboardButton -from .replymarkup import ReplyMarkup -from .replykeyboardmarkup import ReplyKeyboardMarkup -from .replykeyboardremove import ReplyKeyboardRemove -from .forcereply import ForceReply -from .files.inputfile import InputFile -from .files.file import File -from .parsemode import ParseMode -from .messageentity import MessageEntity -from .messageid import MessageId -from .games.game import Game -from .poll import Poll, PollOption, PollAnswer -from .voicechat import ( +from ._chatmemberupdated import ChatMemberUpdated +from ._chatpermissions import ChatPermissions +from ._files.photosize import PhotoSize +from ._files.audio import Audio +from ._files.voice import Voice +from ._files.document import Document +from ._files.animation import Animation +from ._files.sticker import Sticker, StickerSet, MaskPosition +from ._files.video import Video +from ._files.contact import Contact +from ._files.location import Location +from ._files.venue import Venue +from ._files.videonote import VideoNote +from ._chataction import ChatAction +from ._dice import Dice +from ._userprofilephotos import UserProfilePhotos +from ._keyboardbuttonpolltype import KeyboardButtonPollType +from ._keyboardbutton import KeyboardButton +from ._replymarkup import ReplyMarkup +from ._replykeyboardmarkup import ReplyKeyboardMarkup +from ._replykeyboardremove import ReplyKeyboardRemove +from ._forcereply import ForceReply +from ._files.inputfile import InputFile +from ._files.file import File +from ._parsemode import ParseMode +from ._messageentity import MessageEntity +from ._messageid import MessageId +from ._games.game import Game +from ._poll import Poll, PollOption, PollAnswer +from ._voicechat import ( VoiceChatStarted, VoiceChatEnded, VoiceChatParticipantsInvited, VoiceChatScheduled, ) -from .loginurl import LoginUrl -from .proximityalerttriggered import ProximityAlertTriggered -from .games.callbackgame import CallbackGame -from .payment.shippingaddress import ShippingAddress -from .payment.orderinfo import OrderInfo -from .payment.successfulpayment import SuccessfulPayment -from .payment.invoice import Invoice -from .passport.credentials import EncryptedCredentials -from .passport.passportfile import PassportFile -from .passport.data import IdDocumentData, PersonalDetails, ResidentialAddress -from .passport.encryptedpassportelement import EncryptedPassportElement -from .passport.passportdata import PassportData -from .inline.inlinekeyboardbutton import InlineKeyboardButton -from .inline.inlinekeyboardmarkup import InlineKeyboardMarkup -from .messageautodeletetimerchanged import MessageAutoDeleteTimerChanged -from .message import Message -from .callbackquery import CallbackQuery -from .choseninlineresult import ChosenInlineResult -from .inline.inputmessagecontent import InputMessageContent -from .inline.inlinequery import InlineQuery -from .inline.inlinequeryresult import InlineQueryResult -from .inline.inlinequeryresultarticle import InlineQueryResultArticle -from .inline.inlinequeryresultaudio import InlineQueryResultAudio -from .inline.inlinequeryresultcachedaudio import InlineQueryResultCachedAudio -from .inline.inlinequeryresultcacheddocument import InlineQueryResultCachedDocument -from .inline.inlinequeryresultcachedgif import InlineQueryResultCachedGif -from .inline.inlinequeryresultcachedmpeg4gif import InlineQueryResultCachedMpeg4Gif -from .inline.inlinequeryresultcachedphoto import InlineQueryResultCachedPhoto -from .inline.inlinequeryresultcachedsticker import InlineQueryResultCachedSticker -from .inline.inlinequeryresultcachedvideo import InlineQueryResultCachedVideo -from .inline.inlinequeryresultcachedvoice import InlineQueryResultCachedVoice -from .inline.inlinequeryresultcontact import InlineQueryResultContact -from .inline.inlinequeryresultdocument import InlineQueryResultDocument -from .inline.inlinequeryresultgif import InlineQueryResultGif -from .inline.inlinequeryresultlocation import InlineQueryResultLocation -from .inline.inlinequeryresultmpeg4gif import InlineQueryResultMpeg4Gif -from .inline.inlinequeryresultphoto import InlineQueryResultPhoto -from .inline.inlinequeryresultvenue import InlineQueryResultVenue -from .inline.inlinequeryresultvideo import InlineQueryResultVideo -from .inline.inlinequeryresultvoice import InlineQueryResultVoice -from .inline.inlinequeryresultgame import InlineQueryResultGame -from .inline.inputtextmessagecontent import InputTextMessageContent -from .inline.inputlocationmessagecontent import InputLocationMessageContent -from .inline.inputvenuemessagecontent import InputVenueMessageContent -from .payment.labeledprice import LabeledPrice -from .inline.inputinvoicemessagecontent import InputInvoiceMessageContent -from .inline.inputcontactmessagecontent import InputContactMessageContent -from .payment.shippingoption import ShippingOption -from .payment.precheckoutquery import PreCheckoutQuery -from .payment.shippingquery import ShippingQuery -from .webhookinfo import WebhookInfo -from .games.gamehighscore import GameHighScore -from .update import Update -from .files.inputmedia import ( +from ._loginurl import LoginUrl +from ._proximityalerttriggered import ProximityAlertTriggered +from ._games.callbackgame import CallbackGame +from ._payment.shippingaddress import ShippingAddress +from ._payment.orderinfo import OrderInfo +from ._payment.successfulpayment import SuccessfulPayment +from ._payment.invoice import Invoice +from ._passport.credentials import EncryptedCredentials +from ._passport.passportfile import PassportFile +from ._passport.data import IdDocumentData, PersonalDetails, ResidentialAddress +from ._passport.encryptedpassportelement import EncryptedPassportElement +from ._passport.passportdata import PassportData +from ._inline.inlinekeyboardbutton import InlineKeyboardButton +from ._inline.inlinekeyboardmarkup import InlineKeyboardMarkup +from ._messageautodeletetimerchanged import MessageAutoDeleteTimerChanged +from ._message import Message +from ._callbackquery import CallbackQuery +from ._choseninlineresult import ChosenInlineResult +from ._inline.inputmessagecontent import InputMessageContent +from ._inline.inlinequery import InlineQuery +from ._inline.inlinequeryresult import InlineQueryResult +from ._inline.inlinequeryresultarticle import InlineQueryResultArticle +from ._inline.inlinequeryresultaudio import InlineQueryResultAudio +from ._inline.inlinequeryresultcachedaudio import InlineQueryResultCachedAudio +from ._inline.inlinequeryresultcacheddocument import InlineQueryResultCachedDocument +from ._inline.inlinequeryresultcachedgif import InlineQueryResultCachedGif +from ._inline.inlinequeryresultcachedmpeg4gif import InlineQueryResultCachedMpeg4Gif +from ._inline.inlinequeryresultcachedphoto import InlineQueryResultCachedPhoto +from ._inline.inlinequeryresultcachedsticker import InlineQueryResultCachedSticker +from ._inline.inlinequeryresultcachedvideo import InlineQueryResultCachedVideo +from ._inline.inlinequeryresultcachedvoice import InlineQueryResultCachedVoice +from ._inline.inlinequeryresultcontact import InlineQueryResultContact +from ._inline.inlinequeryresultdocument import InlineQueryResultDocument +from ._inline.inlinequeryresultgif import InlineQueryResultGif +from ._inline.inlinequeryresultlocation import InlineQueryResultLocation +from ._inline.inlinequeryresultmpeg4gif import InlineQueryResultMpeg4Gif +from ._inline.inlinequeryresultphoto import InlineQueryResultPhoto +from ._inline.inlinequeryresultvenue import InlineQueryResultVenue +from ._inline.inlinequeryresultvideo import InlineQueryResultVideo +from ._inline.inlinequeryresultvoice import InlineQueryResultVoice +from ._inline.inlinequeryresultgame import InlineQueryResultGame +from ._inline.inputtextmessagecontent import InputTextMessageContent +from ._inline.inputlocationmessagecontent import InputLocationMessageContent +from ._inline.inputvenuemessagecontent import InputVenueMessageContent +from ._payment.labeledprice import LabeledPrice +from ._inline.inputinvoicemessagecontent import InputInvoiceMessageContent +from ._inline.inputcontactmessagecontent import InputContactMessageContent +from ._payment.shippingoption import ShippingOption +from ._payment.precheckoutquery import PreCheckoutQuery +from ._payment.shippingquery import ShippingQuery +from ._webhookinfo import WebhookInfo +from ._games.gamehighscore import GameHighScore +from ._update import Update +from ._files.inputmedia import ( InputMedia, InputMediaVideo, InputMediaPhoto, @@ -130,7 +130,7 @@ InputMediaAudio, InputMediaDocument, ) -from .passport.passportelementerrors import ( +from ._passport.passportelementerrors import ( PassportElementError, PassportElementErrorDataField, PassportElementErrorFile, @@ -142,14 +142,14 @@ PassportElementErrorTranslationFiles, PassportElementErrorUnspecified, ) -from .passport.credentials import ( +from ._passport.credentials import ( Credentials, DataCredentials, SecureData, SecureValue, FileCredentials, ) -from .botcommandscope import ( +from ._botcommandscope import ( BotCommandScope, BotCommandScopeDefault, BotCommandScopeAllPrivateChats, @@ -159,8 +159,8 @@ BotCommandScopeChatAdministrators, BotCommandScopeChatMember, ) -from .bot import Bot -from .version import __version__, bot_api_version # noqa: F401 +from ._bot import Bot +from ._version import __version__, bot_api_version # noqa: F401 __author__ = 'devs@python-telegram-bot.org' diff --git a/telegram/bot.py b/telegram/_bot.py similarity index 99% rename from telegram/bot.py rename to telegram/_bot.py index 48d31f75a1e..dff25b8333f 100644 --- a/telegram/bot.py +++ b/telegram/_bot.py @@ -93,11 +93,11 @@ ) from telegram.constants import MAX_INLINE_QUERY_RESULTS from telegram.error import InvalidToken, TelegramError -from telegram.utils.defaultvalue import DEFAULT_NONE, DefaultValue, DEFAULT_20 -from telegram.utils.datetime import to_timestamp -from telegram.utils.files import is_local_file, parse_file_input from telegram.request import Request -from telegram.utils.types import FileInput, JSONDict, ODVInput, DVInput +from telegram._utils.defaultvalue import DEFAULT_NONE, DefaultValue, DEFAULT_20 +from telegram._utils.datetime import to_timestamp +from telegram._utils.files import is_local_file, parse_file_input +from telegram._utils.types import FileInput, JSONDict, ODVInput, DVInput if TYPE_CHECKING: from telegram import ( diff --git a/telegram/botcommand.py b/telegram/_botcommand.py similarity index 100% rename from telegram/botcommand.py rename to telegram/_botcommand.py diff --git a/telegram/botcommandscope.py b/telegram/_botcommandscope.py similarity index 99% rename from telegram/botcommandscope.py rename to telegram/_botcommandscope.py index 7137a5acc96..2fa1f8978d4 100644 --- a/telegram/botcommandscope.py +++ b/telegram/_botcommandscope.py @@ -21,7 +21,7 @@ from typing import Any, Union, Optional, TYPE_CHECKING, Dict, Type from telegram import TelegramObject, constants -from telegram.utils.types import JSONDict +from telegram._utils.types import JSONDict if TYPE_CHECKING: from telegram import Bot diff --git a/telegram/callbackquery.py b/telegram/_callbackquery.py similarity index 99% rename from telegram/callbackquery.py rename to telegram/_callbackquery.py index 9a485453def..ca6b5af99f5 100644 --- a/telegram/callbackquery.py +++ b/telegram/_callbackquery.py @@ -21,8 +21,8 @@ from typing import TYPE_CHECKING, Any, List, Optional, Union, Tuple, ClassVar from telegram import Message, TelegramObject, User, Location, ReplyMarkup, constants -from telegram.utils.defaultvalue import DEFAULT_NONE -from telegram.utils.types import JSONDict, ODVInput, DVInput +from telegram._utils.defaultvalue import DEFAULT_NONE +from telegram._utils.types import JSONDict, ODVInput, DVInput if TYPE_CHECKING: from telegram import ( diff --git a/telegram/chat.py b/telegram/_chat.py similarity index 99% rename from telegram/chat.py rename to telegram/_chat.py index 29ff66c05f1..8b0ca5881ce 100644 --- a/telegram/chat.py +++ b/telegram/_chat.py @@ -22,11 +22,11 @@ from typing import TYPE_CHECKING, List, Optional, ClassVar, Union, Tuple, Any from telegram import ChatPhoto, TelegramObject, constants -from telegram.utils.types import JSONDict, FileInput, ODVInput, DVInput +from telegram._utils.types import JSONDict, FileInput, ODVInput, DVInput +from telegram._utils.defaultvalue import DEFAULT_NONE, DEFAULT_20 -from .chatpermissions import ChatPermissions -from .chatlocation import ChatLocation -from .utils.defaultvalue import DEFAULT_NONE, DEFAULT_20 +from telegram._chatpermissions import ChatPermissions +from telegram._chatlocation import ChatLocation if TYPE_CHECKING: from telegram import ( diff --git a/telegram/chataction.py b/telegram/_chataction.py similarity index 100% rename from telegram/chataction.py rename to telegram/_chataction.py diff --git a/telegram/chatinvitelink.py b/telegram/_chatinvitelink.py similarity index 97% rename from telegram/chatinvitelink.py rename to telegram/_chatinvitelink.py index 6b6571c5ae7..eca2f256d0a 100644 --- a/telegram/chatinvitelink.py +++ b/telegram/_chatinvitelink.py @@ -21,8 +21,8 @@ from typing import TYPE_CHECKING, Any, Optional from telegram import TelegramObject, User -from telegram.utils.datetime import from_timestamp, to_timestamp -from telegram.utils.types import JSONDict +from telegram._utils.datetime import from_timestamp, to_timestamp +from telegram._utils.types import JSONDict if TYPE_CHECKING: from telegram import Bot diff --git a/telegram/chatlocation.py b/telegram/_chatlocation.py similarity index 96% rename from telegram/chatlocation.py rename to telegram/_chatlocation.py index 4cd06e8da0e..e22b30828c3 100644 --- a/telegram/chatlocation.py +++ b/telegram/_chatlocation.py @@ -21,9 +21,9 @@ from typing import TYPE_CHECKING, Any, Optional from telegram import TelegramObject -from telegram.utils.types import JSONDict +from telegram._utils.types import JSONDict -from .files.location import Location +from telegram._files.location import Location if TYPE_CHECKING: from telegram import Bot diff --git a/telegram/chatmember.py b/telegram/_chatmember.py similarity index 99% rename from telegram/chatmember.py rename to telegram/_chatmember.py index 081a0264c43..02c53bd7183 100644 --- a/telegram/chatmember.py +++ b/telegram/_chatmember.py @@ -21,8 +21,8 @@ from typing import TYPE_CHECKING, Optional, ClassVar, Dict, Type from telegram import TelegramObject, User, constants -from telegram.utils.datetime import from_timestamp, to_timestamp -from telegram.utils.types import JSONDict +from telegram._utils.datetime import from_timestamp, to_timestamp +from telegram._utils.types import JSONDict if TYPE_CHECKING: from telegram import Bot diff --git a/telegram/chatmemberupdated.py b/telegram/_chatmemberupdated.py similarity index 98% rename from telegram/chatmemberupdated.py rename to telegram/_chatmemberupdated.py index 1d93f1fa883..0da17ea5e07 100644 --- a/telegram/chatmemberupdated.py +++ b/telegram/_chatmemberupdated.py @@ -21,8 +21,8 @@ from typing import TYPE_CHECKING, Any, Optional, Dict, Tuple, Union from telegram import TelegramObject, User, Chat, ChatMember, ChatInviteLink -from telegram.utils.datetime import from_timestamp, to_timestamp -from telegram.utils.types import JSONDict +from telegram._utils.datetime import from_timestamp, to_timestamp +from telegram._utils.types import JSONDict if TYPE_CHECKING: from telegram import Bot diff --git a/telegram/chatpermissions.py b/telegram/_chatpermissions.py similarity index 100% rename from telegram/chatpermissions.py rename to telegram/_chatpermissions.py diff --git a/telegram/choseninlineresult.py b/telegram/_choseninlineresult.py similarity index 98% rename from telegram/choseninlineresult.py rename to telegram/_choseninlineresult.py index c993b07f7e0..7feb4a33279 100644 --- a/telegram/choseninlineresult.py +++ b/telegram/_choseninlineresult.py @@ -22,7 +22,7 @@ from typing import TYPE_CHECKING, Any, Optional from telegram import Location, TelegramObject, User -from telegram.utils.types import JSONDict +from telegram._utils.types import JSONDict if TYPE_CHECKING: from telegram import Bot diff --git a/telegram/dice.py b/telegram/_dice.py similarity index 100% rename from telegram/dice.py rename to telegram/_dice.py diff --git a/telegram/files/__init__.py b/telegram/_files/__init__.py similarity index 100% rename from telegram/files/__init__.py rename to telegram/_files/__init__.py diff --git a/telegram/files/animation.py b/telegram/_files/animation.py similarity index 97% rename from telegram/files/animation.py rename to telegram/_files/animation.py index 2bf2a05fc48..31d19941fb6 100644 --- a/telegram/files/animation.py +++ b/telegram/_files/animation.py @@ -20,8 +20,8 @@ from typing import TYPE_CHECKING, Any, Optional from telegram import PhotoSize, TelegramObject -from telegram.utils.defaultvalue import DEFAULT_NONE -from telegram.utils.types import JSONDict, ODVInput +from telegram._utils.defaultvalue import DEFAULT_NONE +from telegram._utils.types import JSONDict, ODVInput if TYPE_CHECKING: from telegram import Bot, File diff --git a/telegram/files/audio.py b/telegram/_files/audio.py similarity index 98% rename from telegram/files/audio.py rename to telegram/_files/audio.py index 8aaf685b28d..8c8a8e06798 100644 --- a/telegram/files/audio.py +++ b/telegram/_files/audio.py @@ -21,8 +21,8 @@ from typing import TYPE_CHECKING, Any, Optional from telegram import PhotoSize, TelegramObject -from telegram.utils.defaultvalue import DEFAULT_NONE -from telegram.utils.types import JSONDict, ODVInput +from telegram._utils.defaultvalue import DEFAULT_NONE +from telegram._utils.types import JSONDict, ODVInput if TYPE_CHECKING: from telegram import Bot, File diff --git a/telegram/files/chatphoto.py b/telegram/_files/chatphoto.py similarity index 97% rename from telegram/files/chatphoto.py rename to telegram/_files/chatphoto.py index 1e2f7e984a3..83ca6f507c8 100644 --- a/telegram/files/chatphoto.py +++ b/telegram/_files/chatphoto.py @@ -20,8 +20,8 @@ from typing import TYPE_CHECKING, Any from telegram import TelegramObject -from telegram.utils.defaultvalue import DEFAULT_NONE -from telegram.utils.types import JSONDict, ODVInput +from telegram._utils.defaultvalue import DEFAULT_NONE +from telegram._utils.types import JSONDict, ODVInput if TYPE_CHECKING: from telegram import Bot, File diff --git a/telegram/files/contact.py b/telegram/_files/contact.py similarity index 100% rename from telegram/files/contact.py rename to telegram/_files/contact.py diff --git a/telegram/files/document.py b/telegram/_files/document.py similarity index 97% rename from telegram/files/document.py rename to telegram/_files/document.py index 12abed22c8d..8afff799022 100644 --- a/telegram/files/document.py +++ b/telegram/_files/document.py @@ -21,8 +21,8 @@ from typing import TYPE_CHECKING, Any, Optional from telegram import PhotoSize, TelegramObject -from telegram.utils.defaultvalue import DEFAULT_NONE -from telegram.utils.types import JSONDict, ODVInput +from telegram._utils.defaultvalue import DEFAULT_NONE +from telegram._utils.types import JSONDict, ODVInput if TYPE_CHECKING: from telegram import Bot, File diff --git a/telegram/files/file.py b/telegram/_files/file.py similarity index 98% rename from telegram/files/file.py rename to telegram/_files/file.py index 0f0d859f91a..45cd9438257 100644 --- a/telegram/files/file.py +++ b/telegram/_files/file.py @@ -24,8 +24,8 @@ from typing import IO, TYPE_CHECKING, Any, Optional, Union from telegram import TelegramObject -from telegram.passport.credentials import decrypt -from telegram.utils.files import is_local_file +from telegram._passport.credentials import decrypt +from telegram._utils.files import is_local_file if TYPE_CHECKING: from telegram import Bot, FileCredentials diff --git a/telegram/files/inputfile.py b/telegram/_files/inputfile.py similarity index 100% rename from telegram/files/inputfile.py rename to telegram/_files/inputfile.py diff --git a/telegram/files/inputmedia.py b/telegram/_files/inputmedia.py similarity index 99% rename from telegram/files/inputmedia.py rename to telegram/_files/inputmedia.py index 6b33d4fcdb3..f06eb6231ab 100644 --- a/telegram/files/inputmedia.py +++ b/telegram/_files/inputmedia.py @@ -30,9 +30,9 @@ Video, MessageEntity, ) -from telegram.utils.defaultvalue import DEFAULT_NONE -from telegram.utils.files import parse_file_input -from telegram.utils.types import FileInput, JSONDict, ODVInput +from telegram._utils.defaultvalue import DEFAULT_NONE +from telegram._utils.files import parse_file_input +from telegram._utils.types import FileInput, JSONDict, ODVInput class InputMedia(TelegramObject): diff --git a/telegram/files/location.py b/telegram/_files/location.py similarity index 100% rename from telegram/files/location.py rename to telegram/_files/location.py diff --git a/telegram/files/photosize.py b/telegram/_files/photosize.py similarity index 97% rename from telegram/files/photosize.py rename to telegram/_files/photosize.py index 2edd48b9b2b..74498dad358 100644 --- a/telegram/files/photosize.py +++ b/telegram/_files/photosize.py @@ -21,8 +21,8 @@ from typing import TYPE_CHECKING, Any from telegram import TelegramObject -from telegram.utils.defaultvalue import DEFAULT_NONE -from telegram.utils.types import JSONDict, ODVInput +from telegram._utils.defaultvalue import DEFAULT_NONE +from telegram._utils.types import JSONDict, ODVInput if TYPE_CHECKING: from telegram import Bot, File diff --git a/telegram/files/sticker.py b/telegram/_files/sticker.py similarity index 99% rename from telegram/files/sticker.py rename to telegram/_files/sticker.py index f783453c57e..0ca1829b6a9 100644 --- a/telegram/files/sticker.py +++ b/telegram/_files/sticker.py @@ -21,8 +21,8 @@ from typing import TYPE_CHECKING, Any, List, Optional, ClassVar from telegram import PhotoSize, TelegramObject, constants -from telegram.utils.defaultvalue import DEFAULT_NONE -from telegram.utils.types import JSONDict, ODVInput +from telegram._utils.defaultvalue import DEFAULT_NONE +from telegram._utils.types import JSONDict, ODVInput if TYPE_CHECKING: from telegram import Bot, File diff --git a/telegram/files/venue.py b/telegram/_files/venue.py similarity index 98% rename from telegram/files/venue.py rename to telegram/_files/venue.py index a45c9b64d46..f4bbd2cb703 100644 --- a/telegram/files/venue.py +++ b/telegram/_files/venue.py @@ -21,7 +21,7 @@ from typing import TYPE_CHECKING, Any, Optional from telegram import Location, TelegramObject -from telegram.utils.types import JSONDict +from telegram._utils.types import JSONDict if TYPE_CHECKING: from telegram import Bot diff --git a/telegram/files/video.py b/telegram/_files/video.py similarity index 97% rename from telegram/files/video.py rename to telegram/_files/video.py index c29e0605afa..aa4905b2bb9 100644 --- a/telegram/files/video.py +++ b/telegram/_files/video.py @@ -21,8 +21,8 @@ from typing import TYPE_CHECKING, Any, Optional from telegram import PhotoSize, TelegramObject -from telegram.utils.defaultvalue import DEFAULT_NONE -from telegram.utils.types import JSONDict, ODVInput +from telegram._utils.defaultvalue import DEFAULT_NONE +from telegram._utils.types import JSONDict, ODVInput if TYPE_CHECKING: from telegram import Bot, File diff --git a/telegram/files/videonote.py b/telegram/_files/videonote.py similarity index 97% rename from telegram/files/videonote.py rename to telegram/_files/videonote.py index 250b91fde0e..2c01dc60f67 100644 --- a/telegram/files/videonote.py +++ b/telegram/_files/videonote.py @@ -21,8 +21,8 @@ from typing import TYPE_CHECKING, Optional, Any from telegram import PhotoSize, TelegramObject -from telegram.utils.defaultvalue import DEFAULT_NONE -from telegram.utils.types import JSONDict, ODVInput +from telegram._utils.defaultvalue import DEFAULT_NONE +from telegram._utils.types import JSONDict, ODVInput if TYPE_CHECKING: from telegram import Bot, File diff --git a/telegram/files/voice.py b/telegram/_files/voice.py similarity index 97% rename from telegram/files/voice.py rename to telegram/_files/voice.py index 472015906b4..ba0b1f2bb35 100644 --- a/telegram/files/voice.py +++ b/telegram/_files/voice.py @@ -21,8 +21,8 @@ from typing import TYPE_CHECKING, Any from telegram import TelegramObject -from telegram.utils.defaultvalue import DEFAULT_NONE -from telegram.utils.types import JSONDict, ODVInput +from telegram._utils.defaultvalue import DEFAULT_NONE +from telegram._utils.types import JSONDict, ODVInput if TYPE_CHECKING: from telegram import Bot, File diff --git a/telegram/forcereply.py b/telegram/_forcereply.py similarity index 100% rename from telegram/forcereply.py rename to telegram/_forcereply.py diff --git a/telegram/games/__init__.py b/telegram/_games/__init__.py similarity index 100% rename from telegram/games/__init__.py rename to telegram/_games/__init__.py diff --git a/telegram/games/callbackgame.py b/telegram/_games/callbackgame.py similarity index 100% rename from telegram/games/callbackgame.py rename to telegram/_games/callbackgame.py diff --git a/telegram/games/game.py b/telegram/_games/game.py similarity index 99% rename from telegram/games/game.py rename to telegram/_games/game.py index 7f3e2bc110d..4d8d32984f3 100644 --- a/telegram/games/game.py +++ b/telegram/_games/game.py @@ -22,7 +22,7 @@ from typing import TYPE_CHECKING, Any, Dict, List, Optional from telegram import Animation, MessageEntity, PhotoSize, TelegramObject -from telegram.utils.types import JSONDict +from telegram._utils.types import JSONDict if TYPE_CHECKING: from telegram import Bot diff --git a/telegram/games/gamehighscore.py b/telegram/_games/gamehighscore.py similarity index 98% rename from telegram/games/gamehighscore.py rename to telegram/_games/gamehighscore.py index 418c7f4683a..db47e251632 100644 --- a/telegram/games/gamehighscore.py +++ b/telegram/_games/gamehighscore.py @@ -21,7 +21,7 @@ from typing import TYPE_CHECKING, Optional from telegram import TelegramObject, User -from telegram.utils.types import JSONDict +from telegram._utils.types import JSONDict if TYPE_CHECKING: from telegram import Bot diff --git a/telegram/inline/__init__.py b/telegram/_inline/__init__.py similarity index 100% rename from telegram/inline/__init__.py rename to telegram/_inline/__init__.py diff --git a/telegram/inline/inlinekeyboardbutton.py b/telegram/_inline/inlinekeyboardbutton.py similarity index 100% rename from telegram/inline/inlinekeyboardbutton.py rename to telegram/_inline/inlinekeyboardbutton.py diff --git a/telegram/inline/inlinekeyboardmarkup.py b/telegram/_inline/inlinekeyboardmarkup.py similarity index 99% rename from telegram/inline/inlinekeyboardmarkup.py rename to telegram/_inline/inlinekeyboardmarkup.py index 634105296b8..1ca1e20a475 100644 --- a/telegram/inline/inlinekeyboardmarkup.py +++ b/telegram/_inline/inlinekeyboardmarkup.py @@ -21,7 +21,7 @@ from typing import TYPE_CHECKING, Any, List, Optional from telegram import InlineKeyboardButton, ReplyMarkup -from telegram.utils.types import JSONDict +from telegram._utils.types import JSONDict if TYPE_CHECKING: from telegram import Bot diff --git a/telegram/inline/inlinequery.py b/telegram/_inline/inlinequery.py similarity index 98% rename from telegram/inline/inlinequery.py rename to telegram/_inline/inlinequery.py index 7ea70fdee4a..c70184bbf1e 100644 --- a/telegram/inline/inlinequery.py +++ b/telegram/_inline/inlinequery.py @@ -22,8 +22,8 @@ from typing import TYPE_CHECKING, Any, Optional, Union, Callable, ClassVar, Sequence from telegram import Location, TelegramObject, User, constants -from telegram.utils.defaultvalue import DEFAULT_NONE -from telegram.utils.types import JSONDict, ODVInput +from telegram._utils.defaultvalue import DEFAULT_NONE +from telegram._utils.types import JSONDict, ODVInput if TYPE_CHECKING: from telegram import Bot, InlineQueryResult diff --git a/telegram/inline/inlinequeryresult.py b/telegram/_inline/inlinequeryresult.py similarity index 98% rename from telegram/inline/inlinequeryresult.py rename to telegram/_inline/inlinequeryresult.py index 532a03c347b..06c72748ea4 100644 --- a/telegram/inline/inlinequeryresult.py +++ b/telegram/_inline/inlinequeryresult.py @@ -22,7 +22,7 @@ from typing import Any from telegram import TelegramObject -from telegram.utils.types import JSONDict +from telegram._utils.types import JSONDict class InlineQueryResult(TelegramObject): diff --git a/telegram/inline/inlinequeryresultarticle.py b/telegram/_inline/inlinequeryresultarticle.py similarity index 100% rename from telegram/inline/inlinequeryresultarticle.py rename to telegram/_inline/inlinequeryresultarticle.py diff --git a/telegram/inline/inlinequeryresultaudio.py b/telegram/_inline/inlinequeryresultaudio.py similarity index 98% rename from telegram/inline/inlinequeryresultaudio.py rename to telegram/_inline/inlinequeryresultaudio.py index e19041f5e11..d1ef58a5daa 100644 --- a/telegram/inline/inlinequeryresultaudio.py +++ b/telegram/_inline/inlinequeryresultaudio.py @@ -21,8 +21,8 @@ from typing import TYPE_CHECKING, Any, Union, Tuple, List from telegram import InlineQueryResult, MessageEntity -from telegram.utils.defaultvalue import DEFAULT_NONE -from telegram.utils.types import ODVInput +from telegram._utils.defaultvalue import DEFAULT_NONE +from telegram._utils.types import ODVInput if TYPE_CHECKING: from telegram import InputMessageContent, ReplyMarkup diff --git a/telegram/inline/inlinequeryresultcachedaudio.py b/telegram/_inline/inlinequeryresultcachedaudio.py similarity index 97% rename from telegram/inline/inlinequeryresultcachedaudio.py rename to telegram/_inline/inlinequeryresultcachedaudio.py index f16b9472fb2..5094bd7725a 100644 --- a/telegram/inline/inlinequeryresultcachedaudio.py +++ b/telegram/_inline/inlinequeryresultcachedaudio.py @@ -21,8 +21,8 @@ from typing import TYPE_CHECKING, Any, Union, Tuple, List from telegram import InlineQueryResult, MessageEntity -from telegram.utils.defaultvalue import DEFAULT_NONE -from telegram.utils.types import ODVInput +from telegram._utils.defaultvalue import DEFAULT_NONE +from telegram._utils.types import ODVInput if TYPE_CHECKING: from telegram import InputMessageContent, ReplyMarkup diff --git a/telegram/inline/inlinequeryresultcacheddocument.py b/telegram/_inline/inlinequeryresultcacheddocument.py similarity index 98% rename from telegram/inline/inlinequeryresultcacheddocument.py rename to telegram/_inline/inlinequeryresultcacheddocument.py index dec3ebbf5ac..19546d67f68 100644 --- a/telegram/inline/inlinequeryresultcacheddocument.py +++ b/telegram/_inline/inlinequeryresultcacheddocument.py @@ -22,8 +22,8 @@ from typing import TYPE_CHECKING, Any, Union, Tuple, List from telegram import InlineQueryResult, MessageEntity -from telegram.utils.defaultvalue import DEFAULT_NONE -from telegram.utils.types import ODVInput +from telegram._utils.defaultvalue import DEFAULT_NONE +from telegram._utils.types import ODVInput if TYPE_CHECKING: from telegram import InputMessageContent, ReplyMarkup diff --git a/telegram/inline/inlinequeryresultcachedgif.py b/telegram/_inline/inlinequeryresultcachedgif.py similarity index 98% rename from telegram/inline/inlinequeryresultcachedgif.py rename to telegram/_inline/inlinequeryresultcachedgif.py index e5af12f5377..e3f883b86ff 100644 --- a/telegram/inline/inlinequeryresultcachedgif.py +++ b/telegram/_inline/inlinequeryresultcachedgif.py @@ -21,8 +21,8 @@ from typing import TYPE_CHECKING, Any, Union, Tuple, List from telegram import InlineQueryResult, MessageEntity -from telegram.utils.defaultvalue import DEFAULT_NONE -from telegram.utils.types import ODVInput +from telegram._utils.defaultvalue import DEFAULT_NONE +from telegram._utils.types import ODVInput if TYPE_CHECKING: from telegram import InputMessageContent, ReplyMarkup diff --git a/telegram/inline/inlinequeryresultcachedmpeg4gif.py b/telegram/_inline/inlinequeryresultcachedmpeg4gif.py similarity index 98% rename from telegram/inline/inlinequeryresultcachedmpeg4gif.py rename to telegram/_inline/inlinequeryresultcachedmpeg4gif.py index 624dd09aee8..ce6efbc838f 100644 --- a/telegram/inline/inlinequeryresultcachedmpeg4gif.py +++ b/telegram/_inline/inlinequeryresultcachedmpeg4gif.py @@ -21,8 +21,8 @@ from typing import TYPE_CHECKING, Any, Union, Tuple, List from telegram import InlineQueryResult, MessageEntity -from telegram.utils.defaultvalue import DEFAULT_NONE -from telegram.utils.types import ODVInput +from telegram._utils.defaultvalue import DEFAULT_NONE +from telegram._utils.types import ODVInput if TYPE_CHECKING: from telegram import InputMessageContent, ReplyMarkup diff --git a/telegram/inline/inlinequeryresultcachedphoto.py b/telegram/_inline/inlinequeryresultcachedphoto.py similarity index 98% rename from telegram/inline/inlinequeryresultcachedphoto.py rename to telegram/_inline/inlinequeryresultcachedphoto.py index a18857767be..5e5882e8096 100644 --- a/telegram/inline/inlinequeryresultcachedphoto.py +++ b/telegram/_inline/inlinequeryresultcachedphoto.py @@ -22,8 +22,8 @@ from typing import TYPE_CHECKING, Any, Union, Tuple, List from telegram import InlineQueryResult, MessageEntity -from telegram.utils.defaultvalue import DEFAULT_NONE -from telegram.utils.types import ODVInput +from telegram._utils.defaultvalue import DEFAULT_NONE +from telegram._utils.types import ODVInput if TYPE_CHECKING: from telegram import InputMessageContent, ReplyMarkup diff --git a/telegram/inline/inlinequeryresultcachedsticker.py b/telegram/_inline/inlinequeryresultcachedsticker.py similarity index 100% rename from telegram/inline/inlinequeryresultcachedsticker.py rename to telegram/_inline/inlinequeryresultcachedsticker.py diff --git a/telegram/inline/inlinequeryresultcachedvideo.py b/telegram/_inline/inlinequeryresultcachedvideo.py similarity index 98% rename from telegram/inline/inlinequeryresultcachedvideo.py rename to telegram/_inline/inlinequeryresultcachedvideo.py index 309b0b64ad5..de77a9a522c 100644 --- a/telegram/inline/inlinequeryresultcachedvideo.py +++ b/telegram/_inline/inlinequeryresultcachedvideo.py @@ -21,8 +21,8 @@ from typing import TYPE_CHECKING, Any, Union, Tuple, List from telegram import InlineQueryResult, MessageEntity -from telegram.utils.defaultvalue import DEFAULT_NONE -from telegram.utils.types import ODVInput +from telegram._utils.defaultvalue import DEFAULT_NONE +from telegram._utils.types import ODVInput if TYPE_CHECKING: from telegram import InputMessageContent, ReplyMarkup diff --git a/telegram/inline/inlinequeryresultcachedvoice.py b/telegram/_inline/inlinequeryresultcachedvoice.py similarity index 97% rename from telegram/inline/inlinequeryresultcachedvoice.py rename to telegram/_inline/inlinequeryresultcachedvoice.py index 89762e85187..650cf3af2fd 100644 --- a/telegram/inline/inlinequeryresultcachedvoice.py +++ b/telegram/_inline/inlinequeryresultcachedvoice.py @@ -21,8 +21,8 @@ from typing import TYPE_CHECKING, Any, Union, Tuple, List from telegram import InlineQueryResult, MessageEntity -from telegram.utils.defaultvalue import DEFAULT_NONE -from telegram.utils.types import ODVInput +from telegram._utils.defaultvalue import DEFAULT_NONE +from telegram._utils.types import ODVInput if TYPE_CHECKING: from telegram import InputMessageContent, ReplyMarkup diff --git a/telegram/inline/inlinequeryresultcontact.py b/telegram/_inline/inlinequeryresultcontact.py similarity index 100% rename from telegram/inline/inlinequeryresultcontact.py rename to telegram/_inline/inlinequeryresultcontact.py diff --git a/telegram/inline/inlinequeryresultdocument.py b/telegram/_inline/inlinequeryresultdocument.py similarity index 98% rename from telegram/inline/inlinequeryresultdocument.py rename to telegram/_inline/inlinequeryresultdocument.py index e3bd625088f..74a7836b75e 100644 --- a/telegram/inline/inlinequeryresultdocument.py +++ b/telegram/_inline/inlinequeryresultdocument.py @@ -21,8 +21,8 @@ from typing import TYPE_CHECKING, Any, Union, Tuple, List from telegram import InlineQueryResult, MessageEntity -from telegram.utils.defaultvalue import DEFAULT_NONE -from telegram.utils.types import ODVInput +from telegram._utils.defaultvalue import DEFAULT_NONE +from telegram._utils.types import ODVInput if TYPE_CHECKING: from telegram import InputMessageContent, ReplyMarkup diff --git a/telegram/inline/inlinequeryresultgame.py b/telegram/_inline/inlinequeryresultgame.py similarity index 100% rename from telegram/inline/inlinequeryresultgame.py rename to telegram/_inline/inlinequeryresultgame.py diff --git a/telegram/inline/inlinequeryresultgif.py b/telegram/_inline/inlinequeryresultgif.py similarity index 98% rename from telegram/inline/inlinequeryresultgif.py rename to telegram/_inline/inlinequeryresultgif.py index 36ce5e6ef41..d2ceedbb6ab 100644 --- a/telegram/inline/inlinequeryresultgif.py +++ b/telegram/_inline/inlinequeryresultgif.py @@ -22,8 +22,8 @@ from typing import TYPE_CHECKING, Any, Union, Tuple, List from telegram import InlineQueryResult, MessageEntity -from telegram.utils.defaultvalue import DEFAULT_NONE -from telegram.utils.types import ODVInput +from telegram._utils.defaultvalue import DEFAULT_NONE +from telegram._utils.types import ODVInput if TYPE_CHECKING: from telegram import InputMessageContent, ReplyMarkup diff --git a/telegram/inline/inlinequeryresultlocation.py b/telegram/_inline/inlinequeryresultlocation.py similarity index 100% rename from telegram/inline/inlinequeryresultlocation.py rename to telegram/_inline/inlinequeryresultlocation.py diff --git a/telegram/inline/inlinequeryresultmpeg4gif.py b/telegram/_inline/inlinequeryresultmpeg4gif.py similarity index 98% rename from telegram/inline/inlinequeryresultmpeg4gif.py rename to telegram/_inline/inlinequeryresultmpeg4gif.py index 0b8718e583d..5bd15fd7821 100644 --- a/telegram/inline/inlinequeryresultmpeg4gif.py +++ b/telegram/_inline/inlinequeryresultmpeg4gif.py @@ -21,8 +21,8 @@ from typing import TYPE_CHECKING, Any, Union, Tuple, List from telegram import InlineQueryResult, MessageEntity -from telegram.utils.defaultvalue import DEFAULT_NONE -from telegram.utils.types import ODVInput +from telegram._utils.defaultvalue import DEFAULT_NONE +from telegram._utils.types import ODVInput if TYPE_CHECKING: from telegram import InputMessageContent, ReplyMarkup diff --git a/telegram/inline/inlinequeryresultphoto.py b/telegram/_inline/inlinequeryresultphoto.py similarity index 98% rename from telegram/inline/inlinequeryresultphoto.py rename to telegram/_inline/inlinequeryresultphoto.py index 6bf71ac514c..e476166a1e8 100644 --- a/telegram/inline/inlinequeryresultphoto.py +++ b/telegram/_inline/inlinequeryresultphoto.py @@ -21,8 +21,8 @@ from typing import TYPE_CHECKING, Any, Union, Tuple, List from telegram import InlineQueryResult, MessageEntity -from telegram.utils.defaultvalue import DEFAULT_NONE -from telegram.utils.types import ODVInput +from telegram._utils.defaultvalue import DEFAULT_NONE +from telegram._utils.types import ODVInput if TYPE_CHECKING: from telegram import InputMessageContent, ReplyMarkup diff --git a/telegram/inline/inlinequeryresultvenue.py b/telegram/_inline/inlinequeryresultvenue.py similarity index 100% rename from telegram/inline/inlinequeryresultvenue.py rename to telegram/_inline/inlinequeryresultvenue.py diff --git a/telegram/inline/inlinequeryresultvideo.py b/telegram/_inline/inlinequeryresultvideo.py similarity index 98% rename from telegram/inline/inlinequeryresultvideo.py rename to telegram/_inline/inlinequeryresultvideo.py index a6d58d68abc..7ea81ab8409 100644 --- a/telegram/inline/inlinequeryresultvideo.py +++ b/telegram/_inline/inlinequeryresultvideo.py @@ -21,8 +21,8 @@ from typing import TYPE_CHECKING, Any, Union, Tuple, List from telegram import InlineQueryResult, MessageEntity -from telegram.utils.defaultvalue import DEFAULT_NONE -from telegram.utils.types import ODVInput +from telegram._utils.defaultvalue import DEFAULT_NONE +from telegram._utils.types import ODVInput if TYPE_CHECKING: from telegram import InputMessageContent, ReplyMarkup diff --git a/telegram/inline/inlinequeryresultvoice.py b/telegram/_inline/inlinequeryresultvoice.py similarity index 98% rename from telegram/inline/inlinequeryresultvoice.py rename to telegram/_inline/inlinequeryresultvoice.py index 0e4084533c9..82ee8a38119 100644 --- a/telegram/inline/inlinequeryresultvoice.py +++ b/telegram/_inline/inlinequeryresultvoice.py @@ -21,8 +21,8 @@ from typing import TYPE_CHECKING, Any, Union, Tuple, List from telegram import InlineQueryResult, MessageEntity -from telegram.utils.defaultvalue import DEFAULT_NONE -from telegram.utils.types import ODVInput +from telegram._utils.defaultvalue import DEFAULT_NONE +from telegram._utils.types import ODVInput if TYPE_CHECKING: from telegram import InputMessageContent, ReplyMarkup diff --git a/telegram/inline/inputcontactmessagecontent.py b/telegram/_inline/inputcontactmessagecontent.py similarity index 100% rename from telegram/inline/inputcontactmessagecontent.py rename to telegram/_inline/inputcontactmessagecontent.py diff --git a/telegram/inline/inputinvoicemessagecontent.py b/telegram/_inline/inputinvoicemessagecontent.py similarity index 99% rename from telegram/inline/inputinvoicemessagecontent.py rename to telegram/_inline/inputinvoicemessagecontent.py index ee6783725eb..832181048cd 100644 --- a/telegram/inline/inputinvoicemessagecontent.py +++ b/telegram/_inline/inputinvoicemessagecontent.py @@ -21,7 +21,7 @@ from typing import Any, List, Optional, TYPE_CHECKING from telegram import InputMessageContent, LabeledPrice -from telegram.utils.types import JSONDict +from telegram._utils.types import JSONDict if TYPE_CHECKING: from telegram import Bot diff --git a/telegram/inline/inputlocationmessagecontent.py b/telegram/_inline/inputlocationmessagecontent.py similarity index 100% rename from telegram/inline/inputlocationmessagecontent.py rename to telegram/_inline/inputlocationmessagecontent.py diff --git a/telegram/inline/inputmessagecontent.py b/telegram/_inline/inputmessagecontent.py similarity index 100% rename from telegram/inline/inputmessagecontent.py rename to telegram/_inline/inputmessagecontent.py diff --git a/telegram/inline/inputtextmessagecontent.py b/telegram/_inline/inputtextmessagecontent.py similarity index 97% rename from telegram/inline/inputtextmessagecontent.py rename to telegram/_inline/inputtextmessagecontent.py index 69b79c52458..f1278589445 100644 --- a/telegram/inline/inputtextmessagecontent.py +++ b/telegram/_inline/inputtextmessagecontent.py @@ -21,8 +21,8 @@ from typing import Any, Union, Tuple, List from telegram import InputMessageContent, MessageEntity -from telegram.utils.defaultvalue import DEFAULT_NONE -from telegram.utils.types import JSONDict, ODVInput +from telegram._utils.defaultvalue import DEFAULT_NONE +from telegram._utils.types import JSONDict, ODVInput class InputTextMessageContent(InputMessageContent): diff --git a/telegram/inline/inputvenuemessagecontent.py b/telegram/_inline/inputvenuemessagecontent.py similarity index 100% rename from telegram/inline/inputvenuemessagecontent.py rename to telegram/_inline/inputvenuemessagecontent.py diff --git a/telegram/keyboardbutton.py b/telegram/_keyboardbutton.py similarity index 100% rename from telegram/keyboardbutton.py rename to telegram/_keyboardbutton.py diff --git a/telegram/keyboardbuttonpolltype.py b/telegram/_keyboardbuttonpolltype.py similarity index 100% rename from telegram/keyboardbuttonpolltype.py rename to telegram/_keyboardbuttonpolltype.py diff --git a/telegram/loginurl.py b/telegram/_loginurl.py similarity index 100% rename from telegram/loginurl.py rename to telegram/_loginurl.py diff --git a/telegram/message.py b/telegram/_message.py similarity index 99% rename from telegram/message.py rename to telegram/_message.py index 8a55bb2b688..9cc1338fd72 100644 --- a/telegram/message.py +++ b/telegram/_message.py @@ -56,9 +56,9 @@ VoiceChatScheduled, ) from telegram.helpers import escape_markdown -from telegram.utils.datetime import from_timestamp, to_timestamp -from telegram.utils.defaultvalue import DEFAULT_NONE, DEFAULT_20 -from telegram.utils.types import JSONDict, FileInput, ODVInput, DVInput +from telegram._utils.datetime import from_timestamp, to_timestamp +from telegram._utils.defaultvalue import DEFAULT_NONE, DEFAULT_20 +from telegram._utils.types import JSONDict, FileInput, ODVInput, DVInput if TYPE_CHECKING: from telegram import ( diff --git a/telegram/messageautodeletetimerchanged.py b/telegram/_messageautodeletetimerchanged.py similarity index 100% rename from telegram/messageautodeletetimerchanged.py rename to telegram/_messageautodeletetimerchanged.py diff --git a/telegram/messageentity.py b/telegram/_messageentity.py similarity index 99% rename from telegram/messageentity.py rename to telegram/_messageentity.py index 5948de2ee15..19555f05e4d 100644 --- a/telegram/messageentity.py +++ b/telegram/_messageentity.py @@ -21,7 +21,7 @@ from typing import TYPE_CHECKING, Any, List, Optional, ClassVar from telegram import TelegramObject, User, constants -from telegram.utils.types import JSONDict +from telegram._utils.types import JSONDict if TYPE_CHECKING: from telegram import Bot diff --git a/telegram/messageid.py b/telegram/_messageid.py similarity index 100% rename from telegram/messageid.py rename to telegram/_messageid.py diff --git a/telegram/parsemode.py b/telegram/_parsemode.py similarity index 100% rename from telegram/parsemode.py rename to telegram/_parsemode.py diff --git a/telegram/passport/__init__.py b/telegram/_passport/__init__.py similarity index 100% rename from telegram/passport/__init__.py rename to telegram/_passport/__init__.py diff --git a/telegram/passport/credentials.py b/telegram/_passport/credentials.py similarity index 99% rename from telegram/passport/credentials.py rename to telegram/_passport/credentials.py index 77b69335083..9a53175b2f1 100644 --- a/telegram/passport/credentials.py +++ b/telegram/_passport/credentials.py @@ -43,7 +43,7 @@ from telegram import TelegramObject from telegram.error import PassportDecryptionError -from telegram.utils.types import JSONDict +from telegram._utils.types import JSONDict if TYPE_CHECKING: from telegram import Bot diff --git a/telegram/passport/data.py b/telegram/_passport/data.py similarity index 100% rename from telegram/passport/data.py rename to telegram/_passport/data.py diff --git a/telegram/passport/encryptedpassportelement.py b/telegram/_passport/encryptedpassportelement.py similarity index 99% rename from telegram/passport/encryptedpassportelement.py rename to telegram/_passport/encryptedpassportelement.py index 97cbc669c17..e096b3254bc 100644 --- a/telegram/passport/encryptedpassportelement.py +++ b/telegram/_passport/encryptedpassportelement.py @@ -27,8 +27,8 @@ ResidentialAddress, TelegramObject, ) -from telegram.passport.credentials import decrypt_json -from telegram.utils.types import JSONDict +from telegram._passport.credentials import decrypt_json +from telegram._utils.types import JSONDict if TYPE_CHECKING: from telegram import Bot, Credentials diff --git a/telegram/passport/passportdata.py b/telegram/_passport/passportdata.py similarity index 99% rename from telegram/passport/passportdata.py rename to telegram/_passport/passportdata.py index 93ba74f1953..65167331080 100644 --- a/telegram/passport/passportdata.py +++ b/telegram/_passport/passportdata.py @@ -21,7 +21,7 @@ from typing import TYPE_CHECKING, Any, List, Optional from telegram import EncryptedCredentials, EncryptedPassportElement, TelegramObject -from telegram.utils.types import JSONDict +from telegram._utils.types import JSONDict if TYPE_CHECKING: from telegram import Bot, Credentials diff --git a/telegram/passport/passportelementerrors.py b/telegram/_passport/passportelementerrors.py similarity index 100% rename from telegram/passport/passportelementerrors.py rename to telegram/_passport/passportelementerrors.py diff --git a/telegram/passport/passportfile.py b/telegram/_passport/passportfile.py similarity index 98% rename from telegram/passport/passportfile.py rename to telegram/_passport/passportfile.py index df43d85478f..b63dc3874c0 100644 --- a/telegram/passport/passportfile.py +++ b/telegram/_passport/passportfile.py @@ -21,8 +21,8 @@ from typing import TYPE_CHECKING, Any, List, Optional from telegram import TelegramObject -from telegram.utils.defaultvalue import DEFAULT_NONE -from telegram.utils.types import JSONDict, ODVInput +from telegram._utils.defaultvalue import DEFAULT_NONE +from telegram._utils.types import JSONDict, ODVInput if TYPE_CHECKING: from telegram import Bot, File, FileCredentials diff --git a/telegram/payment/__init__.py b/telegram/_payment/__init__.py similarity index 100% rename from telegram/payment/__init__.py rename to telegram/_payment/__init__.py diff --git a/telegram/payment/invoice.py b/telegram/_payment/invoice.py similarity index 100% rename from telegram/payment/invoice.py rename to telegram/_payment/invoice.py diff --git a/telegram/payment/labeledprice.py b/telegram/_payment/labeledprice.py similarity index 100% rename from telegram/payment/labeledprice.py rename to telegram/_payment/labeledprice.py diff --git a/telegram/payment/orderinfo.py b/telegram/_payment/orderinfo.py similarity index 98% rename from telegram/payment/orderinfo.py rename to telegram/_payment/orderinfo.py index 8a78482044f..bfb9ea6ec92 100644 --- a/telegram/payment/orderinfo.py +++ b/telegram/_payment/orderinfo.py @@ -21,7 +21,7 @@ from typing import TYPE_CHECKING, Any, Optional from telegram import ShippingAddress, TelegramObject -from telegram.utils.types import JSONDict +from telegram._utils.types import JSONDict if TYPE_CHECKING: from telegram import Bot diff --git a/telegram/payment/precheckoutquery.py b/telegram/_payment/precheckoutquery.py similarity index 97% rename from telegram/payment/precheckoutquery.py rename to telegram/_payment/precheckoutquery.py index 7f73b7f2bc2..7b6e45d7d4a 100644 --- a/telegram/payment/precheckoutquery.py +++ b/telegram/_payment/precheckoutquery.py @@ -21,8 +21,8 @@ from typing import TYPE_CHECKING, Any, Optional from telegram import OrderInfo, TelegramObject, User -from telegram.utils.defaultvalue import DEFAULT_NONE -from telegram.utils.types import JSONDict, ODVInput +from telegram._utils.defaultvalue import DEFAULT_NONE +from telegram._utils.types import JSONDict, ODVInput if TYPE_CHECKING: from telegram import Bot diff --git a/telegram/payment/shippingaddress.py b/telegram/_payment/shippingaddress.py similarity index 100% rename from telegram/payment/shippingaddress.py rename to telegram/_payment/shippingaddress.py diff --git a/telegram/payment/shippingoption.py b/telegram/_payment/shippingoption.py similarity index 98% rename from telegram/payment/shippingoption.py rename to telegram/_payment/shippingoption.py index 6b548d1d0de..74fb5405b9a 100644 --- a/telegram/payment/shippingoption.py +++ b/telegram/_payment/shippingoption.py @@ -21,7 +21,7 @@ from typing import TYPE_CHECKING, Any, List from telegram import TelegramObject -from telegram.utils.types import JSONDict +from telegram._utils.types import JSONDict if TYPE_CHECKING: from telegram import LabeledPrice # noqa diff --git a/telegram/payment/shippingquery.py b/telegram/_payment/shippingquery.py similarity index 97% rename from telegram/payment/shippingquery.py rename to telegram/_payment/shippingquery.py index 69a981d43f7..b936bd6290a 100644 --- a/telegram/payment/shippingquery.py +++ b/telegram/_payment/shippingquery.py @@ -21,8 +21,8 @@ from typing import TYPE_CHECKING, Any, Optional, List from telegram import ShippingAddress, TelegramObject, User, ShippingOption -from telegram.utils.defaultvalue import DEFAULT_NONE -from telegram.utils.types import JSONDict, ODVInput +from telegram._utils.defaultvalue import DEFAULT_NONE +from telegram._utils.types import JSONDict, ODVInput if TYPE_CHECKING: from telegram import Bot diff --git a/telegram/payment/successfulpayment.py b/telegram/_payment/successfulpayment.py similarity index 99% rename from telegram/payment/successfulpayment.py rename to telegram/_payment/successfulpayment.py index 696287181af..189eceb3f2a 100644 --- a/telegram/payment/successfulpayment.py +++ b/telegram/_payment/successfulpayment.py @@ -21,7 +21,7 @@ from typing import TYPE_CHECKING, Any, Optional from telegram import OrderInfo, TelegramObject -from telegram.utils.types import JSONDict +from telegram._utils.types import JSONDict if TYPE_CHECKING: from telegram import Bot diff --git a/telegram/poll.py b/telegram/_poll.py similarity index 99% rename from telegram/poll.py rename to telegram/_poll.py index 7386339aae4..29a07625f5f 100644 --- a/telegram/poll.py +++ b/telegram/_poll.py @@ -24,8 +24,8 @@ from typing import TYPE_CHECKING, Any, Dict, List, Optional, ClassVar from telegram import MessageEntity, TelegramObject, User, constants -from telegram.utils.datetime import from_timestamp, to_timestamp -from telegram.utils.types import JSONDict +from telegram._utils.datetime import from_timestamp, to_timestamp +from telegram._utils.types import JSONDict if TYPE_CHECKING: from telegram import Bot diff --git a/telegram/proximityalerttriggered.py b/telegram/_proximityalerttriggered.py similarity index 98% rename from telegram/proximityalerttriggered.py rename to telegram/_proximityalerttriggered.py index 98bb41b51d7..d2d88f4df41 100644 --- a/telegram/proximityalerttriggered.py +++ b/telegram/_proximityalerttriggered.py @@ -20,7 +20,7 @@ from typing import Any, Optional, TYPE_CHECKING from telegram import TelegramObject, User -from telegram.utils.types import JSONDict +from telegram._utils.types import JSONDict if TYPE_CHECKING: from telegram import Bot diff --git a/telegram/replykeyboardmarkup.py b/telegram/_replykeyboardmarkup.py similarity index 99% rename from telegram/replykeyboardmarkup.py rename to telegram/_replykeyboardmarkup.py index 7b59dc0dbc4..36a81fe1c21 100644 --- a/telegram/replykeyboardmarkup.py +++ b/telegram/_replykeyboardmarkup.py @@ -21,7 +21,7 @@ from typing import Any, List, Union, Sequence from telegram import KeyboardButton, ReplyMarkup -from telegram.utils.types import JSONDict +from telegram._utils.types import JSONDict class ReplyKeyboardMarkup(ReplyMarkup): diff --git a/telegram/replykeyboardremove.py b/telegram/_replykeyboardremove.py similarity index 100% rename from telegram/replykeyboardremove.py rename to telegram/_replykeyboardremove.py diff --git a/telegram/replymarkup.py b/telegram/_replymarkup.py similarity index 100% rename from telegram/replymarkup.py rename to telegram/_replymarkup.py diff --git a/telegram/telegramobject.py b/telegram/_telegramobject.py similarity index 98% rename from telegram/telegramobject.py rename to telegram/_telegramobject.py index 264a721bc25..44b810b5fff 100644 --- a/telegram/telegramobject.py +++ b/telegram/_telegramobject.py @@ -24,8 +24,8 @@ from typing import TYPE_CHECKING, List, Optional, Type, TypeVar, Tuple -from telegram.utils.types import JSONDict -from telegram.utils.warnings import warn +from telegram._utils.types import JSONDict +from telegram._utils.warnings import warn if TYPE_CHECKING: from telegram import Bot diff --git a/telegram/update.py b/telegram/_update.py similarity index 99% rename from telegram/update.py rename to telegram/_update.py index b8acfe9bdec..fc16c2a830b 100644 --- a/telegram/update.py +++ b/telegram/_update.py @@ -26,14 +26,15 @@ InlineQuery, Message, Poll, + PollAnswer, PreCheckoutQuery, ShippingQuery, TelegramObject, ChatMemberUpdated, constants, ) -from telegram.poll import PollAnswer -from telegram.utils.types import JSONDict + +from telegram._utils.types import JSONDict if TYPE_CHECKING: from telegram import Bot, Chat, User # noqa diff --git a/telegram/user.py b/telegram/_user.py similarity index 99% rename from telegram/user.py rename to telegram/_user.py index 150fa5a619e..1363a2b9bf6 100644 --- a/telegram/user.py +++ b/telegram/_user.py @@ -26,8 +26,8 @@ mention_markdown as helpers_mention_markdown, mention_html as helpers_mention_html, ) -from telegram.utils.defaultvalue import DEFAULT_NONE, DEFAULT_20 -from telegram.utils.types import JSONDict, FileInput, ODVInput, DVInput +from telegram._utils.defaultvalue import DEFAULT_NONE, DEFAULT_20 +from telegram._utils.types import JSONDict, FileInput, ODVInput, DVInput if TYPE_CHECKING: from telegram import ( diff --git a/telegram/userprofilephotos.py b/telegram/_userprofilephotos.py similarity index 98% rename from telegram/userprofilephotos.py rename to telegram/_userprofilephotos.py index 95b44da1ce0..fbf814d63ed 100644 --- a/telegram/userprofilephotos.py +++ b/telegram/_userprofilephotos.py @@ -21,7 +21,7 @@ from typing import TYPE_CHECKING, Any, List, Optional from telegram import PhotoSize, TelegramObject -from telegram.utils.types import JSONDict +from telegram._utils.types import JSONDict if TYPE_CHECKING: from telegram import Bot diff --git a/telegram/utils/__init__.py b/telegram/_utils/__init__.py similarity index 100% rename from telegram/utils/__init__.py rename to telegram/_utils/__init__.py diff --git a/telegram/utils/datetime.py b/telegram/_utils/datetime.py similarity index 99% rename from telegram/utils/datetime.py rename to telegram/_utils/datetime.py index 8d96d7b72c4..1b0b420d1af 100644 --- a/telegram/utils/datetime.py +++ b/telegram/_utils/datetime.py @@ -20,7 +20,7 @@ .. versionchanged:: 14.0 Previously, the contents of this module were available through the (no longer existing) - module ``telegram.utils.helpers``. + module ``telegram._utils.helpers``. Warning: Contents of this module are intended to be used internally by the library and *not* by the diff --git a/telegram/utils/defaultvalue.py b/telegram/_utils/defaultvalue.py similarity index 99% rename from telegram/utils/defaultvalue.py rename to telegram/_utils/defaultvalue.py index f602f6a1df2..2c4258d729d 100644 --- a/telegram/utils/defaultvalue.py +++ b/telegram/_utils/defaultvalue.py @@ -20,7 +20,7 @@ .. versionchanged:: 14.0 Previously, the contents of this module were available through the (no longer existing) - module ``telegram.utils.helpers``. + module ``telegram._utils.helpers``. Warning: Contents of this module are intended to be used internally by the library and *not* by the diff --git a/telegram/utils/files.py b/telegram/_utils/files.py similarity index 98% rename from telegram/utils/files.py rename to telegram/_utils/files.py index c6972c087b5..53dcebd26f0 100644 --- a/telegram/utils/files.py +++ b/telegram/_utils/files.py @@ -20,7 +20,7 @@ .. versionchanged:: 14.0 Previously, the contents of this module were available through the (no longer existing) - module ``telegram.utils.helpers``. + module ``telegram._utils.helpers``. Warning: Contents of this module are intended to be used internally by the library and *not* by the @@ -31,7 +31,7 @@ from pathlib import Path from typing import Optional, Union, Type, Any, cast, IO, TYPE_CHECKING -from telegram.utils.types import FileInput +from telegram._utils.types import FileInput if TYPE_CHECKING: from telegram import TelegramObject, InputFile diff --git a/telegram/utils/types.py b/telegram/_utils/types.py similarity index 96% rename from telegram/utils/types.py rename to telegram/_utils/types.py index d943b78a050..02a38ce0654 100644 --- a/telegram/utils/types.py +++ b/telegram/_utils/types.py @@ -38,7 +38,7 @@ if TYPE_CHECKING: from telegram import InputFile # noqa: F401 - from telegram.utils.defaultvalue import DefaultValue # noqa: F401 + from telegram._utils.defaultvalue import DefaultValue # noqa: F401 FileLike = Union[IO, 'InputFile'] """Either an open file handler or a :class:`telegram.InputFile`.""" diff --git a/telegram/utils/warnings.py b/telegram/_utils/warnings.py similarity index 100% rename from telegram/utils/warnings.py rename to telegram/_utils/warnings.py diff --git a/telegram/version.py b/telegram/_version.py similarity index 100% rename from telegram/version.py rename to telegram/_version.py diff --git a/telegram/voicechat.py b/telegram/_voicechat.py similarity index 97% rename from telegram/voicechat.py rename to telegram/_voicechat.py index 8e95ec4388a..2f612bd8e84 100644 --- a/telegram/voicechat.py +++ b/telegram/_voicechat.py @@ -23,8 +23,8 @@ from typing import TYPE_CHECKING, Optional, List from telegram import TelegramObject, User -from telegram.utils.datetime import from_timestamp, to_timestamp -from telegram.utils.types import JSONDict +from telegram._utils.datetime import from_timestamp, to_timestamp +from telegram._utils.types import JSONDict if TYPE_CHECKING: from telegram import Bot diff --git a/telegram/webhookinfo.py b/telegram/_webhookinfo.py similarity index 100% rename from telegram/webhookinfo.py rename to telegram/_webhookinfo.py diff --git a/telegram/ext/__init__.py b/telegram/ext/__init__.py index e35b6ca7756..ccee7c7873c 100644 --- a/telegram/ext/__init__.py +++ b/telegram/ext/__init__.py @@ -18,35 +18,34 @@ # along with this program. If not, see [http://www.gnu.org/licenses/]. """Extensions over the Telegram Bot API to facilitate bot making""" -from .extbot import ExtBot -from .basepersistence import BasePersistence, PersistenceInput -from .picklepersistence import PicklePersistence -from .dictpersistence import DictPersistence -from .handler import Handler -from .callbackcontext import CallbackContext -from .contexttypes import ContextTypes -from .dispatcher import Dispatcher, DispatcherHandlerStop - -from .jobqueue import JobQueue, Job -from .updater import Updater -from .callbackqueryhandler import CallbackQueryHandler -from .choseninlineresulthandler import ChosenInlineResultHandler -from .inlinequeryhandler import InlineQueryHandler +from ._extbot import ExtBot +from ._basepersistence import BasePersistence, PersistenceInput +from ._picklepersistence import PicklePersistence +from ._dictpersistence import DictPersistence +from ._handler import Handler +from ._callbackcontext import CallbackContext +from ._contexttypes import ContextTypes +from ._dispatcher import Dispatcher, DispatcherHandlerStop +from ._jobqueue import JobQueue, Job +from ._updater import Updater +from ._callbackqueryhandler import CallbackQueryHandler +from ._choseninlineresulthandler import ChosenInlineResultHandler +from ._inlinequeryhandler import InlineQueryHandler from .filters import BaseFilter, MessageFilter, UpdateFilter, Filters -from .messagehandler import MessageHandler -from .commandhandler import CommandHandler, PrefixHandler -from .stringcommandhandler import StringCommandHandler -from .stringregexhandler import StringRegexHandler -from .typehandler import TypeHandler -from .conversationhandler import ConversationHandler -from .precheckoutqueryhandler import PreCheckoutQueryHandler -from .shippingqueryhandler import ShippingQueryHandler -from .pollanswerhandler import PollAnswerHandler -from .pollhandler import PollHandler -from .chatmemberhandler import ChatMemberHandler -from .defaults import Defaults -from .callbackdatacache import CallbackDataCache, InvalidCallbackData -from .builders import DispatcherBuilder, UpdaterBuilder +from ._messagehandler import MessageHandler +from ._commandhandler import CommandHandler, PrefixHandler +from ._stringcommandhandler import StringCommandHandler +from ._stringregexhandler import StringRegexHandler +from ._typehandler import TypeHandler +from ._conversationhandler import ConversationHandler +from ._precheckoutqueryhandler import PreCheckoutQueryHandler +from ._shippingqueryhandler import ShippingQueryHandler +from ._pollanswerhandler import PollAnswerHandler +from ._pollhandler import PollHandler +from ._chatmemberhandler import ChatMemberHandler +from ._defaults import Defaults +from ._callbackdatacache import CallbackDataCache, InvalidCallbackData +from ._builders import DispatcherBuilder, UpdaterBuilder __all__ = ( 'BaseFilter', diff --git a/telegram/ext/basepersistence.py b/telegram/ext/_basepersistence.py similarity index 88% rename from telegram/ext/basepersistence.py rename to telegram/ext/_basepersistence.py index 8d907d45b16..97ce2d2d531 100644 --- a/telegram/ext/basepersistence.py +++ b/telegram/ext/_basepersistence.py @@ -22,11 +22,11 @@ from typing import Dict, Optional, Tuple, cast, ClassVar, Generic, DefaultDict, NamedTuple from telegram import Bot -import telegram.ext.extbot +from telegram.ext import ExtBot -from telegram.ext.utils.types import UD, CD, BD, ConversationDict, CDCData from telegram.warnings import PTBRuntimeWarning -from telegram.utils.warnings import warn +from telegram._utils.warnings import warn +from telegram.ext._utils.types import UD, CD, BD, ConversationDict, CDCData class PersistenceInput(NamedTuple): @@ -185,7 +185,7 @@ def set_bot(self, bot: Bot) -> None: Args: bot (:class:`telegram.Bot`): The bot. """ - if self.store_data.callback_data and not isinstance(bot, telegram.ext.extbot.ExtBot): + if self.store_data.callback_data and not isinstance(bot, ExtBot): raise TypeError('callback_data can only be stored when using telegram.ext.ExtBot.') self.bot = bot @@ -401,30 +401,48 @@ def _insert_bot(self, obj: object, memo: Dict[int, object]) -> object: def get_user_data(self) -> DefaultDict[int, UD]: """Will be called by :class:`telegram.ext.Dispatcher` upon creation with a persistence object. It should return the ``user_data`` if stored, or an empty - :obj:`defaultdict(telegram.ext.utils.types.UD)` with integer keys. + :obj:`defaultdict`. In the latter case, the :obj:`defaultdict` should produce values + corresponding to one of the following: + + * :obj:`dict` + * The type from :attr:`telegram.ext.ContextTypes.user_data` + if :class:`telegram.ext.ContextTypes` are used. Returns: - DefaultDict[:obj:`int`, :class:`telegram.ext.utils.types.UD`]: The restored user data. + DefaultDict[:obj:`int`, :obj:`dict` | :attr:`telegram.ext.ContextTypes.user_data`]: + The restored user data. """ @abstractmethod def get_chat_data(self) -> DefaultDict[int, CD]: """Will be called by :class:`telegram.ext.Dispatcher` upon creation with a persistence object. It should return the ``chat_data`` if stored, or an empty - :obj:`defaultdict(telegram.ext.utils.types.CD)` with integer keys. + :obj:`defaultdict`. In the latter case, the :obj:`defaultdict` should produce values + corresponding to one of the following: + + * :obj:`dict` + * The type from :attr:`telegram.ext.ContextTypes.chat_data` + if :class:`telegram.ext.ContextTypes` are used. Returns: - DefaultDict[:obj:`int`, :class:`telegram.ext.utils.types.CD`]: The restored chat data. + DefaultDict[:obj:`int`, :obj:`dict` | :attr:`telegram.ext.ContextTypes.chat_data`]: + The restored chat data. """ @abstractmethod def get_bot_data(self) -> BD: """Will be called by :class:`telegram.ext.Dispatcher` upon creation with a persistence object. It should return the ``bot_data`` if stored, or an empty - :class:`telegram.ext.utils.types.BD`. + :obj:`defaultdict`. In the latter case, the :obj:`defaultdict` should produce values + corresponding to one of the following: + + * :obj:`dict` + * The type from :attr:`telegram.ext.ContextTypes.bot_data` + if :class:`telegram.ext.ContextTypes` are used. Returns: - :class:`telegram.ext.utils.types.BD`: The restored bot data. + DefaultDict[:obj:`int`, :obj:`dict` | :attr:`telegram.ext.ContextTypes.bot_data`]: + The restored bot data. """ @abstractmethod @@ -438,8 +456,9 @@ def get_callback_data(self) -> Optional[CDCData]: Changed this method into an ``@abstractmethod``. Returns: - Optional[:class:`telegram.ext.utils.types.CDCData`]: The restored meta data or - :obj:`None`, if no data was stored. + Optional[Tuple[List[Tuple[:obj:`str`, :obj:`float`, \ + Dict[:obj:`str`, :obj:`Any`]]], Dict[:obj:`str`, :obj:`str`]]: + The restored meta data or :obj:`None`, if no data was stored. """ @abstractmethod @@ -466,7 +485,7 @@ def update_conversation( Args: name (:obj:`str`): The handler's name. key (:obj:`tuple`): The key the state is changed for. - new_state (:obj:`tuple` | :obj:`any`): The new state for the given key. + new_state (:obj:`tuple` | :obj:`Any`): The new state for the given key. """ @abstractmethod @@ -476,8 +495,8 @@ def update_user_data(self, user_id: int, data: UD) -> None: Args: user_id (:obj:`int`): The user the data might have been changed for. - data (:class:`telegram.ext.utils.types.UD`): The - :attr:`telegram.ext.Dispatcher.user_data` ``[user_id]``. + data (:obj:`dict` | :attr:`telegram.ext.ContextTypes.user_data`): + The :attr:`telegram.ext.Dispatcher.user_data` ``[user_id]``. """ @abstractmethod @@ -487,8 +506,8 @@ def update_chat_data(self, chat_id: int, data: CD) -> None: Args: chat_id (:obj:`int`): The chat the data might have been changed for. - data (:class:`telegram.ext.utils.types.CD`): The - :attr:`telegram.ext.Dispatcher.chat_data` ``[chat_id]``. + data (:obj:`dict` | :attr:`telegram.ext.ContextTypes.chat_data`): + The :attr:`telegram.ext.Dispatcher.chat_data` ``[chat_id]``. """ @abstractmethod @@ -497,8 +516,8 @@ def update_bot_data(self, data: BD) -> None: handled an update. Args: - data (:class:`telegram.ext.utils.types.BD`): The - :attr:`telegram.ext.Dispatcher.bot_data`. + data (:obj:`dict` | :attr:`telegram.ext.ContextTypes.bot_data`): + The :attr:`telegram.ext.Dispatcher.bot_data`. """ @abstractmethod @@ -514,7 +533,8 @@ def refresh_user_data(self, user_id: int, user_data: UD) -> None: Args: user_id (:obj:`int`): The user ID this :attr:`user_data` is associated with. - user_data (:class:`telegram.ext.utils.types.UD`): The ``user_data`` of a single user. + user_data (:obj:`dict` | :attr:`telegram.ext.ContextTypes.user_data`): + The ``user_data`` of a single user. """ @abstractmethod @@ -530,7 +550,8 @@ def refresh_chat_data(self, chat_id: int, chat_data: CD) -> None: Args: chat_id (:obj:`int`): The chat ID this :attr:`chat_data` is associated with. - chat_data (:class:`telegram.ext.utils.types.CD`): The ``chat_data`` of a single chat. + chat_data (:obj:`dict` | :attr:`telegram.ext.ContextTypes.chat_data`): + The ``chat_data`` of a single chat. """ @abstractmethod @@ -545,7 +566,8 @@ def refresh_bot_data(self, bot_data: BD) -> None: Changed this method into an ``@abstractmethod``. Args: - bot_data (:class:`telegram.ext.utils.types.BD`): The ``bot_data``. + bot_data (:obj:`dict` | :attr:`telegram.ext.ContextTypes.bot_data`): + The ``bot_data``. """ @abstractmethod @@ -559,8 +581,9 @@ def update_callback_data(self, data: CDCData) -> None: Changed this method into an ``@abstractmethod``. Args: - data (:class:`telegram.ext.utils.types.CDCData`): The relevant data to restore - :class:`telegram.ext.CallbackDataCache`. + data (Optional[Tuple[List[Tuple[:obj:`str`, :obj:`float`, \ + Dict[:obj:`str`, :obj:`Any`]]], Dict[:obj:`str`, :obj:`str`]]): + The relevant data to restore :class:`telegram.ext.CallbackDataCache`. """ @abstractmethod diff --git a/telegram/ext/builders.py b/telegram/ext/_builders.py similarity index 99% rename from telegram/ext/builders.py rename to telegram/ext/_builders.py index e910854c236..082605cf61d 100644 --- a/telegram/ext/builders.py +++ b/telegram/ext/_builders.py @@ -37,12 +37,12 @@ ) from telegram import Bot -from telegram.ext import Dispatcher, JobQueue, Updater, ExtBot, ContextTypes, CallbackContext -from telegram.ext.utils.types import CCT, UD, CD, BD, BT, JQ, PT -from telegram.utils.defaultvalue import DEFAULT_NONE, DefaultValue, DEFAULT_FALSE from telegram.request import Request -from telegram.utils.types import ODVInput, DVInput -from telegram.utils.warnings import warn +from telegram._utils.types import ODVInput, DVInput +from telegram._utils.warnings import warn +from telegram._utils.defaultvalue import DEFAULT_NONE, DefaultValue, DEFAULT_FALSE +from telegram.ext import Dispatcher, JobQueue, Updater, ExtBot, ContextTypes, CallbackContext +from telegram.ext._utils.types import CCT, UD, CD, BD, BT, JQ, PT if TYPE_CHECKING: from telegram.ext import ( diff --git a/telegram/ext/callbackcontext.py b/telegram/ext/_callbackcontext.py similarity index 99% rename from telegram/ext/callbackcontext.py rename to telegram/ext/_callbackcontext.py index f1196d21766..e62f1c890c9 100644 --- a/telegram/ext/callbackcontext.py +++ b/telegram/ext/_callbackcontext.py @@ -34,11 +34,11 @@ from telegram import Update, CallbackQuery from telegram.ext import ExtBot -from telegram.ext.utils.types import UD, CD, BD, BT, JQ, PT # pylint: disable=unused-import +from telegram.ext._utils.types import UD, CD, BD, BT, JQ, PT # pylint: disable=unused-import if TYPE_CHECKING: from telegram.ext import Dispatcher, Job, JobQueue - from telegram.ext.utils.types import CCT + from telegram.ext._utils.types import CCT class CallbackContext(Generic[BT, UD, CD, BD]): diff --git a/telegram/ext/callbackdatacache.py b/telegram/ext/_callbackdatacache.py similarity index 96% rename from telegram/ext/callbackdatacache.py rename to telegram/ext/_callbackdatacache.py index 3429409f664..447a7a26b8e 100644 --- a/telegram/ext/callbackdatacache.py +++ b/telegram/ext/_callbackdatacache.py @@ -53,8 +53,8 @@ User, ) from telegram.error import TelegramError -from telegram.utils.datetime import to_float_timestamp -from telegram.ext.utils.types import CDCData +from telegram._utils.datetime import to_float_timestamp +from telegram.ext._utils.types import CDCData if TYPE_CHECKING: from telegram.ext import ExtBot @@ -126,8 +126,11 @@ class CallbackDataCache: bot (:class:`telegram.ext.ExtBot`): The bot this cache is for. maxsize (:obj:`int`, optional): Maximum number of items in each of the internal mappings. Defaults to 1024. - persistent_data (:obj:`telegram.ext.utils.types.CDCData`, optional): Data to initialize - the cache with, as returned by :meth:`telegram.ext.BasePersistence.get_callback_data`. + + persistent_data (Tuple[List[Tuple[:obj:`str`, :obj:`float`, \ + Dict[:obj:`str`, :obj:`Any`]]], Dict[:obj:`str`, :obj:`str`]], optional): \ + Data to initialize the cache with, as returned by \ + :meth:`telegram.ext.BasePersistence.get_callback_data`. Attributes: bot (:class:`telegram.ext.ExtBot`): The bot this cache is for. @@ -162,7 +165,8 @@ def __init__( @property def persistence_data(self) -> CDCData: - """:obj:`telegram.ext.utils.types.CDCData`: The data that needs to be persisted to allow + """Tuple[List[Tuple[:obj:`str`, :obj:`float`, Dict[:obj:`str`, :obj:`Any`]]], + Dict[:obj:`str`, :obj:`str`]]: The data that needs to be persisted to allow caching callback data across bot reboots. """ # While building a list/dict from the LRUCaches has linear runtime (in the number of diff --git a/telegram/ext/callbackqueryhandler.py b/telegram/ext/_callbackqueryhandler.py similarity index 97% rename from telegram/ext/callbackqueryhandler.py rename to telegram/ext/_callbackqueryhandler.py index f48bd21606c..dafe482e8d9 100644 --- a/telegram/ext/callbackqueryhandler.py +++ b/telegram/ext/_callbackqueryhandler.py @@ -31,10 +31,9 @@ ) from telegram import Update -from telegram.utils.defaultvalue import DefaultValue, DEFAULT_FALSE - -from .handler import Handler -from .utils.types import CCT +from telegram.ext import Handler +from telegram._utils.defaultvalue import DefaultValue, DEFAULT_FALSE +from telegram.ext._utils.types import CCT if TYPE_CHECKING: from telegram.ext import Dispatcher diff --git a/telegram/ext/chatmemberhandler.py b/telegram/ext/_chatmemberhandler.py similarity index 96% rename from telegram/ext/chatmemberhandler.py rename to telegram/ext/_chatmemberhandler.py index 41940f5e639..652c4ce8f28 100644 --- a/telegram/ext/chatmemberhandler.py +++ b/telegram/ext/_chatmemberhandler.py @@ -20,9 +20,9 @@ from typing import ClassVar, TypeVar, Union, Callable from telegram import Update -from telegram.utils.defaultvalue import DefaultValue, DEFAULT_FALSE -from .handler import Handler -from .utils.types import CCT +from telegram.ext import Handler +from telegram._utils.defaultvalue import DefaultValue, DEFAULT_FALSE +from telegram.ext._utils.types import CCT RT = TypeVar('RT') diff --git a/telegram/ext/choseninlineresulthandler.py b/telegram/ext/_choseninlineresulthandler.py similarity index 96% rename from telegram/ext/choseninlineresulthandler.py rename to telegram/ext/_choseninlineresulthandler.py index 266e11bd290..d61bdedfe67 100644 --- a/telegram/ext/choseninlineresulthandler.py +++ b/telegram/ext/_choseninlineresulthandler.py @@ -21,10 +21,9 @@ from typing import Optional, TypeVar, Union, Callable, TYPE_CHECKING, Pattern, Match, cast from telegram import Update - -from telegram.utils.defaultvalue import DefaultValue, DEFAULT_FALSE -from .handler import Handler -from .utils.types import CCT +from telegram.ext import Handler +from telegram._utils.defaultvalue import DefaultValue, DEFAULT_FALSE +from telegram.ext._utils.types import CCT RT = TypeVar('RT') diff --git a/telegram/ext/commandhandler.py b/telegram/ext/_commandhandler.py similarity index 98% rename from telegram/ext/commandhandler.py rename to telegram/ext/_commandhandler.py index e3741974038..908c1572045 100644 --- a/telegram/ext/commandhandler.py +++ b/telegram/ext/_commandhandler.py @@ -21,12 +21,10 @@ from typing import TYPE_CHECKING, Callable, Dict, List, Optional, Tuple, TypeVar, Union from telegram import MessageEntity, Update -from telegram.ext import BaseFilter, Filters -from telegram.utils.types import SLT -from telegram.utils.defaultvalue import DefaultValue, DEFAULT_FALSE - -from .utils.types import CCT -from .handler import Handler +from telegram.ext import BaseFilter, Filters, Handler +from telegram._utils.types import SLT +from telegram._utils.defaultvalue import DefaultValue, DEFAULT_FALSE +from telegram.ext._utils.types import CCT if TYPE_CHECKING: from telegram.ext import Dispatcher diff --git a/telegram/ext/contexttypes.py b/telegram/ext/_contexttypes.py similarity index 97% rename from telegram/ext/contexttypes.py rename to telegram/ext/_contexttypes.py index 6e87972809a..cb6d608faac 100644 --- a/telegram/ext/contexttypes.py +++ b/telegram/ext/_contexttypes.py @@ -20,9 +20,9 @@ """This module contains the auxiliary class ContextTypes.""" from typing import Type, Generic, overload, Dict # pylint: disable=unused-import -from telegram.ext.callbackcontext import CallbackContext -from telegram.ext.extbot import ExtBot # pylint: disable=unused-import -from telegram.ext.utils.types import CCT, UD, CD, BD +from telegram.ext._callbackcontext import CallbackContext +from telegram.ext._extbot import ExtBot # pylint: disable=unused-import +from telegram.ext._utils.types import CCT, UD, CD, BD class ContextTypes(Generic[CCT, UD, CD, BD]): diff --git a/telegram/ext/conversationhandler.py b/telegram/ext/_conversationhandler.py similarity index 99% rename from telegram/ext/conversationhandler.py rename to telegram/ext/_conversationhandler.py index bc95b351529..b0b61588e57 100644 --- a/telegram/ext/conversationhandler.py +++ b/telegram/ext/_conversationhandler.py @@ -46,10 +46,10 @@ Handler, InlineQueryHandler, ) -from telegram.ext.utils.promise import Promise -from telegram.ext.utils.types import ConversationDict -from telegram.ext.utils.types import CCT -from telegram.utils.warnings import warn +from telegram._utils.warnings import warn +from telegram.ext._utils.promise import Promise +from telegram.ext._utils.types import ConversationDict +from telegram.ext._utils.types import CCT if TYPE_CHECKING: from telegram.ext import Dispatcher, Job, JobQueue diff --git a/telegram/ext/defaults.py b/telegram/ext/_defaults.py similarity index 99% rename from telegram/ext/defaults.py rename to telegram/ext/_defaults.py index b772b49326c..ac0fbd5cca0 100644 --- a/telegram/ext/defaults.py +++ b/telegram/ext/_defaults.py @@ -22,8 +22,8 @@ import pytz -from telegram.utils.defaultvalue import DEFAULT_NONE -from telegram.utils.types import ODVInput +from telegram._utils.defaultvalue import DEFAULT_NONE +from telegram._utils.types import ODVInput class Defaults: diff --git a/telegram/ext/dictpersistence.py b/telegram/ext/_dictpersistence.py similarity index 95% rename from telegram/ext/dictpersistence.py rename to telegram/ext/_dictpersistence.py index d521f62685f..a60616cd23b 100644 --- a/telegram/ext/dictpersistence.py +++ b/telegram/ext/_dictpersistence.py @@ -22,8 +22,8 @@ from collections import defaultdict from telegram.ext import BasePersistence, PersistenceInput -from telegram.ext.utils.types import ConversationDict, CDCData -from telegram.utils.types import JSONDict +from telegram._utils.types import JSONDict +from telegram.ext._utils.types import ConversationDict, CDCData try: import ujson as json @@ -203,7 +203,8 @@ def bot_data_json(self) -> str: @property def callback_data(self) -> Optional[CDCData]: - """:class:`telegram.ext.utils.types.CDCData`: The meta data on the stored callback data. + """Tuple[List[Tuple[:obj:`str`, :obj:`float`, Dict[:obj:`str`, :obj:`Any`]]], \ + Dict[:obj:`str`, :obj:`str`]]: The meta data on the stored callback data. .. versionadded:: 13.6 """ @@ -269,8 +270,9 @@ def get_callback_data(self) -> Optional[CDCData]: .. versionadded:: 13.6 Returns: - Optional[:class:`telegram.ext.utils.types.CDCData`]: The restored meta data or - :obj:`None`, if no data was stored. + Tuple[List[Tuple[:obj:`str`, :obj:`float`, Dict[:obj:`str`, :obj:`Any`]]], \ + Dict[:obj:`str`, :obj:`str`]]: The restored meta data or :obj:`None`, \ + if no data was stored. """ if self.callback_data is None: self._callback_data = None @@ -296,7 +298,7 @@ def update_conversation( Args: name (:obj:`str`): The handler's name. key (:obj:`tuple`): The key the state is changed for. - new_state (:obj:`tuple` | :obj:`any`): The new state for the given key. + new_state (:obj:`tuple` | :obj:`Any`): The new state for the given key. """ if not self._conversations: self._conversations = {} @@ -350,7 +352,8 @@ def update_callback_data(self, data: CDCData) -> None: .. versionadded:: 13.6 Args: - data (:class:`telegram.ext.utils.types.CDCData`): The relevant data to restore + data (Tuple[List[Tuple[:obj:`str`, :obj:`float`, Dict[:obj:`str`, :obj:`Any`]]], \ + Dict[:obj:`str`, :obj:`str`]]): The relevant data to restore :class:`telegram.ext.CallbackDataCache`. """ if self._callback_data == data: diff --git a/telegram/ext/dispatcher.py b/telegram/ext/_dispatcher.py similarity index 98% rename from telegram/ext/dispatcher.py rename to telegram/ext/_dispatcher.py index 1edb21dab8b..6ad1ec3dd12 100644 --- a/telegram/ext/dispatcher.py +++ b/telegram/ext/_dispatcher.py @@ -42,13 +42,13 @@ from telegram import Update from telegram.error import TelegramError from telegram.ext import BasePersistence, ContextTypes, ExtBot -from telegram.ext.handler import Handler -from telegram.ext.callbackdatacache import CallbackDataCache -from telegram.utils.defaultvalue import DefaultValue, DEFAULT_FALSE -from telegram.utils.warnings import warn -from telegram.ext.utils.promise import Promise -from telegram.ext.utils.types import CCT, UD, CD, BD, BT, JQ, PT -from .utils.stack import was_called_by +from telegram.ext._handler import Handler +from telegram.ext._callbackdatacache import CallbackDataCache +from telegram._utils.defaultvalue import DefaultValue, DEFAULT_FALSE +from telegram._utils.warnings import warn +from telegram.ext._utils.promise import Promise +from telegram.ext._utils.types import CCT, UD, CD, BD, BT, JQ, PT +from telegram.ext._utils.stack import was_called_by if TYPE_CHECKING: from .jobqueue import Job @@ -180,7 +180,7 @@ def __init__( stack_level: int = 4, ): if not was_called_by( - inspect.currentframe(), Path(__file__).parent.resolve() / 'builders.py' + inspect.currentframe(), Path(__file__).parent.resolve() / '_builders.py' ): warn( '`Dispatcher` instances should be built via the `DispatcherBuilder`.', @@ -549,7 +549,7 @@ def add_handler(self, handler: Handler[UT, CCT], group: int = DEFAULT_GROUP) -> """ # Unfortunately due to circular imports this has to be here # pylint: disable=import-outside-toplevel - from .conversationhandler import ConversationHandler + from telegram.ext._conversationhandler import ConversationHandler if not isinstance(handler, Handler): raise TypeError(f'handler is not an instance of {Handler.__name__}') @@ -713,7 +713,7 @@ def dispatch_error( Args: update (:obj:`object` | :class:`telegram.Update`): The update that caused the error. error (:obj:`Exception`): The error that was raised. - promise (:class:`telegram.utils.Promise`, optional): The promise whose pooled function + promise (:class:`telegram._utils.Promise`, optional): The promise whose pooled function raised the error. job (:class:`telegram.ext.Job`, optional): The job that caused the error. diff --git a/telegram/ext/extbot.py b/telegram/ext/_extbot.py similarity index 98% rename from telegram/ext/extbot.py rename to telegram/ext/_extbot.py index bf60c9865b8..b39242569a7 100644 --- a/telegram/ext/extbot.py +++ b/telegram/ext/_extbot.py @@ -35,8 +35,8 @@ no_type_check, ) -import telegram.bot from telegram import ( + Bot, ReplyMarkup, Message, InlineKeyboardMarkup, @@ -48,20 +48,20 @@ InputMedia, ) -from telegram.ext.callbackdatacache import CallbackDataCache -from telegram.utils.types import JSONDict, ODVInput, DVInput -from telegram.utils.defaultvalue import DEFAULT_NONE, DefaultValue -from telegram.utils.datetime import to_timestamp +from telegram._utils.types import JSONDict, ODVInput, DVInput +from telegram._utils.defaultvalue import DEFAULT_NONE, DefaultValue +from telegram._utils.datetime import to_timestamp +from telegram.ext._callbackdatacache import CallbackDataCache if TYPE_CHECKING: from telegram import InlineQueryResult, MessageEntity from telegram.request import Request - from .defaults import Defaults + from telegram.ext import Defaults HandledTypes = TypeVar('HandledTypes', bound=Union[Message, CallbackQuery, Chat]) -class ExtBot(telegram.bot.Bot): +class ExtBot(Bot): """This object represents a Telegram Bot with convenience extensions. Warning: diff --git a/telegram/ext/handler.py b/telegram/ext/_handler.py similarity index 96% rename from telegram/ext/handler.py rename to telegram/ext/_handler.py index 7e715369e57..6404c443e5c 100644 --- a/telegram/ext/handler.py +++ b/telegram/ext/_handler.py @@ -20,10 +20,10 @@ from abc import ABC, abstractmethod from typing import TYPE_CHECKING, Any, Callable, Optional, TypeVar, Union, Generic -from telegram.ext.utils.promise import Promise -from telegram.utils.defaultvalue import DefaultValue, DEFAULT_FALSE -from telegram.ext.utils.types import CCT -from .extbot import ExtBot +from telegram._utils.defaultvalue import DefaultValue, DEFAULT_FALSE +from telegram.ext._utils.promise import Promise +from telegram.ext._utils.types import CCT +from telegram.ext._extbot import ExtBot if TYPE_CHECKING: from telegram.ext import Dispatcher diff --git a/telegram/ext/inlinequeryhandler.py b/telegram/ext/_inlinequeryhandler.py similarity index 97% rename from telegram/ext/inlinequeryhandler.py rename to telegram/ext/_inlinequeryhandler.py index 2fc155f22bc..78f701d205a 100644 --- a/telegram/ext/inlinequeryhandler.py +++ b/telegram/ext/_inlinequeryhandler.py @@ -31,10 +31,9 @@ ) from telegram import Update -from telegram.utils.defaultvalue import DefaultValue, DEFAULT_FALSE - -from .handler import Handler -from .utils.types import CCT +from telegram.ext import Handler +from telegram._utils.defaultvalue import DefaultValue, DEFAULT_FALSE +from telegram.ext._utils.types import CCT if TYPE_CHECKING: from telegram.ext import Dispatcher diff --git a/telegram/ext/jobqueue.py b/telegram/ext/_jobqueue.py similarity index 99% rename from telegram/ext/jobqueue.py rename to telegram/ext/_jobqueue.py index e4334942219..77b4f9e9f5c 100644 --- a/telegram/ext/jobqueue.py +++ b/telegram/ext/_jobqueue.py @@ -26,8 +26,8 @@ from apscheduler.schedulers.background import BackgroundScheduler from apscheduler.job import Job as APSJob -from telegram.utils.types import JSONDict -from .extbot import ExtBot +from telegram._utils.types import JSONDict +from telegram.ext._extbot import ExtBot if TYPE_CHECKING: from telegram.ext import Dispatcher, CallbackContext diff --git a/telegram/ext/messagehandler.py b/telegram/ext/_messagehandler.py similarity index 96% rename from telegram/ext/messagehandler.py rename to telegram/ext/_messagehandler.py index 75f1484cfde..8f30a1e0339 100644 --- a/telegram/ext/messagehandler.py +++ b/telegram/ext/_messagehandler.py @@ -20,11 +20,10 @@ from typing import TYPE_CHECKING, Callable, Dict, Optional, TypeVar, Union from telegram import Update -from telegram.ext import BaseFilter, Filters -from telegram.utils.defaultvalue import DefaultValue, DEFAULT_FALSE +from telegram.ext import BaseFilter, Filters, Handler +from telegram._utils.defaultvalue import DefaultValue, DEFAULT_FALSE -from .handler import Handler -from .utils.types import CCT +from telegram.ext._utils.types import CCT if TYPE_CHECKING: from telegram.ext import Dispatcher diff --git a/telegram/ext/picklepersistence.py b/telegram/ext/_picklepersistence.py similarity index 92% rename from telegram/ext/picklepersistence.py rename to telegram/ext/_picklepersistence.py index 25211453e68..1328160774d 100644 --- a/telegram/ext/picklepersistence.py +++ b/telegram/ext/_picklepersistence.py @@ -32,8 +32,8 @@ ) from telegram.ext import BasePersistence, PersistenceInput -from .utils.types import UD, CD, BD, ConversationDict, CDCData -from .contexttypes import ContextTypes +from telegram.ext._contexttypes import ContextTypes +from telegram.ext._utils.types import UD, CD, BD, ConversationDict, CDCData class PicklePersistence(BasePersistence[UD, CD, BD]): @@ -198,7 +198,8 @@ def get_user_data(self) -> DefaultDict[int, UD]: """Returns the user_data from the pickle file if it exists or an empty :obj:`defaultdict`. Returns: - DefaultDict[:obj:`int`, :class:`telegram.ext.utils.types.UD`]: The restored user data. + DefaultDict[:obj:`int`, :obj:`dict` | :attr:`telegram.ext.ContextTypes.user_data`]: + The restored user data. """ if self.user_data: pass @@ -217,7 +218,8 @@ def get_chat_data(self) -> DefaultDict[int, CD]: """Returns the chat_data from the pickle file if it exists or an empty :obj:`defaultdict`. Returns: - DefaultDict[:obj:`int`, :class:`telegram.ext.utils.types.CD`]: The restored chat data. + DefaultDict[:obj:`int`, :obj:`dict` | :attr:`telegram.ext.ContextTypes.chat_data`]: + The restored chat data. """ if self.chat_data: pass @@ -234,10 +236,10 @@ def get_chat_data(self) -> DefaultDict[int, CD]: def get_bot_data(self) -> BD: """Returns the bot_data from the pickle file if it exists or an empty object of type - :class:`telegram.ext.utils.types.BD`. + :obj:`dict` | :attr:`telegram.ext.ContextTypes.bot_data`. Returns: - :class:`telegram.ext.utils.types.BD`: The restored bot data. + :obj:`dict` | :attr:`telegram.ext.ContextTypes.bot_data`: The restored bot data. """ if self.bot_data: pass @@ -256,8 +258,9 @@ def get_callback_data(self) -> Optional[CDCData]: .. versionadded:: 13.6 Returns: - Optional[:class:`telegram.ext.utils.types.CDCData`]: The restored meta data or - :obj:`None`, if no data was stored. + Optional[Tuple[List[Tuple[:obj:`str`, :obj:`float`, \ + Dict[:obj:`str`, :obj:`Any`]]], Dict[:obj:`str`, :obj:`str`]]: + The restored meta data or :obj:`None`, if no data was stored. """ if self.callback_data: pass @@ -301,7 +304,7 @@ def update_conversation( Args: name (:obj:`str`): The handler's name. key (:obj:`tuple`): The key the state is changed for. - new_state (:obj:`tuple` | :obj:`any`): The new state for the given key. + new_state (:obj:`tuple` | :obj:`Any`): The new state for the given key. """ if not self.conversations: self.conversations = {} @@ -319,7 +322,7 @@ def update_user_data(self, user_id: int, data: UD) -> None: Args: user_id (:obj:`int`): The user the data might have been changed for. - data (:class:`telegram.ext.utils.types.UD`): The + data (:obj:`dict` | :attr:`telegram.ext.ContextTypes.user_data`): The :attr:`telegram.ext.Dispatcher.user_data` ``[user_id]``. """ if self.user_data is None: @@ -338,7 +341,7 @@ def update_chat_data(self, chat_id: int, data: CD) -> None: Args: chat_id (:obj:`int`): The chat the data might have been changed for. - data (:class:`telegram.ext.utils.types.CD`): The + data (:obj:`dict` | :attr:`telegram.ext.ContextTypes.chat_data`): The :attr:`telegram.ext.Dispatcher.chat_data` ``[chat_id]``. """ if self.chat_data is None: @@ -356,7 +359,7 @@ def update_bot_data(self, data: BD) -> None: """Will update the bot_data and depending on :attr:`on_flush` save the pickle file. Args: - data (:class:`telegram.ext.utils.types.BD`): The + data (:obj:`dict` | :attr:`telegram.ext.ContextTypes.bot_data`): The :attr:`telegram.ext.Dispatcher.bot_data`. """ if self.bot_data == data: @@ -375,8 +378,9 @@ def update_callback_data(self, data: CDCData) -> None: .. versionadded:: 13.6 Args: - data (:class:`telegram.ext.utils.types.CDCData`): The relevant data to restore - :class:`telegram.ext.CallbackDataCache`. + data (Tuple[List[Tuple[:obj:`str`, :obj:`float`, \ + Dict[:obj:`str`, :obj:`Any`]]], Dict[:obj:`str`, :obj:`str`]]): + The relevant data to restore :class:`telegram.ext.CallbackDataCache`. """ if self.callback_data == data: return diff --git a/telegram/ext/pollanswerhandler.py b/telegram/ext/_pollanswerhandler.py similarity index 96% rename from telegram/ext/pollanswerhandler.py rename to telegram/ext/_pollanswerhandler.py index 6bafc1ffe3f..8e47f480595 100644 --- a/telegram/ext/pollanswerhandler.py +++ b/telegram/ext/_pollanswerhandler.py @@ -21,8 +21,8 @@ from telegram import Update -from .handler import Handler -from .utils.types import CCT +from telegram.ext import Handler +from telegram.ext._utils.types import CCT class PollAnswerHandler(Handler[Update, CCT]): diff --git a/telegram/ext/pollhandler.py b/telegram/ext/_pollhandler.py similarity index 96% rename from telegram/ext/pollhandler.py rename to telegram/ext/_pollhandler.py index d23fa1b0af5..5627bf72e27 100644 --- a/telegram/ext/pollhandler.py +++ b/telegram/ext/_pollhandler.py @@ -21,8 +21,8 @@ from telegram import Update -from .handler import Handler -from .utils.types import CCT +from telegram.ext import Handler +from telegram.ext._utils.types import CCT class PollHandler(Handler[Update, CCT]): diff --git a/telegram/ext/precheckoutqueryhandler.py b/telegram/ext/_precheckoutqueryhandler.py similarity index 96% rename from telegram/ext/precheckoutqueryhandler.py rename to telegram/ext/_precheckoutqueryhandler.py index c79e7b44c0b..14792de1829 100644 --- a/telegram/ext/precheckoutqueryhandler.py +++ b/telegram/ext/_precheckoutqueryhandler.py @@ -20,9 +20,8 @@ from telegram import Update - -from .handler import Handler -from .utils.types import CCT +from telegram.ext import Handler +from telegram.ext._utils.types import CCT class PreCheckoutQueryHandler(Handler[Update, CCT]): diff --git a/telegram/ext/shippingqueryhandler.py b/telegram/ext/_shippingqueryhandler.py similarity index 96% rename from telegram/ext/shippingqueryhandler.py rename to telegram/ext/_shippingqueryhandler.py index 17309b2d7e3..41f926f4438 100644 --- a/telegram/ext/shippingqueryhandler.py +++ b/telegram/ext/_shippingqueryhandler.py @@ -20,8 +20,8 @@ from telegram import Update -from .handler import Handler -from .utils.types import CCT +from telegram.ext import Handler +from telegram.ext._utils.types import CCT class ShippingQueryHandler(Handler[Update, CCT]): diff --git a/telegram/ext/stringcommandhandler.py b/telegram/ext/_stringcommandhandler.py similarity index 96% rename from telegram/ext/stringcommandhandler.py rename to telegram/ext/_stringcommandhandler.py index 35ebf56a44a..5d8e76621e6 100644 --- a/telegram/ext/stringcommandhandler.py +++ b/telegram/ext/_stringcommandhandler.py @@ -20,10 +20,9 @@ from typing import TYPE_CHECKING, Callable, List, Optional, TypeVar, Union -from telegram.utils.defaultvalue import DefaultValue, DEFAULT_FALSE - -from .handler import Handler -from .utils.types import CCT +from telegram.ext import Handler +from telegram._utils.defaultvalue import DefaultValue, DEFAULT_FALSE +from telegram.ext._utils.types import CCT if TYPE_CHECKING: from telegram.ext import Dispatcher diff --git a/telegram/ext/stringregexhandler.py b/telegram/ext/_stringregexhandler.py similarity index 96% rename from telegram/ext/stringregexhandler.py rename to telegram/ext/_stringregexhandler.py index a6c5a82f770..f063fc7975d 100644 --- a/telegram/ext/stringregexhandler.py +++ b/telegram/ext/_stringregexhandler.py @@ -21,10 +21,9 @@ import re from typing import TYPE_CHECKING, Callable, Match, Optional, Pattern, TypeVar, Union -from telegram.utils.defaultvalue import DefaultValue, DEFAULT_FALSE - -from .handler import Handler -from .utils.types import CCT +from telegram.ext import Handler +from telegram.ext._utils.types import CCT +from telegram._utils.defaultvalue import DefaultValue, DEFAULT_FALSE if TYPE_CHECKING: from telegram.ext import Dispatcher diff --git a/telegram/ext/typehandler.py b/telegram/ext/_typehandler.py similarity index 95% rename from telegram/ext/typehandler.py rename to telegram/ext/_typehandler.py index d3aa812b68a..63f04b1da7a 100644 --- a/telegram/ext/typehandler.py +++ b/telegram/ext/_typehandler.py @@ -19,10 +19,10 @@ """This module contains the TypeHandler class.""" from typing import Callable, Type, TypeVar, Union -from telegram.utils.defaultvalue import DefaultValue, DEFAULT_FALSE -from .handler import Handler -from .utils.types import CCT +from telegram.ext import Handler +from telegram.ext._utils.types import CCT +from telegram._utils.defaultvalue import DefaultValue, DEFAULT_FALSE RT = TypeVar('RT') UT = TypeVar('UT') diff --git a/telegram/ext/updater.py b/telegram/ext/_updater.py similarity index 99% rename from telegram/ext/updater.py rename to telegram/ext/_updater.py index 5b61059b3ee..c66c5f4c458 100644 --- a/telegram/ext/updater.py +++ b/telegram/ext/_updater.py @@ -40,10 +40,10 @@ from telegram.error import InvalidToken, RetryAfter, TimedOut, Unauthorized, TelegramError from telegram.ext import Dispatcher -from telegram.ext.utils.webhookhandler import WebhookAppClass, WebhookServer -from .utils.stack import was_called_by -from .utils.types import BT -from ..utils.warnings import warn +from telegram.ext._utils.webhookhandler import WebhookAppClass, WebhookServer +from telegram.ext._utils.stack import was_called_by +from telegram.ext._utils.types import BT +from telegram._utils.warnings import warn if TYPE_CHECKING: from .builders import InitUpdaterBuilder @@ -117,7 +117,7 @@ def __init__( exception_event: Event = None, ): if not was_called_by( - inspect.currentframe(), Path(__file__).parent.resolve() / 'builders.py' + inspect.currentframe(), Path(__file__).parent.resolve() / '_builders.py' ): warn( '`Updater` instances should be built via the `UpdaterBuilder`.', diff --git a/telegram/ext/utils/__init__.py b/telegram/ext/_utils/__init__.py similarity index 100% rename from telegram/ext/utils/__init__.py rename to telegram/ext/_utils/__init__.py diff --git a/telegram/ext/utils/promise.py b/telegram/ext/_utils/promise.py similarity index 97% rename from telegram/ext/utils/promise.py rename to telegram/ext/_utils/promise.py index 44b665aa93a..8ed58d8ccdf 100644 --- a/telegram/ext/utils/promise.py +++ b/telegram/ext/_utils/promise.py @@ -22,7 +22,7 @@ from threading import Event from typing import Callable, List, Optional, Tuple, TypeVar, Union -from telegram.utils.types import JSONDict +from telegram._utils.types import JSONDict RT = TypeVar('RT') @@ -124,7 +124,7 @@ def result(self, timeout: float = None) -> Optional[RT]: def add_done_callback(self, callback: Callable) -> None: """ - Callback to be run when :class:`telegram.ext.utils.promise.Promise` becomes done. + Callback to be run when :class:`telegram.ext._utils.promise.Promise` becomes done. Note: Callback won't be called if :attr:`pooled_function` diff --git a/telegram/ext/utils/stack.py b/telegram/ext/_utils/stack.py similarity index 100% rename from telegram/ext/utils/stack.py rename to telegram/ext/_utils/stack.py diff --git a/telegram/ext/utils/types.py b/telegram/ext/_utils/types.py similarity index 94% rename from telegram/ext/utils/types.py rename to telegram/ext/_utils/types.py index 028de433bf9..58d23b9872d 100644 --- a/telegram/ext/utils/types.py +++ b/telegram/ext/_utils/types.py @@ -33,13 +33,14 @@ ConversationDict = Dict[Tuple[int, ...], Optional[object]] -"""Dicts as maintained by the :class:`telegram.ext.ConversationHandler`. +"""Dict[Tuple[:obj:`int`, ...], Optional[:obj:`object`]]: + Dicts as maintained by the :class:`telegram.ext.ConversationHandler`. .. versionadded:: 13.6 """ CDCData = Tuple[List[Tuple[str, float, Dict[str, Any]]], Dict[str, str]] -"""Tuple[List[Tuple[:obj:`str`, :obj:`float`, Dict[:obj:`str`, :obj:`any`]]], \ +"""Tuple[List[Tuple[:obj:`str`, :obj:`float`, Dict[:obj:`str`, :obj:`Any`]]], \ Dict[:obj:`str`, :obj:`str`]]: Data returned by :attr:`telegram.ext.CallbackDataCache.persistence_data`. diff --git a/telegram/ext/utils/webhookhandler.py b/telegram/ext/_utils/webhookhandler.py similarity index 99% rename from telegram/ext/utils/webhookhandler.py rename to telegram/ext/_utils/webhookhandler.py index 8714fc18a63..b293b245865 100644 --- a/telegram/ext/utils/webhookhandler.py +++ b/telegram/ext/_utils/webhookhandler.py @@ -31,7 +31,7 @@ from telegram import Update from telegram.ext import ExtBot -from telegram.utils.types import JSONDict +from telegram._utils.types import JSONDict if TYPE_CHECKING: from telegram import Bot diff --git a/telegram/ext/filters.py b/telegram/ext/filters.py index acd20bd09ac..c1cabdf1787 100644 --- a/telegram/ext/filters.py +++ b/telegram/ext/filters.py @@ -49,7 +49,7 @@ 'XORFilter', ] -from telegram.utils.types import SLT +from telegram._utils.types import SLT DataDict = Dict[str, list] diff --git a/telegram/request.py b/telegram/request.py index b0496751994..f715cfb34e3 100644 --- a/telegram/request.py +++ b/telegram/request.py @@ -73,7 +73,7 @@ TimedOut, Unauthorized, ) -from telegram.utils.types import JSONDict +from telegram._utils.types import JSONDict # pylint: disable=unused-argument diff --git a/tests/conftest.py b/tests/conftest.py index a0064d0559f..1dd50b6de8c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -61,7 +61,7 @@ UpdaterBuilder, ) from telegram.error import BadRequest -from telegram.utils.defaultvalue import DefaultValue, DEFAULT_NONE +from telegram._utils.defaultvalue import DefaultValue, DEFAULT_NONE from telegram.request import Request from tests.bots import get_bot diff --git a/tests/test_bot.py b/tests/test_bot.py index 53d3dec46a9..90f5c15dc62 100644 --- a/tests/test_bot.py +++ b/tests/test_bot.py @@ -56,12 +56,11 @@ InputMedia, ) from telegram.constants import MAX_INLINE_QUERY_RESULTS -from telegram.ext import ExtBot +from telegram.ext import ExtBot, InvalidCallbackData from telegram.error import BadRequest, InvalidToken, NetworkError, RetryAfter, TelegramError -from telegram.ext.callbackdatacache import InvalidCallbackData -from telegram.utils.datetime import from_timestamp, to_timestamp +from telegram._utils.datetime import from_timestamp, to_timestamp from telegram.helpers import escape_markdown -from telegram.utils.defaultvalue import DefaultValue +from telegram._utils.defaultvalue import DefaultValue from tests.conftest import expect_bad_request, check_defaults_handling, GITHUB_ACTION, build_kwargs from tests.bots import FALLBACKS diff --git a/tests/test_builders.py b/tests/test_builders.py index aa6a828e14b..fb7101c5b9d 100644 --- a/tests/test_builders.py +++ b/tests/test_builders.py @@ -30,6 +30,7 @@ from telegram.ext import ( UpdaterBuilder, + DispatcherBuilder, Defaults, JobQueue, PicklePersistence, @@ -37,7 +38,7 @@ Dispatcher, Updater, ) -from telegram.ext.builders import _BOT_CHECKS, _DISPATCHER_CHECKS, DispatcherBuilder, _BaseBuilder +from telegram.ext._builders import _BOT_CHECKS, _DISPATCHER_CHECKS, _BaseBuilder @pytest.fixture( diff --git a/tests/test_callbackdatacache.py b/tests/test_callbackdatacache.py index c93e4166ae5..94e1c4db322 100644 --- a/tests/test_callbackdatacache.py +++ b/tests/test_callbackdatacache.py @@ -25,7 +25,7 @@ import pytz from telegram import InlineKeyboardButton, InlineKeyboardMarkup, CallbackQuery, Message, User -from telegram.ext.callbackdatacache import ( +from telegram.ext._callbackdatacache import ( CallbackDataCache, _KeyboardData, InvalidCallbackData, diff --git a/tests/test_chatinvitelink.py b/tests/test_chatinvitelink.py index 2b84e8ee863..3ef30d1937d 100644 --- a/tests/test_chatinvitelink.py +++ b/tests/test_chatinvitelink.py @@ -21,7 +21,7 @@ import pytest from telegram import User, ChatInviteLink -from telegram.utils.datetime import to_timestamp +from telegram._utils.datetime import to_timestamp @pytest.fixture(scope='class') diff --git a/tests/test_chatmember.py b/tests/test_chatmember.py index 58365706105..3cdf8255014 100644 --- a/tests/test_chatmember.py +++ b/tests/test_chatmember.py @@ -22,7 +22,7 @@ import pytest -from telegram.utils.datetime import to_timestamp +from telegram._utils.datetime import to_timestamp from telegram import ( User, ChatMember, diff --git a/tests/test_chatmemberhandler.py b/tests/test_chatmemberhandler.py index 4f8b1930331..849767eb9fe 100644 --- a/tests/test_chatmemberhandler.py +++ b/tests/test_chatmemberhandler.py @@ -35,7 +35,7 @@ ChatMember, ) from telegram.ext import CallbackContext, JobQueue, ChatMemberHandler -from telegram.utils.datetime import from_timestamp +from telegram._utils.datetime import from_timestamp message = Message(1, None, Chat(1, ''), from_user=User(1, '', False), text='Text') diff --git a/tests/test_chatmemberupdated.py b/tests/test_chatmemberupdated.py index 64d656d1c22..2b1ecacb62e 100644 --- a/tests/test_chatmemberupdated.py +++ b/tests/test_chatmemberupdated.py @@ -30,7 +30,7 @@ ChatMemberUpdated, ChatInviteLink, ) -from telegram.utils.datetime import to_timestamp +from telegram._utils.datetime import to_timestamp @pytest.fixture(scope='class') diff --git a/tests/test_datetime.py b/tests/test_datetime.py index 1d7645069ff..41a8f56822a 100644 --- a/tests/test_datetime.py +++ b/tests/test_datetime.py @@ -24,7 +24,7 @@ import pytest -from telegram.utils import datetime as tg_dtm +from telegram._utils import datetime as tg_dtm from telegram.ext import Defaults diff --git a/tests/test_defaultvalue.py b/tests/test_defaultvalue.py index addcb4ddd62..f93e9894a30 100644 --- a/tests/test_defaultvalue.py +++ b/tests/test_defaultvalue.py @@ -19,7 +19,7 @@ import pytest from telegram import User -from telegram.utils.defaultvalue import DefaultValue +from telegram._utils.defaultvalue import DefaultValue class TestDefaultValue: diff --git a/tests/test_dispatcher.py b/tests/test_dispatcher.py index 458ed0f21f6..b759421be30 100644 --- a/tests/test_dispatcher.py +++ b/tests/test_dispatcher.py @@ -25,20 +25,22 @@ from telegram import Message, User, Chat, Update, Bot, MessageEntity from telegram.ext import ( + CommandHandler, MessageHandler, + JobQueue, Filters, Defaults, - CommandHandler, CallbackContext, - JobQueue, - BasePersistence, ContextTypes, + BasePersistence, + PersistenceInput, + Dispatcher, + DispatcherHandlerStop, DispatcherBuilder, UpdaterBuilder, ) -from telegram.ext import PersistenceInput -from telegram.ext.dispatcher import Dispatcher, DispatcherHandlerStop -from telegram.utils.defaultvalue import DEFAULT_FALSE + +from telegram._utils.defaultvalue import DEFAULT_FALSE from telegram.error import TelegramError from tests.conftest import create_dp from collections import defaultdict diff --git a/tests/test_error.py b/tests/test_error.py index 2ec920c2d32..ba1b2ba350a 100644 --- a/tests/test_error.py +++ b/tests/test_error.py @@ -33,7 +33,7 @@ TelegramError, PassportDecryptionError, ) -from telegram.ext.callbackdatacache import InvalidCallbackData +from telegram.ext import InvalidCallbackData class TestErrors: diff --git a/tests/test_files.py b/tests/test_files.py index ed83ec66de2..0973c88c547 100644 --- a/tests/test_files.py +++ b/tests/test_files.py @@ -20,8 +20,8 @@ import pytest -import telegram.utils.datetime -import telegram.utils.files +import telegram._utils.datetime +import telegram._utils.files from telegram import InputFile, Animation, MessageEntity @@ -40,7 +40,7 @@ class TestFiles: ], ) def test_is_local_file(self, string, expected): - assert telegram.utils.files.is_local_file(string) == expected + assert telegram._utils.files.is_local_file(string) == expected @pytest.mark.parametrize( 'string,expected', @@ -65,19 +65,21 @@ def test_is_local_file(self, string, expected): ], ) def test_parse_file_input_string(self, string, expected): - assert telegram.utils.files.parse_file_input(string) == expected + assert telegram._utils.files.parse_file_input(string) == expected def test_parse_file_input_file_like(self): source_file = Path('tests/data/game.gif') with source_file.open('rb') as file: - parsed = telegram.utils.files.parse_file_input(file) + parsed = telegram._utils.files.parse_file_input(file) assert isinstance(parsed, InputFile) assert not parsed.attach assert parsed.filename == 'game.gif' with source_file.open('rb') as file: - parsed = telegram.utils.files.parse_file_input(file, attach=True, filename='test_file') + parsed = telegram._utils.files.parse_file_input( + file, attach=True, filename='test_file' + ) assert isinstance(parsed, InputFile) assert parsed.attach @@ -85,13 +87,13 @@ def test_parse_file_input_file_like(self): def test_parse_file_input_bytes(self): source_file = Path('tests/data/text_file.txt') - parsed = telegram.utils.files.parse_file_input(source_file.read_bytes()) + parsed = telegram._utils.files.parse_file_input(source_file.read_bytes()) assert isinstance(parsed, InputFile) assert not parsed.attach assert parsed.filename == 'application.octet-stream' - parsed = telegram.utils.files.parse_file_input( + parsed = telegram._utils.files.parse_file_input( source_file.read_bytes(), attach=True, filename='test_file' ) @@ -101,9 +103,9 @@ def test_parse_file_input_bytes(self): def test_parse_file_input_tg_object(self): animation = Animation('file_id', 'unique_id', 1, 1, 1) - assert telegram.utils.files.parse_file_input(animation, Animation) == 'file_id' - assert telegram.utils.files.parse_file_input(animation, MessageEntity) is animation + assert telegram._utils.files.parse_file_input(animation, Animation) == 'file_id' + assert telegram._utils.files.parse_file_input(animation, MessageEntity) is animation @pytest.mark.parametrize('obj', [{1: 2}, [1, 2], (1, 2)]) def test_parse_file_input_other(self, obj): - assert telegram.utils.files.parse_file_input(obj) is obj + assert telegram._utils.files.parse_file_input(obj) is obj diff --git a/tests/test_keyboardbutton.py b/tests/test_keyboardbutton.py index 94b481ec32c..6720d6aebb9 100644 --- a/tests/test_keyboardbutton.py +++ b/tests/test_keyboardbutton.py @@ -18,8 +18,7 @@ # along with this program. If not, see [http://www.gnu.org/licenses/]. import pytest -from telegram import KeyboardButton, InlineKeyboardButton -from telegram.keyboardbuttonpolltype import KeyboardButtonPollType +from telegram import KeyboardButton, InlineKeyboardButton, KeyboardButtonPollType @pytest.fixture(scope='class') diff --git a/tests/test_no_passport.py b/tests/test_no_passport.py index 8345f6ced61..ae4de8acd64 100644 --- a/tests/test_no_passport.py +++ b/tests/test_no_passport.py @@ -37,8 +37,8 @@ import pytest -from telegram import bot -from telegram.passport import credentials +from telegram import _bot as bot +from telegram._passport import credentials as credentials from tests.conftest import env_var_2_bool TEST_NO_PASSPORT = env_var_2_bool(os.getenv('TEST_NO_PASSPORT', False)) diff --git a/tests/test_persistence.py b/tests/test_persistence.py index 09fdacacec2..6927a27c4fa 100644 --- a/tests/test_persistence.py +++ b/tests/test_persistence.py @@ -22,8 +22,7 @@ from pathlib import Path from threading import Lock -from telegram.ext import PersistenceInput, UpdaterBuilder -from telegram.ext.callbackdatacache import CallbackDataCache +from telegram.ext import PersistenceInput, UpdaterBuilder, CallbackDataCache try: import ujson as json diff --git a/tests/test_poll.py b/tests/test_poll.py index c5e21dd9f31..a14cbe1ea89 100644 --- a/tests/test_poll.py +++ b/tests/test_poll.py @@ -21,7 +21,7 @@ from telegram import Poll, PollOption, PollAnswer, User, MessageEntity -from telegram.utils.datetime import to_timestamp +from telegram._utils.datetime import to_timestamp @pytest.fixture(scope="class") diff --git a/tests/test_promise.py b/tests/test_promise.py index 35bbf5575c2..fd68c43ee53 100644 --- a/tests/test_promise.py +++ b/tests/test_promise.py @@ -20,7 +20,7 @@ import pytest from telegram.error import TelegramError -from telegram.ext.utils.promise import Promise +from telegram.ext._utils.promise import Promise class TestPromise: diff --git a/tests/test_stack.py b/tests/test_stack.py index 54d57fa5d7a..035f4058f40 100644 --- a/tests/test_stack.py +++ b/tests/test_stack.py @@ -19,7 +19,7 @@ import inspect from pathlib import Path -from telegram.ext.utils.stack import was_called_by +from telegram.ext._utils.stack import was_called_by class TestStack: diff --git a/tests/test_update.py b/tests/test_update.py index 35a5bf3226a..27f38bdec57 100644 --- a/tests/test_update.py +++ b/tests/test_update.py @@ -31,12 +31,13 @@ ShippingQuery, PreCheckoutQuery, Poll, + PollAnswer, PollOption, ChatMemberUpdated, ChatMemberOwner, ) -from telegram.poll import PollAnswer -from telegram.utils.datetime import from_timestamp + +from telegram._utils.datetime import from_timestamp message = Message(1, None, Chat(1, ''), from_user=User(1, '', False), text='Text') chat_member_updated = ChatMemberUpdated( diff --git a/tests/test_updater.py b/tests/test_updater.py index 2814c5fe275..9490e97c84e 100644 --- a/tests/test_updater.py +++ b/tests/test_updater.py @@ -54,7 +54,7 @@ UpdaterBuilder, DispatcherBuilder, ) -from telegram.ext.utils.webhookhandler import WebhookServer +from telegram.ext._utils.webhookhandler import WebhookServer signalskip = pytest.mark.skipif( sys.platform == 'win32', @@ -415,7 +415,7 @@ def webhook_server_init(*args): monkeypatch.setattr(updater.bot, 'delete_webhook', lambda *args, **kwargs: True) monkeypatch.setattr('telegram.ext.Dispatcher.process_update', lambda _, u: q.put(u)) monkeypatch.setattr( - 'telegram.ext.utils.webhookhandler.WebhookServer.__init__', webhook_server_init + 'telegram.ext._utils.webhookhandler.WebhookServer.__init__', webhook_server_init ) ip = '127.0.0.1' diff --git a/tests/test_voicechat.py b/tests/test_voicechat.py index 300a6d11877..dfae8b747ab 100644 --- a/tests/test_voicechat.py +++ b/tests/test_voicechat.py @@ -26,7 +26,7 @@ User, VoiceChatScheduled, ) -from telegram.utils.datetime import to_timestamp +from telegram._utils.datetime import to_timestamp @pytest.fixture(scope='class') diff --git a/tests/test_warnings.py b/tests/test_warnings.py index a9e7ba18f5f..1d2bec3d4c2 100644 --- a/tests/test_warnings.py +++ b/tests/test_warnings.py @@ -21,7 +21,7 @@ import pytest -from telegram.utils.warnings import warn +from telegram._utils.warnings import warn from telegram.warnings import PTBUserWarning, PTBRuntimeWarning, PTBDeprecationWarning @@ -65,7 +65,7 @@ def make_assertion(cls): def test_warn(self, recwarn): expected_file = ( - pathlib.Path(__file__).parent.parent.resolve() / 'telegram' / 'utils' / 'warnings.py' + pathlib.Path(__file__).parent.parent.resolve() / 'telegram' / '_utils' / 'warnings.py' ) warn('test message')