Skip to content

Commit

Permalink
Change Union[type1, None] to Optional[type1]
Browse files Browse the repository at this point in the history
  • Loading branch information
alissonlauffer committed Nov 29, 2020
1 parent 1db4855 commit a26e648
Show file tree
Hide file tree
Showing 35 changed files with 89 additions and 89 deletions.
6 changes: 3 additions & 3 deletions pyrogram/client.py
Expand Up @@ -29,7 +29,7 @@
from hashlib import sha256
from importlib import import_module
from pathlib import Path
from typing import Union, List
from typing import Union, List, Optional

import pyrogram
from pyrogram import raw
Expand Down Expand Up @@ -396,7 +396,7 @@ def parse_mode(self):
return self._parse_mode

@parse_mode.setter
def parse_mode(self, parse_mode: Union[str, None] = "combined"):
def parse_mode(self, parse_mode: Optional[str] = "combined"):
if parse_mode not in self.PARSE_MODES:
raise ValueError('parse_mode must be one of {} or None. Not "{}"'.format(
", ".join(f'"{m}"' for m in self.PARSE_MODES[:-1]),
Expand All @@ -406,7 +406,7 @@ def parse_mode(self, parse_mode: Union[str, None] = "combined"):
self._parse_mode = parse_mode

# TODO: redundant, remove in next major version
def set_parse_mode(self, parse_mode: Union[str, None] = "combined"):
def set_parse_mode(self, parse_mode: Optional[str] = "combined"):
"""Set the parse mode to be used globally by the client.
When setting the parse mode with this method, all other methods having a *parse_mode* parameter will follow the
Expand Down
4 changes: 2 additions & 2 deletions pyrogram/methods/chats/set_slow_mode.py
Expand Up @@ -16,7 +16,7 @@
# 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 Union
from typing import Union, Optional

from pyrogram import raw
from pyrogram.scaffold import Scaffold
Expand All @@ -26,7 +26,7 @@ class SetSlowMode(Scaffold):
async def set_slow_mode(
self,
chat_id: Union[int, str],
seconds: Union[int, None]
seconds: Optional[int]
) -> bool:
"""Set the slow mode interval for a chat.
Expand Down
4 changes: 2 additions & 2 deletions pyrogram/methods/chats/update_chat_username.py
Expand Up @@ -16,7 +16,7 @@
# 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 Union
from typing import Union, Optional

from pyrogram import raw
from pyrogram.scaffold import Scaffold
Expand All @@ -26,7 +26,7 @@ class UpdateChatUsername(Scaffold):
async def update_chat_username(
self,
chat_id: Union[int, str],
username: Union[str, None]
username: Optional[str]
) -> bool:
"""Update a channel or a supergroup username.
Expand Down
4 changes: 2 additions & 2 deletions pyrogram/methods/messages/download_media.py
Expand Up @@ -20,7 +20,7 @@
import os
import time
from datetime import datetime
from typing import Union
from typing import Union, Optional

from pyrogram import types
from pyrogram.file_id import FileId, FileType, PHOTO_TYPES
Expand All @@ -37,7 +37,7 @@ async def download_media(
block: bool = True,
progress: callable = None,
progress_args: tuple = ()
) -> Union[str, None]:
) -> Optional[str]:
"""Download the media from a message.
Parameters:
Expand Down
4 changes: 2 additions & 2 deletions pyrogram/methods/messages/edit_inline_caption.py
Expand Up @@ -16,7 +16,7 @@
# 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 Union
from typing import Optional

from pyrogram import types
from pyrogram.scaffold import Scaffold
Expand All @@ -27,7 +27,7 @@ async def edit_inline_caption(
self,
inline_message_id: str,
caption: str,
parse_mode: Union[str, None] = object,
parse_mode: Optional[str] = object,
reply_markup: "types.InlineKeyboardMarkup" = None
) -> bool:
"""Edit the caption of inline media messages.
Expand Down
4 changes: 2 additions & 2 deletions pyrogram/methods/messages/edit_inline_text.py
Expand Up @@ -16,7 +16,7 @@
# 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 Union
from typing import Optional

from pyrogram import raw
from pyrogram import types
Expand All @@ -30,7 +30,7 @@ async def edit_inline_text(
self,
inline_message_id: str,
text: str,
parse_mode: Union[str, None] = object,
parse_mode: Optional[str] = object,
disable_web_page_preview: bool = None,
reply_markup: "types.InlineKeyboardMarkup" = None
) -> bool:
Expand Down
4 changes: 2 additions & 2 deletions pyrogram/methods/messages/edit_message_caption.py
Expand Up @@ -16,7 +16,7 @@
# 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 Union, List
from typing import Union, List, Optional

from pyrogram import types
from pyrogram.scaffold import Scaffold
Expand All @@ -28,7 +28,7 @@ async def edit_message_caption(
chat_id: Union[int, str],
message_id: int,
caption: str,
parse_mode: Union[str, None] = object,
parse_mode: Optional[str] = object,
caption_entities: List["types.MessageEntity"] = None,
reply_markup: "types.InlineKeyboardMarkup" = None
) -> "types.Message":
Expand Down
4 changes: 2 additions & 2 deletions pyrogram/methods/messages/edit_message_text.py
Expand Up @@ -16,7 +16,7 @@
# 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 Union, List
from typing import Union, List, Optional

from pyrogram import raw
from pyrogram import types
Expand All @@ -30,7 +30,7 @@ async def edit_message_text(
chat_id: Union[int, str],
message_id: int,
text: str,
parse_mode: Union[str, None] = object,
parse_mode: Optional[str] = object,
entities: List["types.MessageEntity"] = None,
disable_web_page_preview: bool = None,
reply_markup: "types.InlineKeyboardMarkup" = None
Expand Down
6 changes: 3 additions & 3 deletions pyrogram/methods/messages/send_animation.py
Expand Up @@ -18,7 +18,7 @@

import os
import re
from typing import Union, BinaryIO, List
from typing import Union, BinaryIO, List, Optional

from pyrogram import StopTransmission
from pyrogram import raw
Expand All @@ -36,7 +36,7 @@ async def send_animation(
animation: Union[str, BinaryIO],
caption: str = "",
unsave: bool = False,
parse_mode: Union[str, None] = object,
parse_mode: Optional[str] = object,
caption_entities: List["types.MessageEntity"] = None,
duration: int = 0,
width: int = 0,
Expand All @@ -54,7 +54,7 @@ async def send_animation(
] = None,
progress: callable = None,
progress_args: tuple = ()
) -> Union["types.Message", None]:
) -> Optional["types.Message"]:
"""Send animation files (animation or H.264/MPEG-4 AVC video without sound).
Parameters:
Expand Down
6 changes: 3 additions & 3 deletions pyrogram/methods/messages/send_audio.py
Expand Up @@ -18,7 +18,7 @@

import os
import re
from typing import Union, BinaryIO, List
from typing import Union, BinaryIO, List, Optional

from pyrogram import StopTransmission
from pyrogram import raw
Expand All @@ -35,7 +35,7 @@ async def send_audio(
chat_id: Union[int, str],
audio: Union[str, BinaryIO],
caption: str = "",
parse_mode: Union[str, None] = object,
parse_mode: Optional[str] = object,
caption_entities: List["types.MessageEntity"] = None,
duration: int = 0,
performer: str = None,
Expand All @@ -53,7 +53,7 @@ async def send_audio(
] = None,
progress: callable = None,
progress_args: tuple = ()
) -> Union["types.Message", None]:
) -> Optional["types.Message"]:
"""Send audio files.
For sending voice messages, use the :meth:`~pyrogram.Client.send_voice` method instead.
Expand Down
6 changes: 3 additions & 3 deletions pyrogram/methods/messages/send_cached_media.py
Expand Up @@ -16,7 +16,7 @@
# 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 Union
from typing import Union, Optional

from pyrogram import raw
from pyrogram import types
Expand All @@ -30,7 +30,7 @@ async def send_cached_media(
chat_id: Union[int, str],
file_id: str,
caption: str = "",
parse_mode: Union[str, None] = object,
parse_mode: Optional[str] = object,
disable_notification: bool = None,
reply_to_message_id: int = None,
schedule_date: int = None,
Expand All @@ -40,7 +40,7 @@ async def send_cached_media(
"types.ReplyKeyboardRemove",
"types.ForceReply"
] = None
) -> Union["types.Message", None]:
) -> Optional["types.Message"]:
"""Send any media stored on the Telegram servers using a file_id.
This convenience method works with any valid file_id only.
Expand Down
4 changes: 2 additions & 2 deletions pyrogram/methods/messages/send_dice.py
Expand Up @@ -16,7 +16,7 @@
# 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 Union
from typing import Union, Optional

from pyrogram import raw
from pyrogram import types
Expand All @@ -37,7 +37,7 @@ async def send_dice(
"types.ReplyKeyboardRemove",
"types.ForceReply"
] = None
) -> Union["types.Message", None]:
) -> Optional["types.Message"]:
"""Send a dice with a random value from 1 to 6.
Parameters:
Expand Down
6 changes: 3 additions & 3 deletions pyrogram/methods/messages/send_document.py
Expand Up @@ -18,7 +18,7 @@

import os
import re
from typing import Union, BinaryIO, List
from typing import Union, BinaryIO, List, Optional

from pyrogram import StopTransmission
from pyrogram import raw
Expand All @@ -36,7 +36,7 @@ async def send_document(
document: Union[str, BinaryIO],
thumb: Union[str, BinaryIO] = None,
caption: str = "",
parse_mode: Union[str, None] = object,
parse_mode: Optional[str] = object,
caption_entities: List["types.MessageEntity"] = None,
file_name: str = None,
force_document: bool = None,
Expand All @@ -51,7 +51,7 @@ async def send_document(
] = None,
progress: callable = None,
progress_args: tuple = ()
) -> Union["types.Message", None]:
) -> Optional["types.Message"]:
"""Send generic files.
Parameters:
Expand Down
4 changes: 2 additions & 2 deletions pyrogram/methods/messages/send_message.py
Expand Up @@ -16,7 +16,7 @@
# 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 Union, List
from typing import Union, List, Optional

