team-dev-spring-2022 / TGBot

Telegram Bot для автоматизации процессов учебы
1 stars 3 forks source link

Suggest to loosen the dependency on aiogram #50

Open Agnes-U opened 2 years ago

Agnes-U commented 2 years ago

Hi, your project TGBot requires "aiogram==2.19" in its dependency. After analyzing the source code, we found that the following versions of aiogram can also be suitable without affecting your project, i.e., aiogram 2.18, 2.20. Therefore, we suggest to loosen the dependency on aiogram from "aiogram==2.19" to "aiogram>=2.18,<=2.20" to avoid any possible conflict for importing more packages or for downstream projects that may use TGBot.

May I pull a request to further loosen the dependency on aiogram?

By the way, could you please tell us whether such dependency analysis may be potentially helpful for maintaining dependencies easier during your development?



We also give our detailed analysis as follows for your reference:

Your project TGBot directly uses 7 APIs from package aiogram.

aiogram.utils.executor.start_polling, aiogram.dispatcher.dispatcher.Dispatcher.message_handler, aiogram.dispatcher.dispatcher.Dispatcher.__init__, aiogram.types.message.Message.__init__, aiogram.utils.markdown.text, aiogram.bot.bot.Bot.__init__, aiogram.utils.markdown.bold

Beginning from the 7 APIs above, 36 functions are then indirectly called, including 27 aiogram's internal APIs and 9 outsider APIs. The specific call graph is listed as follows (neglecting some repeated function occurrences).

[/team-dev-spring-2022/TGBot]
+--aiogram.utils.executor.start_polling
|      +--aiogram.utils.executor.Executor.__init__
|      |      +--secrets.token_urlsafe
|      |      +--aiogram.utils.mixins.ContextInstanceMixin.set_current
|      +--aiogram.utils.executor._setup_callbacks
|      +--aiogram.utils.executor.Executor.start_polling
|      |      +--aiogram.utils.executor.Executor._prepare_polling
|      |      |      +--aiogram.utils.executor.Executor._check_frozen
+--aiogram.dispatcher.dispatcher.Dispatcher.message_handler
|      +--aiogram.dispatcher.dispatcher.Dispatcher.register_message_handler
|      |      +--aiogram.dispatcher.handler.Handler.register
|      |      |      +--aiogram.dispatcher.handler._get_spec
|      |      |      |      +--inspect.getfullargspec
|      |      |      +--aiogram.dispatcher.filters.filters.get_filters_spec
|      |      |      |      +--aiogram.dispatcher.filters.filters.get_filter_spec
|      |      |      |      |      +--inspect.getfullargspec
|      |      |      |      |      +--inspect.isawaitable
|      |      |      |      |      +--inspect.iscoroutinefunction
|      |      |      |      |      +--aiogram.dispatcher.handler.FilterObj.__init__
|      |      |      +--aiogram.dispatcher.handler.Handler.HandlerObj.__init__
|      |      +--aiogram.dispatcher.dispatcher.Dispatcher._wrap_async_task
|      |      |      +--aiogram.dispatcher.dispatcher.Dispatcher.async_task
|      |      |      |      +--aiogram.dispatcher.dispatcher.Dispatcher._loop_create_task
|      |      |      |      |      +--asyncio.create_task
|      |      |      |      |      +--aiogram.dispatcher.dispatcher._ensure_loop
|      |      |      |      +--functools.wraps
+--aiogram.dispatcher.dispatcher.Dispatcher.__init__
|      +--aiogram.dispatcher.storage.DisabledStorage.__init__
|      +--aiogram.dispatcher.filters.factory.FiltersFactory.__init__
|      +--aiogram.dispatcher.dispatcher._ensure_loop
|      +--aiogram.dispatcher.handler.Handler.__init__
|      +--aiogram.dispatcher.middlewares.MiddlewareManager.__init__
|      +--aiogram.dispatcher.handler.Handler.register
|      +--aiogram.dispatcher.dispatcher.Dispatcher._setup_filters
+--aiogram.types.message.Message.__init__
+--aiogram.utils.markdown.text
|      +--aiogram.utils.markdown._join
+--aiogram.bot.bot.Bot.__init__
|      +--aiogram.bot.base.BaseBot.__init__
|      |      +--aiogram.bot.api.check_token
|      |      |      +--aiogram.utils.exceptions.ValidationError.__init__
|      |      |      |      +--aiogram.utils.exceptions.TelegramAPIError.__init__
|      |      |      |      |      +--aiogram.utils.exceptions._clean_message
|      |      +--ssl.create_default_context
|      |      +--certifi.where
|      |      +--aiohttp_socks.utils.parse_proxy_url
+--aiogram.utils.markdown.bold
|      +--aiogram.utils.markdown._join

