Type hint all Pyrogram types · stack-queue/pyrogram@5035daa · GitHub
Skip to content

Commit 5035daa

Browse files
committed
Type hint all Pyrogram types
1 parent e8fbae3 commit 5035daa

27 files changed

Lines changed: 106 additions & 58 deletions

pyrogram/client/types/bots/callback_query.py

Lines changed: 4 additions & 3 deletions

pyrogram/client/types/bots/inline_keyboard_markup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
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 List
20+
1921
from pyrogram.api.types import ReplyInlineMarkup, KeyboardButtonRow
2022
from . import InlineKeyboardButton
2123
from ..pyrogram_type import PyrogramType
@@ -30,7 +32,7 @@ class InlineKeyboardMarkup(PyrogramType):
3032
"""
3133

3234
def __init__(self,
33-
inline_keyboard: list):
35+
inline_keyboard: List[List[InlineKeyboardButton]]):
3436
super().__init__(None)
3537

3638
self.inline_keyboard = inline_keyboard

pyrogram/client/types/bots/reply_keyboard_markup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
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 List
20+
1921
from pyrogram.api.types import KeyboardButtonRow
2022
from pyrogram.api.types import ReplyKeyboardMarkup as RawReplyKeyboardMarkup
2123
from . import KeyboardButton
@@ -48,7 +50,7 @@ class ReplyKeyboardMarkup(PyrogramType):
4850
"""
4951

5052
def __init__(self,
51-
keyboard: list,
53+
keyboard: List[List[KeyboardButton]],
5254
resize_keyboard: bool = None,
5355
one_time_keyboard: bool = None,
5456
selective: bool = None):

pyrogram/client/types/messages_and_media/animation.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
from struct import pack
2020

21+
import pyrogram
2122
from pyrogram.api import types
2223
from .photo_size import PhotoSize
2324
from ..pyrogram_type import PyrogramType
@@ -58,12 +59,12 @@ class Animation(PyrogramType):
5859

5960
def __init__(self,
6061
*,
61-
client,
62+
client: "pyrogram.Client",
6263
file_id: str,
6364
width: int,
6465
height: int,
6566
duration: int,
66-
thumb=None,
67+
thumb: PhotoSize = None,
6768
file_name: str = None,
6869
mime_type: str = None,
6970
file_size: int = None,
@@ -82,7 +83,7 @@ def __init__(self,
8283

8384
@staticmethod
8485
def _parse(client, animation: types.Document, video_attributes: types.DocumentAttributeVideo,
85-
file_name: str) -> "Animation":
86+
file_name: str) -> "Animation":
8687
return Animation(
8788
file_id=encode(
8889
pack(

pyrogram/client/types/messages_and_media/audio.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
from struct import pack
2020

21+
import pyrogram
2122
from pyrogram.api import types
2223
from .photo_size import PhotoSize
2324
from ..pyrogram_type import PyrogramType
@@ -58,10 +59,10 @@ class Audio(PyrogramType):
5859

5960
def __init__(self,
6061
*,
61-
client,
62+
client: "pyrogram.Client",
6263
file_id: str,
6364
duration: int,
64-
thumb=None,
65+
thumb: PhotoSize = None,
6566
file_name: str = None,
6667
mime_type: str = None,
6768
file_size: int = None,
@@ -81,7 +82,8 @@ def __init__(self,
8182
self.title = title
8283

8384
@staticmethod
84-
def _parse(client, audio: types.Document, audio_attributes: types.DocumentAttributeAudio, file_name: str) -> "Audio":
85+
def _parse(client, audio: types.Document, audio_attributes: types.DocumentAttributeAudio,
86+
file_name: str) -> "Audio":
8587
return Audio(
8688
file_id=encode(
8789
pack(

pyrogram/client/types/messages_and_media/contact.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
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+
import pyrogram
20+
1921
from pyrogram.api import types
2022
from ..pyrogram_type import PyrogramType
2123

@@ -42,7 +44,7 @@ class Contact(PyrogramType):
4244

4345
def __init__(self,
4446
*,
45-
client,
47+
client: "pyrogram.Client",
4648
phone_number: str,
4749
first_name: str,
4850
last_name: str = None,

pyrogram/client/types/messages_and_media/document.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
from struct import pack
2020

21+
import pyrogram
2122
from pyrogram.api import types
2223
from .photo_size import PhotoSize
2324
from ..pyrogram_type import PyrogramType
@@ -49,9 +50,9 @@ class Document(PyrogramType):
4950

5051
def __init__(self,
5152
*,
52-
client,
53+
client: "pyrogram.Client",
5354
file_id: str,
54-
thumb=None,
55+
thumb: PhotoSize = None,
5556
file_name: str = None,
5657
mime_type: str = None,
5758
file_size: int = None,

pyrogram/client/types/messages_and_media/location.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
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+
import pyrogram
20+
1921
from pyrogram.api import types
2022
from ..pyrogram_type import PyrogramType
2123

@@ -31,7 +33,11 @@ class Location(PyrogramType):
3133
Latitude as defined by sender.
3234
"""
3335

34-
def __init__(self, *, client, longitude: float, latitude: float):
36+
def __init__(self,
37+
*,
38+
client: "pyrogram.Client",
39+
longitude: float,
40+
latitude: float):
3541
super().__init__(client)
3642

3743
self.longitude = longitude

pyrogram/client/types/messages_and_media/message.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ def __init__(self,
337337

338338
@staticmethod
339339
def _parse(client, message: types.Message or types.MessageService or types.MessageEmpty, users: dict, chats: dict,
340-
replies: int = 1):
340+
replies: int = 1):
341341
if isinstance(message, types.MessageEmpty):
342342
return Message(message_id=message.id, empty=True, client=client)
343343

pyrogram/client/types/messages_and_media/message_entity.py

Lines changed: 4 additions & 2 deletions

0 commit comments

Comments
 (0)