from pyrogram import raw, utils
from pyrogram import types
Expand All @@ -28,7 +28,7 @@ async def send_message(
self,
chat_id: Union[int, str],
text: str,
parse_mode: Union[str, None] = object,
parse_mode: Optional[str] = object,
entities: List["types.MessageEntity"] = None,
disable_web_page_preview: bool = None,
disable_notification: bool = None,
Expand Down
6 changes: 3 additions & 3 deletions pyrogram/methods/messages/send_photo.py
Expand Up @@ -18,7 +18,7 @@

import os
import re
from typing import Union, BinaryIO, List
from typing import Union, BinaryIO, List, Optional

import pyrogram
from pyrogram import raw
Expand All @@ -35,7 +35,7 @@ async def send_photo(
chat_id: Union[int, str],
photo: Union[str, BinaryIO],
caption: str = "",
parse_mode: Union[str, None] = object,
parse_mode: Optional[str] = object,
caption_entities: List["types.MessageEntity"] = None,
ttl_seconds: int = None,
disable_notification: bool = None,
Expand All @@ -49,7 +49,7 @@ async def send_photo(
] = None,
progress: callable = None,
progress_args: tuple = ()
) -> Union["types.Message", None]:
) -> Optional["types.Message"]:
"""Send photos.
Parameters:
Expand Down
4 changes: 2 additions & 2 deletions pyrogram/methods/messages/send_sticker.py
Expand Up @@ -18,7 +18,7 @@

import os
import re
from typing import Union, BinaryIO
from typing import Union, BinaryIO, Optional

from pyrogram import StopTransmission
from pyrogram import raw
Expand All @@ -45,7 +45,7 @@ async def send_sticker(
] = None,
progress: callable = None,
progress_args: tuple = ()
) -> Union["types.Message", None]:
) -> Optional["types.Message"]:
"""Send static .webp or animated .tgs stickers.
Parameters:
Expand Down
6 changes: 3 additions & 3 deletions pyrogram/methods/messages/send_video.py
Expand Up @@ -18,7 +18,7 @@

