Skip to content

Commit

Permalink
Add typehints to all of the decorators classes (Mayuri-Chan#34)
Browse files Browse the repository at this point in the history
Signed-off-by: eyMarv <[email protected]>
  • Loading branch information
MarsBatya authored and eyMarv committed Mar 30, 2024
1 parent 9620b0e commit b5f086b
Show file tree
Hide file tree
Showing 13 changed files with 73 additions and 26 deletions.
8 changes: 6 additions & 2 deletions pyrogram/methods/decorators/on_callback_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.

from typing import Callable
from typing import Callable, Optional, Union

import pyrogram
from pyrogram.filters import Filter


class OnCallbackQuery:
def on_callback_query(self=None, filters=None, group: int = 0) -> Callable:
def on_callback_query(
self: Union["OnCallbackQuery", Filter, None] = None,
filters: Optional[Filter] = None,
group: int = 0,
) -> Callable:
"""Decorator for handling callback queries.
This does the same thing as :meth:`~pyrogram.Client.add_handler` using the
Expand Down
8 changes: 6 additions & 2 deletions pyrogram/methods/decorators/on_chat_join_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.

from typing import Callable
from typing import Callable, Optional, Union

import pyrogram
from pyrogram.filters import Filter


class OnChatJoinRequest:
def on_chat_join_request(self=None, filters=None, group: int = 0) -> Callable:
def on_chat_join_request(
self: Union["OnChatJoinRequest", Filter, None] = None,
filters: Optional[Filter] = None,
group: int = 0,
) -> Callable:
"""Decorator for handling chat join requests.
This does the same thing as :meth:`~pyrogram.Client.add_handler` using the
Expand Down
8 changes: 6 additions & 2 deletions pyrogram/methods/decorators/on_chat_member_updated.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.

from typing import Callable
from typing import Callable, Optional, Union

import pyrogram
from pyrogram.filters import Filter


class OnChatMemberUpdated:
def on_chat_member_updated(self=None, filters=None, group: int = 0) -> Callable:
def on_chat_member_updated(
self: Union["OnChatMemberUpdated", Filter, None] = None,
filters: Optional[Filter] = None,
group: int = 0,
) -> Callable:
"""Decorator for handling event changes on chat members.
This does the same thing as :meth:`~pyrogram.Client.add_handler` using the
Expand Down
8 changes: 6 additions & 2 deletions pyrogram/methods/decorators/on_chosen_inline_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.

from typing import Callable
from typing import Callable, Optional, Union

import pyrogram
from pyrogram.filters import Filter


class OnChosenInlineResult:
def on_chosen_inline_result(self=None, filters=None, group: int = 0) -> Callable:
def on_chosen_inline_result(
self: Union["OnChosenInlineResult", Filter, None] = None,
filters: Optional[Filter] = None,
group: int = 0,
) -> Callable:
"""Decorator for handling chosen inline results.
This does the same thing as :meth:`~pyrogram.Client.add_handler` using the
Expand Down
8 changes: 6 additions & 2 deletions pyrogram/methods/decorators/on_deleted_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.

from typing import Callable
from typing import Callable, Optional, Union

import pyrogram
from pyrogram.filters import Filter


class OnDeletedMessages:
def on_deleted_messages(self=None, filters=None, group: int = 0) -> Callable:
def on_deleted_messages(
self: Union["OnDeletedMessages", Filter, None] = None,
filters: Optional[Filter] = None,
group: int = 0,
) -> Callable:
"""Decorator for handling deleted messages.
This does the same thing as :meth:`~pyrogram.Client.add_handler` using the
Expand Down
4 changes: 2 additions & 2 deletions pyrogram/methods/decorators/on_disconnect.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.

from typing import Callable
from typing import Callable, Optional

import pyrogram


class OnDisconnect:
def on_disconnect(self=None) -> Callable:
def on_disconnect(self: Optional["OnDisconnect"] = None) -> Callable:
"""Decorator for handling disconnections.
This does the same thing as :meth:`~pyrogram.Client.add_handler` using the
Expand Down
8 changes: 6 additions & 2 deletions pyrogram/methods/decorators/on_edited_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.

from typing import Callable
from typing import Callable, Optional, Union

import pyrogram
from pyrogram.filters import Filter


class OnEditedMessage:
def on_edited_message(self=None, filters=None, group: int = 0) -> Callable:
def on_edited_message(
self: Union["OnEditedMessage", Filter, None] = None,
filters: Optional[Filter] = None,
group: int = 0,
) -> Callable:
"""Decorator for handling edited messages.
This does the same thing as :meth:`~pyrogram.Client.add_handler` using the
Expand Down
8 changes: 6 additions & 2 deletions pyrogram/methods/decorators/on_inline_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.

from typing import Callable
from typing import Callable, Optional, Union

import pyrogram
from pyrogram.filters import Filter


class OnInlineQuery:
def on_inline_query(self=None, filters=None, group: int = 0) -> Callable:
def on_inline_query(
self: Union["OnInlineQuery", Filter, None] = None,
filters: Optional[Filter] = None,
group: int = 0,
) -> Callable:
"""Decorator for handling inline queries.
This does the same thing as :meth:`~pyrogram.Client.add_handler` using the
Expand Down
8 changes: 6 additions & 2 deletions pyrogram/methods/decorators/on_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.

from typing import Callable
from typing import Callable, Optional, Union

import pyrogram
from pyrogram.filters import Filter


class OnMessage:
def on_message(self=None, filters=None, group: int = 0) -> Callable:
def on_message(
self: Union["OnMessage", Filter, None] = None,
filters: Optional[Filter] = None,
group: int = 0,
) -> Callable:
"""Decorator for handling new messages.
This does the same thing as :meth:`~pyrogram.Client.add_handler` using the
Expand Down
8 changes: 6 additions & 2 deletions pyrogram/methods/decorators/on_poll.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.

from typing import Callable
from typing import Callable, Optional, Union

import pyrogram
from pyrogram.filters import Filter


class OnPoll:
def on_poll(self=None, filters=None, group: int = 0) -> Callable:
def on_poll(
self: Union["OnPoll", Filter, None] = None,
filters: Optional[Filter] = None,
group: int = 0,
) -> Callable:
"""Decorator for handling poll updates.
This does the same thing as :meth:`~pyrogram.Client.add_handler` using the
Expand Down
7 changes: 5 additions & 2 deletions pyrogram/methods/decorators/on_raw_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.

from typing import Callable
from typing import Callable, Optional

import pyrogram


class OnRawUpdate:
def on_raw_update(self=None, group: int = 0) -> Callable:
def on_raw_update(
self: Optional["OnRawUpdate"] = None,
group: int = 0,
) -> Callable:
"""Decorator for handling raw updates.
This does the same thing as :meth:`~pyrogram.Client.add_handler` using the
Expand Down
8 changes: 6 additions & 2 deletions pyrogram/methods/decorators/on_story.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@
# along with pyroblack. If not, see <http://www.gnu.org/licenses/>.


from typing import Callable
from typing import Callable, Optional, Union

import pyrogram
from pyrogram.filters import Filter


class OnStory:
def on_story(self=None, filters=None, group: int = 0) -> Callable:
def on_story(
self: Union["OnStory", Filter, None] = None,
filters: Optional[Filter] = None,
group: int = 0,
) -> Callable:
"""Decorator for handling new stories.
This does the same thing as :meth:`~pyrogram.Client.add_handler` using the
Expand Down
8 changes: 6 additions & 2 deletions pyrogram/methods/decorators/on_user_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.

from typing import Callable
from typing import Callable, Optional, Union

import pyrogram
from pyrogram.filters import Filter


class OnUserStatus:
def on_user_status(self=None, filters=None, group: int = 0) -> Callable:
def on_user_status(
self: Union["OnUserStatus", Filter, None] = None,
filters: Optional[Filter] = None,
group: int = 0,
) -> Callable:
"""Decorator for handling user status updates.
This does the same thing as :meth:`~pyrogram.Client.add_handler` using the
Expand Down

0 comments on commit b5f086b

Please sign in to comment.