We scan aiogram's versions and observe that during its evolution between any version from [2.18, 2.20] and 2.19, the changing functions (diffs being listed below) have none intersection with any function or API we mentioned above (either directly or indirectly called by this project).

diff: 2.13(original) 2.14
['aiogram.types.force_reply.ForceReply.create', 'aiogram.contrib.fsm_storage.mongo.MongoStorage', 'aiogram.types.chat_member.ChatMember', 'aiogram.contrib.fsm_storage.redis.RedisStorage', 'aiogram.types.bot_command_scope.BotCommandScopeAllGroupChats', 'aiogram.types.chat_member.ChatMember.is_chat_member', 'aiogram.types.chat_member.ChatMemberLeft', 'aiogram.types.chat_member.ChatMember.__int__', 'aiogram.types.chat_member.ChatMember.is_chat_creator', 'aiogram.utils.text_decorations.MarkdownDecoration', 'aiogram.types.chat_member.ChatMemberBanned', 'aiogram.types.chat_member.ChatMemberMember', 'aiogram.types.chat_member.ChatMember.is_chat_admin', 'aiogram.types.chat.Chat', 'aiogram.types.message.Message', 'aiogram.types.chat_member.ChatMemberAdministrator', 'aiogram.bot.bot.Bot.ban_chat_member', 'aiogram.types.bot_command_scope.BotCommandScopeType', 'aiogram.contrib.fsm_storage.memory.MemoryStorage._cleanup', 'aiogram.types.bot_command_scope.BotCommandScopeChatMember', 'aiogram.types.reply_keyboard.ReplyKeyboardMarkup.__init__', 'aiogram.contrib.fsm_storage.redis.RedisStorage2', 'aiogram.types.message.Message.is_command', 'aiogram.types.input_media.InputMedia', 'aiogram.types.bot_command_scope.BotCommandScopeAllChatAdministrators', 'aiogram.types.reply_keyboard.ReplyKeyboardMarkup', 'aiogram.types.bot_command_scope.BotCommandScopeAllPrivateChats', 'aiogram.bot.api.Methods', 'aiogram.types.update.AllowedUpdates.default', 'aiogram.types.bot_command_scope.BotCommandScopeChatAdministrators', 'aiogram.bot.bot.Bot.get_chat_member_count', 'aiogram.types.bot_command_scope.BotCommandScope', 'aiogram.types.chat_member.ChatMember.resolve', 'aiogram.types.bot_command_scope.BotCommandScope.from_type', 'aiogram.types.bot_command_scope.BotCommandScopeChatMember.__init__', 'aiogram.contrib.fsm_storage.memory.MemoryStorage', 'aiogram.types.chat_member.ChatMemberStatus.get_class_by_status', 'aiogram.types.bot_command_scope.BotCommandScopeChat.__init__', 'aiogram.types.chat_member.ChatMemberOwner', 'aiogram.contrib.fsm_storage.redis.RedisStorage2.__init__', 'aiogram.utils.text_decorations.MarkdownDecoration.pre', 'aiogram.types.message.Message.get_full_command', 'aiogram.types.chat.Chat.get_member_count', 'aiogram.bot.bot.Bot', 'aiogram.types.update.AllowedUpdates', 'aiogram.types.message.Message.url', 'aiogram.types.bot_command_scope.BotCommandScopeDefault', 'aiogram.bot.bot.Bot.delete_my_commands', 'aiogram.types.chat_member.ChatMemberStatus', 'aiogram.types.force_reply.ForceReply', 'aiogram.types.chat_member.ChatMemberRestricted', 'aiogram.utils.exceptions.GroupDeactivated', 'aiogram.types.bot_command_scope.BotCommandScopeChat']

