Move Handler Files to _handlers Subdirectory (#4064)

This commit is contained in:
Lucas Molinari 2024-01-15 16:15:33 -03:00 committed by GitHub
parent ebf7f3be12
commit f452c132fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 55 additions and 50 deletions

View file

@ -76,6 +76,7 @@ The following wonderful people contributed directly or indirectly to this projec
- `Loo Zheng Yuan <https://github.com/loozhengyuan>`_
- `LRezende <https://github.com/lrezende>`_
- `Luca Bellanti <https://github.com/Trifase>`_
- `Lucas Molinari <https://github.com/lucasmolinari>`_
- `macrojames <https://github.com/macrojames>`_
- `Matheus Lemos <https://github.com/mlemosf>`_
- `Michael Dix <https://github.com/Eisberge>`_

View file

@ -63,32 +63,32 @@ from . import filters
from ._aioratelimiter import AIORateLimiter
from ._application import Application, ApplicationHandlerStop
from ._applicationbuilder import ApplicationBuilder
from ._basehandler import BaseHandler
from ._basepersistence import BasePersistence, PersistenceInput
from ._baseratelimiter import BaseRateLimiter
from ._baseupdateprocessor import BaseUpdateProcessor, SimpleUpdateProcessor
from ._callbackcontext import CallbackContext
from ._callbackdatacache import CallbackDataCache, InvalidCallbackData
from ._callbackqueryhandler import CallbackQueryHandler
from ._chatjoinrequesthandler import ChatJoinRequestHandler
from ._chatmemberhandler import ChatMemberHandler
from ._choseninlineresulthandler import ChosenInlineResultHandler
from ._commandhandler import CommandHandler
from ._contexttypes import ContextTypes
from ._conversationhandler import ConversationHandler
from ._defaults import Defaults
from ._dictpersistence import DictPersistence
from ._extbot import ExtBot
from ._inlinequeryhandler import InlineQueryHandler
from ._handlers.basehandler import BaseHandler
from ._handlers.callbackqueryhandler import CallbackQueryHandler
from ._handlers.chatjoinrequesthandler import ChatJoinRequestHandler
from ._handlers.chatmemberhandler import ChatMemberHandler
from ._handlers.choseninlineresulthandler import ChosenInlineResultHandler
from ._handlers.commandhandler import CommandHandler
from ._handlers.conversationhandler import ConversationHandler
from ._handlers.inlinequeryhandler import InlineQueryHandler
from ._handlers.messagehandler import MessageHandler
from ._handlers.pollanswerhandler import PollAnswerHandler
from ._handlers.pollhandler import PollHandler
from ._handlers.precheckoutqueryhandler import PreCheckoutQueryHandler
from ._handlers.prefixhandler import PrefixHandler
from ._handlers.shippingqueryhandler import ShippingQueryHandler
from ._handlers.stringcommandhandler import StringCommandHandler
from ._handlers.stringregexhandler import StringRegexHandler
from ._handlers.typehandler import TypeHandler
from ._jobqueue import Job, JobQueue
from ._messagehandler import MessageHandler
from ._picklepersistence import PicklePersistence
from ._pollanswerhandler import PollAnswerHandler
from ._pollhandler import PollHandler
from ._precheckoutqueryhandler import PreCheckoutQueryHandler
from ._prefixhandler import PrefixHandler
from ._shippingqueryhandler import ShippingQueryHandler
from ._stringcommandhandler import StringCommandHandler
from ._stringregexhandler import StringRegexHandler
from ._typehandler import TypeHandler
from ._updater import Updater

View file

@ -64,10 +64,10 @@ from telegram._utils.repr import build_repr_with_selected_attrs
from telegram._utils.types import SCT, DVType, ODVInput
from telegram._utils.warnings import warn
from telegram.error import TelegramError
from telegram.ext._basehandler import BaseHandler
from telegram.ext._basepersistence import BasePersistence
from telegram.ext._contexttypes import ContextTypes
from telegram.ext._extbot import ExtBot
from telegram.ext._handlers.basehandler import BaseHandler
from telegram.ext._updater import Updater
from telegram.ext._utils.stack import was_called_by
from telegram.ext._utils.trackingdict import TrackingDict
@ -494,7 +494,7 @@ class Application(Generic[BT, CCT, UD, CD, BD, JQ], AsyncContextManager["Applica
# Unfortunately due to circular imports this has to be here
# pylint: disable=import-outside-toplevel
from telegram.ext._conversationhandler import ConversationHandler
from telegram.ext._handlers.conversationhandler import ConversationHandler
# Initialize the persistent conversation handlers with the stored states
for handler in itertools.chain.from_iterable(self.handlers.values()):
@ -1304,7 +1304,7 @@ class Application(Generic[BT, CCT, UD, CD, BD, JQ], AsyncContextManager["Applica
"""
# Unfortunately due to circular imports this has to be here
# pylint: disable=import-outside-toplevel
from telegram.ext._conversationhandler import ConversationHandler
from telegram.ext._handlers.conversationhandler import ConversationHandler
if not isinstance(handler, BaseHandler):
raise TypeError(f"handler is not an instance of {BaseHandler.__name__}")
@ -1650,7 +1650,7 @@ class Application(Generic[BT, CCT, UD, CD, BD, JQ], AsyncContextManager["Applica
# Unfortunately due to circular imports this has to be here
# pylint: disable=import-outside-toplevel
from telegram.ext._conversationhandler import PendingState
from telegram.ext._handlers.conversationhandler import PendingState
for name, (key, new_state) in itertools.chain.from_iterable(
zip(itertools.repeat(name), states_dict.pop_accessed_write_items())

View file

View file

@ -24,7 +24,7 @@ from typing import TYPE_CHECKING, Any, Callable, Match, Optional, Pattern, TypeV
from telegram import Update
from telegram._utils.defaultvalue import DEFAULT_TRUE
from telegram._utils.types import DVType
from telegram.ext._basehandler import BaseHandler
from telegram.ext._handlers.basehandler import BaseHandler
from telegram.ext._utils.types import CCT, HandlerCallback
if TYPE_CHECKING:

View file

@ -23,7 +23,7 @@ from typing import FrozenSet, Optional
from telegram import Update
from telegram._utils.defaultvalue import DEFAULT_TRUE
from telegram._utils.types import RT, SCT, DVType
from telegram.ext._basehandler import BaseHandler
from telegram.ext._handlers.basehandler import BaseHandler
from telegram.ext._utils.types import CCT, HandlerCallback

View file

@ -22,7 +22,7 @@ from typing import Final, Optional, TypeVar
from telegram import Update
from telegram._utils.defaultvalue import DEFAULT_TRUE
from telegram._utils.types import DVType
from telegram.ext._basehandler import BaseHandler
from telegram.ext._handlers.basehandler import BaseHandler
from telegram.ext._utils.types import CCT, HandlerCallback
RT = TypeVar("RT")

View file

@ -23,7 +23,7 @@ from typing import TYPE_CHECKING, Any, Match, Optional, Pattern, TypeVar, Union,
from telegram import Update
from telegram._utils.defaultvalue import DEFAULT_TRUE
from telegram._utils.types import DVType
from telegram.ext._basehandler import BaseHandler
from telegram.ext._handlers.basehandler import BaseHandler
from telegram.ext._utils.types import CCT, HandlerCallback
RT = TypeVar("RT")

View file

@ -24,7 +24,7 @@ from telegram import MessageEntity, Update
from telegram._utils.defaultvalue import DEFAULT_TRUE
from telegram._utils.types import SCT, DVType
from telegram.ext import filters as filters_module
from telegram.ext._basehandler import BaseHandler
from telegram.ext._handlers.basehandler import BaseHandler
from telegram.ext._utils.types import CCT, FilterDataDict, HandlerCallback
if TYPE_CHECKING:

View file

@ -42,14 +42,14 @@ from telegram._utils.repr import build_repr_with_selected_attrs
from telegram._utils.types import DVType
from telegram._utils.warnings import warn
from telegram.ext._application import ApplicationHandlerStop
from telegram.ext._basehandler import BaseHandler
from telegram.ext._callbackqueryhandler import CallbackQueryHandler
from telegram.ext._choseninlineresulthandler import ChosenInlineResultHandler
from telegram.ext._extbot import ExtBot
from telegram.ext._inlinequeryhandler import InlineQueryHandler
from telegram.ext._stringcommandhandler import StringCommandHandler
from telegram.ext._stringregexhandler import StringRegexHandler
from telegram.ext._typehandler import TypeHandler
from telegram.ext._handlers.basehandler import BaseHandler
from telegram.ext._handlers.callbackqueryhandler import CallbackQueryHandler
from telegram.ext._handlers.choseninlineresulthandler import ChosenInlineResultHandler
from telegram.ext._handlers.inlinequeryhandler import InlineQueryHandler
from telegram.ext._handlers.stringcommandhandler import StringCommandHandler
from telegram.ext._handlers.stringregexhandler import StringRegexHandler
from telegram.ext._handlers.typehandler import TypeHandler
from telegram.ext._utils.trackingdict import TrackingDict
from telegram.ext._utils.types import CCT, ConversationDict, ConversationKey

View file

@ -23,7 +23,7 @@ from typing import TYPE_CHECKING, Any, List, Match, Optional, Pattern, TypeVar,
from telegram import Update
from telegram._utils.defaultvalue import DEFAULT_TRUE
from telegram._utils.types import DVType
from telegram.ext._basehandler import BaseHandler
from telegram.ext._handlers.basehandler import BaseHandler
from telegram.ext._utils.types import CCT, HandlerCallback
if TYPE_CHECKING:

View file

@ -23,7 +23,7 @@ from telegram import Update
from telegram._utils.defaultvalue import DEFAULT_TRUE
from telegram._utils.types import DVType
from telegram.ext import filters as filters_module
from telegram.ext._basehandler import BaseHandler
from telegram.ext._handlers.basehandler import BaseHandler
from telegram.ext._utils.types import CCT, HandlerCallback
if TYPE_CHECKING:

View file

@ -20,7 +20,7 @@
from telegram import Update
from telegram.ext._basehandler import BaseHandler
from telegram.ext._handlers.basehandler import BaseHandler
from telegram.ext._utils.types import CCT

View file

@ -20,7 +20,7 @@
from telegram import Update
from telegram.ext._basehandler import BaseHandler
from telegram.ext._handlers.basehandler import BaseHandler
from telegram.ext._utils.types import CCT

View file

@ -25,7 +25,7 @@ from typing import Optional, Pattern, TypeVar, Union
from telegram import Update
from telegram._utils.defaultvalue import DEFAULT_TRUE
from telegram._utils.types import DVType
from telegram.ext._basehandler import BaseHandler
from telegram.ext._handlers.basehandler import BaseHandler
from telegram.ext._utils.types import CCT, HandlerCallback
RT = TypeVar("RT")

View file

@ -24,7 +24,7 @@ from telegram import Update
from telegram._utils.defaultvalue import DEFAULT_TRUE
from telegram._utils.types import SCT, DVType
from telegram.ext import filters as filters_module
from telegram.ext._basehandler import BaseHandler
from telegram.ext._handlers.basehandler import BaseHandler
from telegram.ext._utils.types import CCT, HandlerCallback
if TYPE_CHECKING:

View file

@ -20,7 +20,7 @@
from telegram import Update
from telegram.ext._basehandler import BaseHandler
from telegram.ext._handlers.basehandler import BaseHandler
from telegram.ext._utils.types import CCT

View file

@ -22,7 +22,7 @@ from typing import TYPE_CHECKING, Any, List, Optional
from telegram._utils.defaultvalue import DEFAULT_TRUE
from telegram._utils.types import DVType
from telegram.ext._basehandler import BaseHandler
from telegram.ext._handlers.basehandler import BaseHandler
from telegram.ext._utils.types import CCT, RT, HandlerCallback
if TYPE_CHECKING:

View file

@ -23,7 +23,7 @@ from typing import TYPE_CHECKING, Any, Match, Optional, Pattern, TypeVar, Union
from telegram._utils.defaultvalue import DEFAULT_TRUE
from telegram._utils.types import DVType
from telegram.ext._basehandler import BaseHandler
from telegram.ext._handlers.basehandler import BaseHandler
from telegram.ext._utils.types import CCT, HandlerCallback
if TYPE_CHECKING:

View file

@ -22,7 +22,7 @@ from typing import Optional, Type, TypeVar
from telegram._utils.defaultvalue import DEFAULT_TRUE
from telegram._utils.types import DVType
from telegram.ext._basehandler import BaseHandler
from telegram.ext._handlers.basehandler import BaseHandler
from telegram.ext._utils.types import CCT, HandlerCallback
RT = TypeVar("RT")

View file

@ -607,7 +607,7 @@ class TestSendMediaGroupWithRequest:
assert len(messages) == 3
assert all(isinstance(mes, Message) for mes in messages)
assert all(mes.media_group_id == messages[0].media_group_id for mes in messages)
assert all(mes.caption == f"photo {idx+1}" for idx, mes in enumerate(messages))
assert all(mes.caption == f"photo {idx + 1}" for idx, mes in enumerate(messages))
assert all(
mes.caption_entities == (MessageEntity(MessageEntity.BOLD, 0, 5),) for mes in messages
)
@ -742,7 +742,7 @@ class TestSendMediaGroupWithRequest:
assert len(messages) == 3
assert all(isinstance(mes, Message) for mes in messages)
assert all(mes.media_group_id == messages[0].media_group_id for mes in messages)
assert all(mes.caption == f"photo {idx+1}" for idx, mes in enumerate(messages))
assert all(mes.caption == f"photo {idx + 1}" for idx, mes in enumerate(messages))
assert all(
mes.caption_entities == (MessageEntity(MessageEntity.BOLD, 0, 5),)
for mes in messages

View file

@ -17,7 +17,7 @@
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
from telegram.ext._basehandler import BaseHandler
from telegram.ext import BaseHandler
from tests.auxil.slots import mro_slots

View file

@ -725,7 +725,7 @@ class TestConversationHandler:
assert recwarn[0].category is PTBUserWarning
assert (
Path(recwarn[0].filename)
== PROJECT_ROOT_PATH / "telegram" / "ext" / "_conversationhandler.py"
== PROJECT_ROOT_PATH / "telegram" / "ext" / "_handlers" / "conversationhandler.py"
), "wrong stacklevel!"
assert (
str(recwarn[0].message)
@ -1105,7 +1105,11 @@ class TestConversationHandler:
assert warning.category is PTBUserWarning
assert (
Path(warning.filename)
== PROJECT_ROOT_PATH / "telegram" / "ext" / "_conversationhandler.py"
== PROJECT_ROOT_PATH
/ "telegram"
/ "ext"
/ "_handlers"
/ "conversationhandler.py"
), "wrong stacklevel!"
# now set app.job_queue back to it's original value

View file

@ -3173,8 +3173,8 @@ class TestBotWithRequest:
assert await bot.set_my_commands(commands)
for i, bc in enumerate(await bot.get_my_commands()):
assert bc.command == f"cmd{i+1}"
assert bc.description == f"descr{i+1}"
assert bc.command == f"cmd{i + 1}"
assert bc.description == f"descr{i + 1}"
async def test_get_set_delete_my_commands_with_scope(self, bot, super_group_id, chat_id):
group_cmds = [BotCommand("group_cmd", "visible to this supergroup only")]