import os
import re
from typing import Union, BinaryIO, List
from typing import Union, BinaryIO, List, Optional

from pyrogram import StopTransmission
from pyrogram import raw
Expand All @@ -35,7 +35,7 @@ async def send_video(
chat_id: Union[int, str],
video: Union[str, BinaryIO],
caption: str = "",
parse_mode: Union[str, None] = object,
parse_mode: Optional[str] = object,
caption_entities: List["types.MessageEntity"] = None,
duration: int = 0,
width: int = 0,
Expand All @@ -54,7 +54,7 @@ async def send_video(
] = None,
progress: callable = None,
progress_args: tuple = ()
) -> Union["types.Message", None]:
) -> Optional["types.Message"]:
"""Send video files.
Parameters:
Expand Down
4 changes: 2 additions & 2 deletions pyrogram/methods/messages/send_video_note.py
Expand Up @@ -17,7 +17,7 @@
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.

import os
from typing import Union, BinaryIO
from typing import Union, BinaryIO, Optional

from pyrogram import StopTransmission
from pyrogram import raw
Expand Down Expand Up @@ -47,7 +47,7 @@ async def send_video_note(
] = None,
progress: callable = None,
progress_args: tuple = ()
) -> Union["types.Message", None]:
) -> Optional["types.Message"]:
"""Send video messages.
Parameters:
Expand Down

0 comments on commit a26e648

Please sign in to comment.