diff: 2.13(original) 2.14.1
['aiogram.types.force_reply.ForceReply.create', 'aiogram.contrib.fsm_storage.mongo.MongoStorage', 'aiogram.types.chat_member.ChatMember', 'aiogram.contrib.fsm_storage.redis.RedisStorage', 'aiogram.types.bot_command_scope.BotCommandScopeAllGroupChats', 'aiogram.types.chat_member.ChatMember.is_chat_member', 'aiogram.types.chat_member.ChatMemberLeft', 'aiogram.types.chat_member.ChatMember.__int__', 'aiogram.types.chat_member.ChatMember.is_chat_creator', 'aiogram.utils.text_decorations.MarkdownDecoration', 'aiogram.types.chat_member.ChatMemberBanned', 'aiogram.types.chat_member.ChatMemberMember', 'aiogram.types.chat_member.ChatMember.is_chat_admin', 'aiogram.types.chat.Chat', 'aiogram.types.message.Message', 'aiogram.types.chat_member.ChatMemberAdministrator', 'aiogram.bot.bot.Bot.ban_chat_member', 'aiogram.types.bot_command_scope.BotCommandScopeType', 'aiogram.contrib.fsm_storage.memory.MemoryStorage._cleanup', 'aiogram.types.bot_command_scope.BotCommandScopeChatMember', 'aiogram.types.reply_keyboard.ReplyKeyboardMarkup.__init__', 'aiogram.contrib.fsm_storage.redis.RedisStorage2', 'aiogram.types.message.Message.is_command', 'aiogram.types.input_media.InputMedia', 'aiogram.types.bot_command_scope.BotCommandScopeAllChatAdministrators', 'aiogram.types.reply_keyboard.ReplyKeyboardMarkup', 'aiogram.types.bot_command_scope.BotCommandScopeAllPrivateChats', 'aiogram.bot.api.Methods', 'aiogram.types.update.AllowedUpdates.default', 'aiogram.types.bot_command_scope.BotCommandScopeChatAdministrators', 'aiogram.bot.bot.Bot.get_chat_member_count', 'aiogram.types.bot_command_scope.BotCommandScope', 'aiogram.types.chat_member.ChatMember.resolve', 'aiogram.types.bot_command_scope.BotCommandScope.from_type', 'aiogram.types.bot_command_scope.BotCommandScopeChatMember.__init__', 'aiogram.contrib.fsm_storage.memory.MemoryStorage', 'aiogram.types.chat_member.ChatMemberStatus.get_class_by_status', 'aiogram.types.bot_command_scope.BotCommandScopeChat.__init__', 'aiogram.types.chat_member.ChatMemberOwner', 'aiogram.contrib.fsm_storage.redis.RedisStorage2.__init__', 'aiogram.utils.text_decorations.MarkdownDecoration.pre', 'aiogram.types.message.Message.get_full_command', 'aiogram.types.chat.Chat.get_member_count', 'aiogram.bot.bot.Bot', 'aiogram.types.update.AllowedUpdates', 'aiogram.types.message.Message.url', 'aiogram.types.bot_command_scope.BotCommandScopeDefault', 'aiogram.bot.bot.Bot.delete_my_commands', 'aiogram.types.chat_member.ChatMemberStatus', 'aiogram.types.force_reply.ForceReply', 'aiogram.types.chat_member.ChatMemberRestricted', 'aiogram.utils.exceptions.GroupDeactivated', 'aiogram.types.bot_command_scope.BotCommandScopeChat']

