Skip to content

Commit b593463

Browse files
committed
Type hint all the remaining method parameters
1 parent 4fb9969 commit b593463

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+295
-139
lines changed

pyrogram/client/methods/bots/get_inline_bot_results.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@
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 Union
20+
1921
from pyrogram.api import functions, types
2022
from pyrogram.api.errors import UnknownError
2123
from pyrogram.client.ext import BaseClient
2224

2325

2426
class GetInlineBotResults(BaseClient):
2527
def get_inline_bot_results(self,
26-
bot: int or str,
28+
bot: Union[int, str],
2729
query: str,
2830
offset: str = "",
2931
latitude: float = None,

pyrogram/client/methods/bots/request_callback_answer.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@
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 Union
20+
1921
from pyrogram.api import functions
2022
from pyrogram.client.ext import BaseClient
2123

2224

2325
class RequestCallbackAnswer(BaseClient):
2426
def request_callback_answer(self,
25-
chat_id: int or str,
27+
chat_id: Union[int, str],
2628
message_id: int,
2729
callback_data: bytes):
2830
"""Use this method to request a callback answer from bots. This is the equivalent of clicking an

pyrogram/client/methods/bots/send_inline_bot_result.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@
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 Union
20+
1921
from pyrogram.api import functions
2022
from pyrogram.client.ext import BaseClient
2123

2224

2325
class SendInlineBotResult(BaseClient):
2426
def send_inline_bot_result(self,
25-
chat_id: int or str,
27+
chat_id: Union[int, str],
2628
query_id: int,
2729
result_id: str,
2830
disable_notification: bool = None,

pyrogram/client/methods/chats/delete_chat_photo.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@
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 Union
20+
1921
from pyrogram.api import functions, types
2022
from ...ext import BaseClient
2123

2224

2325
class DeleteChatPhoto(BaseClient):
24-
def delete_chat_photo(self, chat_id: int or str):
26+
def delete_chat_photo(self,
27+
chat_id: Union[int, str]):
2528
"""Use this method to delete a chat photo.
2629
Photos can't be changed for private chats.
2730
You must be an administrator in the chat for this to work and must have the appropriate admin rights.

pyrogram/client/methods/chats/export_chat_invite_link.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@
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 Union
20+
1921
from pyrogram.api import functions, types
2022
from ...ext import BaseClient
2123

2224

2325
class ExportChatInviteLink(BaseClient):
24-
def export_chat_invite_link(self, chat_id: int or str):
26+
def export_chat_invite_link(self,
27+
chat_id: Union[int, str]):
2528
"""Use this method to generate a new invite link for a chat; any previously generated link is revoked.
2629
2730
You must be an administrator in the chat for this to work and have the appropriate admin rights.

pyrogram/client/methods/chats/get_chat.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,16 @@
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 Union
20+
1921
import pyrogram
2022
from pyrogram.api import functions, types
2123
from ...ext import BaseClient
2224

2325

2426
class GetChat(BaseClient):
25-
def get_chat(self, chat_id: int or str):
27+
def get_chat(self,
28+
chat_id: Union[int, str]):
2629
"""Use this method to get up to date information about the chat (current name of the user for
2730
one-on-one conversations, current username of a user, group or channel, etc.)
2831
@@ -45,4 +48,4 @@ def get_chat(self, chat_id: int or str):
4548
else:
4649
r = self.send(functions.messages.GetFullChat(peer.chat_id))
4750

48-
return pyrogram.Chat.parse_full(self, r)
51+
return pyrogram.Chat._parse_full(self, r)

pyrogram/client/methods/chats/get_chat_member.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +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 Union
20+
1921
import pyrogram
2022
from pyrogram.api import functions, types, errors
2123
from ...ext import BaseClient
2224

2325

2426
class GetChatMember(BaseClient):
2527
def get_chat_member(self,
26-
chat_id: int or str,
27-
user_id: int or str):
28+
chat_id: Union[int, str],
29+
user_id: Union[int, str]):
2830
"""Use this method to get information about one member of a chat.
2931
3032
Args:
@@ -52,7 +54,7 @@ def get_chat_member(self,
5254
)
5355
)
5456

55-
for member in pyrogram.ChatMembers.parse(self, full_chat).chat_members:
57+
for member in pyrogram.ChatMembers._parse(self, full_chat).chat_members:
5658
if member.user.id == user_id.user_id:
5759
return member
5860
else:
@@ -65,7 +67,7 @@ def get_chat_member(self,
6567
)
6668
)
6769

68-
return pyrogram.ChatMembers.parse(
70+
return pyrogram.ChatMembers._parse(
6971
self,
7072
types.channels.ChannelParticipants(
7173
count=1,

pyrogram/client/methods/chats/get_chat_members.py

Lines changed: 5 additions & 3 deletions
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 Union
20+
1921
import pyrogram
2022
from pyrogram.api import functions, types
2123
from ...ext import BaseClient
@@ -32,7 +34,7 @@ class Filters:
3234

3335
class GetChatMembers(BaseClient):
3436
def get_chat_members(self,
35-
chat_id: int or str,
37+
chat_id: Union[int, str],
3638
offset: int = 0,
3739
limit: int = 200,
3840
query: str = "",
@@ -84,7 +86,7 @@ def get_chat_members(self,
8486
peer = self.resolve_peer(chat_id)
8587

8688
if isinstance(peer, types.InputPeerChat):
87-
return pyrogram.ChatMembers.parse(
89+
return pyrogram.ChatMembers._parse(
8890
self,
8991
self.send(
9092
functions.messages.GetFullChat(
@@ -110,7 +112,7 @@ def get_chat_members(self,
110112
else:
111113
raise ValueError("Invalid filter \"{}\"".format(filter))
112114

113-
return pyrogram.ChatMembers.parse(
115+
return pyrogram.ChatMembers._parse(
114116
self,
115117
self.send(
116118
functions.channels.GetParticipants(

pyrogram/client/methods/chats/get_chat_members_count.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@
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 Union
20+
1921
from pyrogram.api import functions, types
2022
from ...ext import BaseClient
2123

2224

2325
class GetChatMembersCount(BaseClient):
24-
def get_chat_members_count(self, chat_id: int or str):
26+
def get_chat_members_count(self,
27+
chat_id: Union[int, str]):
2528
"""Use this method to get the number of members in a chat.
2629
2730
Args:

pyrogram/client/methods/chats/get_dialogs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
class GetDialogs(BaseClient):
2525
def get_dialogs(self,
26-
offset_dialog=None,
26+
offset_dialog: "pyrogram.Dialog" = None,
2727
limit: int = 100,
2828
pinned_only: bool = False):
2929
"""Use this method to get the user's dialogs
@@ -64,4 +64,4 @@ def get_dialogs(self,
6464
)
6565
)
6666

67-
return pyrogram.Dialogs.parse(self, r)
67+
return pyrogram.Dialogs._parse(self, r)

0 commit comments

Comments
 (0)