Skip to content

Commit 34594af

Browse files
committed
refactor: make some methods static
1 parent b517204 commit 34594af

10 files changed

+22
-11
lines changed

hydrogram/handlers/callback_query_handler.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ def __init__(self, callback: Callable, filters=None):
5757
self.original_callback = callback
5858
super().__init__(self.resolve_future_or_callback, filters)
5959

60-
def compose_data_identifier(self, query: CallbackQuery) -> Identifier:
60+
@staticmethod
61+
def compose_data_identifier(query: CallbackQuery) -> Identifier:
6162
"""
6263
Composes an Identifier object from a CallbackQuery object.
6364

hydrogram/handlers/message_handler.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ def __init__(self, callback: Callable, filters=None):
5656
self.original_callback = callback
5757
super().__init__(self.resolve_future_or_callback, filters)
5858

59+
@staticmethod
5960
async def check_if_has_matching_listener(
60-
self, client: hydrogram.Client, message: Message
61+
client: hydrogram.Client, message: Message
6162
) -> tuple[bool, Listener | None]:
6263
"""
6364
Checks if the message has a matching listener.

hydrogram/methods/utilities/stop_transmission.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121

2222

2323
class StopTransmission:
24-
def stop_transmission(self):
24+
@staticmethod
25+
def stop_transmission():
2526
"""Stop downloading or uploading a file.
2627
2728
This method must be called inside a progress callback function in order to stop the transmission at the

hydrogram/types/bots_and_keyboards/bot_command_scope_all_chat_administrators.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ class BotCommandScopeAllChatAdministrators(BotCommandScope):
2929
def __init__(self):
3030
super().__init__("all_chat_administrators")
3131

32-
async def write(self, client: "hydrogram.Client") -> "raw.base.BotCommandScope":
32+
@staticmethod
33+
async def write(client: "hydrogram.Client") -> "raw.base.BotCommandScope":
3334
return raw.types.BotCommandScopeChatAdmins()

hydrogram/types/bots_and_keyboards/bot_command_scope_all_group_chats.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ class BotCommandScopeAllGroupChats(BotCommandScope):
2929
def __init__(self):
3030
super().__init__("all_group_chats")
3131

32-
async def write(self, client: "hydrogram.Client") -> "raw.base.BotCommandScope":
32+
@staticmethod
33+
async def write(client: "hydrogram.Client") -> "raw.base.BotCommandScope":
3334
return raw.types.BotCommandScopeChats()

hydrogram/types/bots_and_keyboards/bot_command_scope_all_private_chats.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ class BotCommandScopeAllPrivateChats(BotCommandScope):
2929
def __init__(self):
3030
super().__init__("all_private_chats")
3131

32-
async def write(self, client: "hydrogram.Client") -> "raw.base.BotCommandScope":
32+
@staticmethod
33+
async def write(client: "hydrogram.Client") -> "raw.base.BotCommandScope":
3334
return raw.types.BotCommandScopeUsers()

hydrogram/types/bots_and_keyboards/bot_command_scope_default.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@ class BotCommandScopeDefault(BotCommandScope):
3131
def __init__(self):
3232
super().__init__("default")
3333

34-
async def write(self, client: "hydrogram.Client") -> "raw.base.BotCommandScope":
34+
@staticmethod
35+
async def write(client: "hydrogram.Client") -> "raw.base.BotCommandScope":
3536
return raw.types.BotCommandScopeDefault()

hydrogram/types/bots_and_keyboards/menu_button_commands.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ class MenuButtonCommands(MenuButton):
2929
def __init__(self):
3030
super().__init__("commands")
3131

32-
async def write(self, client: "hydrogram.Client") -> "raw.types.BotMenuButtonCommands":
32+
@staticmethod
33+
async def write(client: "hydrogram.Client") -> "raw.types.BotMenuButtonCommands":
3334
return raw.types.BotMenuButtonCommands()

hydrogram/types/bots_and_keyboards/menu_button_default.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ class MenuButtonDefault(MenuButton):
2929
def __init__(self):
3030
super().__init__("default")
3131

32-
async def write(self, client: "hydrogram.Client") -> "raw.types.BotMenuButtonDefault":
32+
@staticmethod
33+
async def write(client: "hydrogram.Client") -> "raw.types.BotMenuButtonDefault":
3334
return raw.types.BotMenuButtonDefault()

hydrogram/types/update.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@
2121

2222

2323
class Update:
24-
def stop_propagation(self):
24+
@staticmethod
25+
def stop_propagation():
2526
raise hydrogram.StopPropagation
2627

27-
def continue_propagation(self):
28+
@staticmethod
29+
def continue_propagation():
2830
raise hydrogram.ContinuePropagation

0 commit comments

Comments
 (0)