diff: 2.13(original) 2.14.2
['aiogram.types.force_reply.ForceReply.create', 'aiogram.contrib.fsm_storage.mongo.MongoStorage', 'aiogram.types.chat_member.ChatMember', 'aiogram.contrib.fsm_storage.redis.RedisStorage', 'aiogram.types.bot_command_scope.BotCommandScopeAllGroupChats', 'aiogram.types.chat_member.ChatMember.is_chat_member', 'aiogram.types.chat_member.ChatMemberLeft', 'aiogram.types.chat_member.ChatMember.__int__', 'aiogram.types.chat_member.ChatMember.is_chat_creator', 'aiogram.utils.text_decorations.MarkdownDecoration', 'aiogram.types.chat_member.ChatMemberBanned', 'aiogram.types.chat_member.ChatMemberMember', 'aiogram.types.chat_member.ChatMember.is_chat_admin', 'aiogram.types.chat.Chat', 'aiogram.types.message.Message', 'aiogram.types.chat_member.ChatMemberAdministrator', 'aiogram.bot.bot.Bot.ban_chat_member', 'aiogram.types.bot_command_scope.BotCommandScopeType', 'aiogram.contrib.fsm_storage.memory.MemoryStorage._cleanup', 'aiogram.types.bot_command_scope.BotCommandScopeChatMember', 'aiogram.types.reply_keyboard.ReplyKeyboardMarkup.__init__', 'aiogram.contrib.fsm_storage.redis.RedisStorage2', 'aiogram.types.message.Message.is_command', 'aiogram.types.input_media.InputMedia', 'aiogram.types.bot_command_scope.BotCommandScopeAllChatAdministrators', 'aiogram.types.reply_keyboard.ReplyKeyboardMarkup', 'aiogram.types.bot_command_scope.BotCommandScopeAllPrivateChats', 'aiogram.bot.api.Methods', 'aiogram.contrib.middlewares.i18n.I18nMiddleware', 'aiogram.types.update.AllowedUpdates.default', 'aiogram.types.bot_command_scope.BotCommandScopeChatAdministrators', 'aiogram.bot.bot.Bot.get_chat_member_count', 'aiogram.types.bot_command_scope.BotCommandScope', 'aiogram.types.chat_member.ChatMember.resolve', 'aiogram.types.bot_command_scope.BotCommandScope.from_type', 'aiogram.types.bot_command_scope.BotCommandScopeChatMember.__init__', 'aiogram.contrib.fsm_storage.memory.MemoryStorage', 'aiogram.types.chat_member.ChatMemberStatus.get_class_by_status', 'aiogram.types.bot_command_scope.BotCommandScopeChat.__init__', 'aiogram.types.chat_member.ChatMemberOwner', 'aiogram.contrib.fsm_storage.redis.RedisStorage2.__init__', 'aiogram.utils.text_decorations.MarkdownDecoration.pre', 'aiogram.types.message.Message.get_full_command', 'aiogram.types.chat.Chat.get_member_count', 'aiogram.bot.bot.Bot', 'aiogram.types.update.AllowedUpdates', 'aiogram.types.message.Message.url', 'aiogram.types.bot_command_scope.BotCommandScopeDefault', 'aiogram.bot.bot.Bot.delete_my_commands', 'aiogram.types.chat_member.ChatMemberStatus', 'aiogram.types.force_reply.ForceReply', 'aiogram.types.chat_member.ChatMemberRestricted', 'aiogram.utils.exceptions.GroupDeactivated', 'aiogram.types.bot_command_scope.BotCommandScopeChat']

