Skip to content

Commit 9b1524d

Browse files
authored
Add typehints to all of the decorators classes (hydrogram#34)
1 parent e085adb commit 9b1524d

13 files changed

Lines changed: 49 additions & 49 deletions

pyrogram/methods/decorators/on_callback_query.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19-
from typing import Callable
19+
from typing import Callable, Optional, Union
2020

2121
import pyrogram
2222
from pyrogram.filters import Filter
2323

2424

2525
class OnCallbackQuery:
2626
def on_callback_query(
27-
self=None,
28-
filters=None,
29-
group: int = 0
27+
self: Union["OnCallbackQuery", Filter, None] = None,
28+
filters: Optional[Filter] = None,
29+
group: int = 0,
3030
) -> Callable:
3131
"""Decorator for handling callback queries.
3232

pyrogram/methods/decorators/on_chat_join_request.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19-
from typing import Callable
19+
from typing import Callable, Optional, Union
2020

2121
import pyrogram
2222
from pyrogram.filters import Filter
2323

2424

2525
class OnChatJoinRequest:
2626
def on_chat_join_request(
27-
self=None,
28-
filters=None,
29-
group: int = 0
27+
self: Union["OnChatJoinRequest", Filter, None] = None,
28+
filters: Optional[Filter] = None,
29+
group: int = 0,
3030
) -> Callable:
3131
"""Decorator for handling chat join requests.
3232

pyrogram/methods/decorators/on_chat_member_updated.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19-
from typing import Callable
19+
from typing import Callable, Optional, Union
2020

2121
import pyrogram
2222
from pyrogram.filters import Filter
2323

2424

2525
class OnChatMemberUpdated:
2626
def on_chat_member_updated(
27-
self=None,
28-
filters=None,
29-
group: int = 0
27+
self: Union["OnChatMemberUpdated", Filter, None] = None,
28+
filters: Optional[Filter] = None,
29+
group: int = 0,
3030
) -> Callable:
3131
"""Decorator for handling event changes on chat members.
3232

pyrogram/methods/decorators/on_chosen_inline_result.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19-
from typing import Callable
19+
from typing import Callable, Optional, Union
2020

2121
import pyrogram
2222
from pyrogram.filters import Filter
2323

2424

2525
class OnChosenInlineResult:
2626
def on_chosen_inline_result(
27-
self=None,
28-
filters=None,
29-
group: int = 0
27+
self: Union["OnChosenInlineResult", Filter, None] = None,
28+
filters: Optional[Filter] = None,
29+
group: int = 0,
3030
) -> Callable:
3131
"""Decorator for handling chosen inline results.
3232

pyrogram/methods/decorators/on_deleted_messages.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19-
from typing import Callable
19+
from typing import Callable, Optional, Union
2020

2121
import pyrogram
2222
from pyrogram.filters import Filter
2323

2424

2525
class OnDeletedMessages:
2626
def on_deleted_messages(
27-
self=None,
28-
filters=None,
29-
group: int = 0
27+
self: Union["OnDeletedMessages", Filter, None] = None,
28+
filters: Optional[Filter] = None,
29+
group: int = 0,
3030
) -> Callable:
3131
"""Decorator for handling deleted messages.
3232

pyrogram/methods/decorators/on_disconnect.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19-
from typing import Callable
19+
from typing import Callable, Optional
2020

2121
import pyrogram
2222

2323

2424
class OnDisconnect:
25-
def on_disconnect(self=None) -> Callable:
25+
def on_disconnect(self: Optional["OnDisconnect"] = None) -> Callable:
2626
"""Decorator for handling disconnections.
2727
2828
This does the same thing as :meth:`~pyrogram.Client.add_handler` using the

pyrogram/methods/decorators/on_edited_message.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19-
from typing import Callable
19+
from typing import Callable, Optional, Union
2020

2121
import pyrogram
2222
from pyrogram.filters import Filter
2323

2424

2525
class OnEditedMessage:
2626
def on_edited_message(
27-
self=None,
28-
filters=None,
29-
group: int = 0
27+
self: Union["OnEditedMessage", Filter, None] = None,
28+
filters: Optional[Filter] = None,
29+
group: int = 0,
3030
) -> Callable:
3131
"""Decorator for handling edited messages.
3232

pyrogram/methods/decorators/on_inline_query.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19-
from typing import Callable
19+
from typing import Callable, Optional, Union
2020

2121
import pyrogram
2222
from pyrogram.filters import Filter
2323

2424

2525
class OnInlineQuery:
2626
def on_inline_query(
27-
self=None,
28-
filters=None,
29-
group: int = 0
27+
self: Union["OnInlineQuery", Filter, None] = None,
28+
filters: Optional[Filter] = None,
29+
group: int = 0,
3030
) -> Callable:
3131
"""Decorator for handling inline queries.
3232

pyrogram/methods/decorators/on_message.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19-
from typing import Callable
19+
from typing import Callable, Optional, Union
2020

2121
import pyrogram
2222
from pyrogram.filters import Filter
2323

2424

2525
class OnMessage:
2626
def on_message(
27-
self=None,
28-
filters=None,
29-
group: int = 0
27+
self: Union["OnMessage", Filter, None] = None,
28+
filters: Optional[Filter] = None,
29+
group: int = 0,
3030
) -> Callable:
3131
"""Decorator for handling new messages.
3232

pyrogram/methods/decorators/on_poll.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19-
from typing import Callable
19+
from typing import Callable, Optional, Union
2020

2121
import pyrogram
2222
from pyrogram.filters import Filter
2323

2424

2525
class OnPoll:
2626
def on_poll(
27-
self=None,
28-
filters=None,
29-
group: int = 0
27+
self: Union["OnPoll", Filter, None] = None,
28+
filters: Optional[Filter] = None,
29+
group: int = 0,
3030
) -> Callable:
3131
"""Decorator for handling poll updates.
3232

0 commit comments

Comments
 (0)