Fix Python 3.5.2 type hinting (#1177)

This commit is contained in:
Lonami Exo 2019-06-28 21:25:56 +02:00
parent 7249d01709
commit 8c771a842f

View File

@ -33,9 +33,6 @@ TotalList = helpers.TotalList
DateLike = typing.Optional[typing.Union[float, datetime.datetime, datetime.date, datetime.timedelta]]
# Note: we can't use `io.BytesIO` directly due to a bug in
# Python 3.5.2's `typing`: https://github.com/python/typing/issues/266
LocalPath = str
ExternalUrl = str
BotFileID = str
@ -50,11 +47,19 @@ FileLike = typing.Union[
types.TypeInputFileLocation
]
OutFileLike = typing.Union[
str,
typing.Type[bytes],
typing.BinaryIO
]
# Can't use `typing.Type` in Python 3.5.2
# See https://github.com/python/typing/issues/266
try:
OutFileLike = typing.Union[
str,
typing.Type[bytes],
typing.BinaryIO
]
except TypeError:
OutFileLike = typing.Union[
str,
typing.BinaryIO
]
MessageLike = typing.Union[str, types.Message]
MessageIDLike = typing.Union[int, types.Message, types.TypeInputMessage]