diff: 2.13(original) 2.14.3
['aiogram.types.fields.Field', 'aiogram.types.force_reply.ForceReply.create', 'aiogram.contrib.fsm_storage.mongo.MongoStorage', 'aiogram.types.chat_member.ChatMember', 'aiogram.contrib.fsm_storage.redis.RedisStorage', 'aiogram.types.bot_command_scope.BotCommandScopeAllGroupChats', 'aiogram.types.chat_member.ChatMember.is_chat_member', 'aiogram.types.chat_member.ChatMemberLeft', 'aiogram.types.chat_member.ChatMember.__int__', 'aiogram.types.chat_member.ChatMember.is_chat_creator', 'aiogram.utils.text_decorations.MarkdownDecoration', 'aiogram.types.chat_member.ChatMemberBanned', 'aiogram.types.fields.ListField.serialize', 'aiogram.types.chat_member.ChatMemberMember', 'aiogram.types.chat_member.ChatMember.is_chat_admin', 'aiogram.types.chat.Chat', 'aiogram.types.message.Message', 'aiogram.types.chat_member.ChatMemberAdministrator', 'aiogram.bot.bot.Bot.ban_chat_member', 'aiogram.types.bot_command_scope.BotCommandScopeType', 'aiogram.contrib.fsm_storage.memory.MemoryStorage._cleanup', 'aiogram.types.chat_member.ChatMember.to_object', 'aiogram.types.bot_command_scope.BotCommandScopeChatMember', 'aiogram.types.reply_keyboard.ReplyKeyboardMarkup.__init__', 'aiogram.contrib.fsm_storage.redis.RedisStorage2', 'aiogram.types.message.Message.is_command', 'aiogram.types.input_media.InputMedia', 'aiogram.types.fields.ListField.deserialize', 'aiogram.types.bot_command_scope.BotCommandScopeAllChatAdministrators', 'aiogram.types.reply_keyboard.ReplyKeyboardMarkup', 'aiogram.types.fields.Field.deserialize', 'aiogram.types.bot_command_scope.BotCommandScopeAllPrivateChats', 'aiogram.bot.api.Methods', 'aiogram.contrib.middlewares.i18n.I18nMiddleware', 'aiogram.types.update.AllowedUpdates.default', 'aiogram.types.bot_command_scope.BotCommandScopeChatAdministrators', 'aiogram.bot.bot.Bot.get_chat_member_count', 'aiogram.types.bot_command_scope.BotCommandScope', 'aiogram.types.chat_member.ChatMember.resolve', 'aiogram.types.bot_command_scope.BotCommandScope.from_type', 'aiogram.types.bot_command_scope.BotCommandScopeChatMember.__init__', 'aiogram.contrib.fsm_storage.memory.MemoryStorage', 'aiogram.types.fields.ListField', 'aiogram.types.chat_member.ChatMemberStatus.get_class_by_status', 'aiogram.types.base.TelegramObject.to_object', 'aiogram.types.bot_command_scope.BotCommandScopeChat.__init__', 'aiogram.types.chat_member.ChatMemberOwner', 'aiogram.contrib.fsm_storage.redis.RedisStorage2.__init__', 'aiogram.utils.text_decorations.MarkdownDecoration.pre', 'aiogram.types.message.Message.get_full_command', 'aiogram.types.base.TelegramObject', 'aiogram.bot.bot.Bot', 'aiogram.types.update.AllowedUpdates', 'aiogram.types.chat.Chat.get_member_count', 'aiogram.types.message.Message.url', 'aiogram.types.bot_command_scope.BotCommandScopeDefault', 'aiogram.bot.bot.Bot.delete_my_commands', 'aiogram.types.chat_member.ChatMemberStatus', 'aiogram.types.force_reply.ForceReply', 'aiogram.types.chat_member.ChatMemberRestricted', 'aiogram.utils.exceptions.GroupDeactivated', 'aiogram.types.bot_command_scope.BotCommandScopeChat']

As for other packages, the APIs of secrets, ssl, certifi, aiohttp_socks, inspect, functools and asyncio are called by aiogram in the call graph and the dependencies on these packages also stay the same in our suggested versions, thus avoiding any outside conflict.

Therefore, we believe that it is quite safe to loose your dependency on aiogram from "aiogram==2.19" to "aiogram>=2.18,<=2.20". This will improve the applicability of TGBot and reduce the possibility of any further dependency conflict with other projects.

SaryalVasilyev commented 1 year ago

dsadas