mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-16 12:51:18 +00:00
Reformat code
This commit is contained in:
parent
c3470b2713
commit
def3bdaa63
@ -171,8 +171,8 @@ def start():
|
|||||||
shutil.rmtree("{}/functions".format(DESTINATION), ignore_errors=True)
|
shutil.rmtree("{}/functions".format(DESTINATION), ignore_errors=True)
|
||||||
|
|
||||||
with open("{}/source/auth_key.tl".format(HOME), encoding="utf-8") as auth, \
|
with open("{}/source/auth_key.tl".format(HOME), encoding="utf-8") as auth, \
|
||||||
open("{}/source/sys_msgs.tl".format(HOME), encoding="utf-8") as system, \
|
open("{}/source/sys_msgs.tl".format(HOME), encoding="utf-8") as system, \
|
||||||
open("{}/source/main_api.tl".format(HOME), encoding="utf-8") as api:
|
open("{}/source/main_api.tl".format(HOME), encoding="utf-8") as api:
|
||||||
schema = (auth.read() + system.read() + api.read()).splitlines()
|
schema = (auth.read() + system.read() + api.read()).splitlines()
|
||||||
|
|
||||||
with open("{}/template/mtproto.txt".format(HOME), encoding="utf-8") as f:
|
with open("{}/template/mtproto.txt".format(HOME), encoding="utf-8") as f:
|
||||||
|
@ -73,7 +73,7 @@ def start():
|
|||||||
f_init.write("from .{}_{} import *\n".format(name.lower(), code))
|
f_init.write("from .{}_{} import *\n".format(name.lower(), code))
|
||||||
|
|
||||||
with open("{}/source/{}".format(HOME, i), encoding="utf-8") as f_csv, \
|
with open("{}/source/{}".format(HOME, i), encoding="utf-8") as f_csv, \
|
||||||
open("{}/{}_{}.py".format(DEST, name.lower(), code), "w", encoding="utf-8") as f_class:
|
open("{}/{}_{}.py".format(DEST, name.lower(), code), "w", encoding="utf-8") as f_class:
|
||||||
reader = csv.reader(f_csv, delimiter="\t")
|
reader = csv.reader(f_csv, delimiter="\t")
|
||||||
|
|
||||||
super_class = caml(name)
|
super_class = caml(name)
|
||||||
|
@ -25,16 +25,16 @@ from ...types.user_and_chats import Chat
|
|||||||
|
|
||||||
class RestrictChat(BaseClient):
|
class RestrictChat(BaseClient):
|
||||||
def restrict_chat(
|
def restrict_chat(
|
||||||
self,
|
self,
|
||||||
chat_id: Union[int, str],
|
chat_id: Union[int, str],
|
||||||
can_send_messages: bool = False,
|
can_send_messages: bool = False,
|
||||||
can_send_media_messages: bool = False,
|
can_send_media_messages: bool = False,
|
||||||
can_send_other_messages: bool = False,
|
can_send_other_messages: bool = False,
|
||||||
can_add_web_page_previews: bool = False,
|
can_add_web_page_previews: bool = False,
|
||||||
can_send_polls: bool = False,
|
can_send_polls: bool = False,
|
||||||
can_change_info: bool = False,
|
can_change_info: bool = False,
|
||||||
can_invite_users: bool = False,
|
can_invite_users: bool = False,
|
||||||
can_pin_messages: bool = False
|
can_pin_messages: bool = False
|
||||||
) -> Chat:
|
) -> Chat:
|
||||||
"""Use this method to restrict a chat.
|
"""Use this method to restrict a chat.
|
||||||
Pass True for all boolean parameters to lift restrictions from a chat.
|
Pass True for all boolean parameters to lift restrictions from a chat.
|
||||||
|
@ -25,18 +25,18 @@ from ...types.user_and_chats import Chat
|
|||||||
|
|
||||||
class RestrictChatMember(BaseClient):
|
class RestrictChatMember(BaseClient):
|
||||||
def restrict_chat_member(
|
def restrict_chat_member(
|
||||||
self,
|
self,
|
||||||
chat_id: Union[int, str],
|
chat_id: Union[int, str],
|
||||||
user_id: Union[int, str],
|
user_id: Union[int, str],
|
||||||
until_date: int = 0,
|
until_date: int = 0,
|
||||||
can_send_messages: bool = False,
|
can_send_messages: bool = False,
|
||||||
can_send_media_messages: bool = False,
|
can_send_media_messages: bool = False,
|
||||||
can_send_other_messages: bool = False,
|
can_send_other_messages: bool = False,
|
||||||
can_add_web_page_previews: bool = False,
|
can_add_web_page_previews: bool = False,
|
||||||
can_send_polls: bool = False,
|
can_send_polls: bool = False,
|
||||||
can_change_info: bool = False,
|
can_change_info: bool = False,
|
||||||
can_invite_users: bool = False,
|
can_invite_users: bool = False,
|
||||||
can_pin_messages: bool = False
|
can_pin_messages: bool = False
|
||||||
) -> Chat:
|
) -> Chat:
|
||||||
"""Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for
|
"""Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for
|
||||||
this to work and must have the appropriate admin rights. Pass True for all boolean parameters to lift
|
this to work and must have the appropriate admin rights. Pass True for all boolean parameters to lift
|
||||||
|
@ -45,7 +45,7 @@ class UpdateChatUsername(BaseClient):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
peer = self.resolve_peer(chat_id)
|
peer = self.resolve_peer(chat_id)
|
||||||
|
|
||||||
if isinstance(peer, types.InputPeerChannel):
|
if isinstance(peer, types.InputPeerChannel):
|
||||||
return bool(
|
return bool(
|
||||||
self.send(
|
self.send(
|
||||||
|
@ -106,15 +106,15 @@ class DownloadMedia(BaseClient):
|
|||||||
else:
|
else:
|
||||||
raise ValueError(error_message)
|
raise ValueError(error_message)
|
||||||
elif isinstance(message, (
|
elif isinstance(message, (
|
||||||
pyrogram.Photo,
|
pyrogram.Photo,
|
||||||
pyrogram.PhotoSize,
|
pyrogram.PhotoSize,
|
||||||
pyrogram.Audio,
|
pyrogram.Audio,
|
||||||
pyrogram.Document,
|
pyrogram.Document,
|
||||||
pyrogram.Video,
|
pyrogram.Video,
|
||||||
pyrogram.Voice,
|
pyrogram.Voice,
|
||||||
pyrogram.VideoNote,
|
pyrogram.VideoNote,
|
||||||
pyrogram.Sticker,
|
pyrogram.Sticker,
|
||||||
pyrogram.Animation
|
pyrogram.Animation
|
||||||
)):
|
)):
|
||||||
if isinstance(message, pyrogram.Photo):
|
if isinstance(message, pyrogram.Photo):
|
||||||
media = pyrogram.Document(
|
media = pyrogram.Document(
|
||||||
|
@ -28,19 +28,19 @@ from pyrogram.client.ext import BaseClient, utils
|
|||||||
|
|
||||||
class SendCachedMedia(BaseClient):
|
class SendCachedMedia(BaseClient):
|
||||||
def send_cached_media(
|
def send_cached_media(
|
||||||
self,
|
self,
|
||||||
chat_id: Union[int, str],
|
chat_id: Union[int, str],
|
||||||
file_id: str,
|
file_id: str,
|
||||||
caption: str = "",
|
caption: str = "",
|
||||||
parse_mode: str = "",
|
parse_mode: str = "",
|
||||||
disable_notification: bool = None,
|
disable_notification: bool = None,
|
||||||
reply_to_message_id: int = None,
|
reply_to_message_id: int = None,
|
||||||
reply_markup: Union[
|
reply_markup: Union[
|
||||||
"pyrogram.InlineKeyboardMarkup",
|
"pyrogram.InlineKeyboardMarkup",
|
||||||
"pyrogram.ReplyKeyboardMarkup",
|
"pyrogram.ReplyKeyboardMarkup",
|
||||||
"pyrogram.ReplyKeyboardRemove",
|
"pyrogram.ReplyKeyboardRemove",
|
||||||
"pyrogram.ForceReply"
|
"pyrogram.ForceReply"
|
||||||
] = None
|
] = None
|
||||||
) -> Union["pyrogram.Message", None]:
|
) -> Union["pyrogram.Message", None]:
|
||||||
"""Use this method to send any media stored on the Telegram servers using a file_id.
|
"""Use this method to send any media stored on the Telegram servers using a file_id.
|
||||||
|
|
||||||
|
@ -21,7 +21,6 @@ from typing import List
|
|||||||
import pyrogram
|
import pyrogram
|
||||||
from pyrogram.api import types
|
from pyrogram.api import types
|
||||||
from .chat_member import ChatMember
|
from .chat_member import ChatMember
|
||||||
from .user import User
|
|
||||||
from ..pyrogram_type import PyrogramType
|
from ..pyrogram_type import PyrogramType
|
||||||
|
|
||||||
|
|
||||||
|
@ -95,27 +95,27 @@ class ChatPermissions(PyrogramType):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
*,
|
*,
|
||||||
until_date: int = None,
|
until_date: int = None,
|
||||||
|
|
||||||
# Admin permissions
|
# Admin permissions
|
||||||
can_be_edited: bool = None,
|
can_be_edited: bool = None,
|
||||||
can_change_info: bool = None,
|
can_change_info: bool = None,
|
||||||
can_post_messages: bool = None, # Channels only
|
can_post_messages: bool = None, # Channels only
|
||||||
can_edit_messages: bool = None, # Channels only
|
can_edit_messages: bool = None, # Channels only
|
||||||
can_delete_messages: bool = None,
|
can_delete_messages: bool = None,
|
||||||
can_restrict_members: bool = None,
|
can_restrict_members: bool = None,
|
||||||
can_invite_users: bool = None,
|
can_invite_users: bool = None,
|
||||||
can_pin_messages: bool = None, # Supergroups only
|
can_pin_messages: bool = None, # Supergroups only
|
||||||
can_promote_members: bool = None,
|
can_promote_members: bool = None,
|
||||||
|
|
||||||
# Restricted user permissions
|
# Restricted user permissions
|
||||||
can_send_messages: bool = None, # Text, contacts, locations and venues
|
can_send_messages: bool = None, # Text, contacts, locations and venues
|
||||||
can_send_media_messages: bool = None, # Audios, documents, photos, videos, video notes and voice notes
|
can_send_media_messages: bool = None, # Audios, documents, photos, videos, video notes and voice notes
|
||||||
can_send_other_messages: bool = None, # Animations (GIFs), games, stickers, inline bot results
|
can_send_other_messages: bool = None, # Animations (GIFs), games, stickers, inline bot results
|
||||||
can_add_web_page_previews: bool = None,
|
can_add_web_page_previews: bool = None,
|
||||||
can_send_polls: bool = None
|
can_send_polls: bool = None
|
||||||
):
|
):
|
||||||
super().__init__(None)
|
super().__init__(None)
|
||||||
|
|
||||||
@ -139,11 +139,11 @@ class ChatPermissions(PyrogramType):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse(
|
def _parse(
|
||||||
entity: Union[
|
entity: Union[
|
||||||
types.ChannelParticipantAdmin,
|
types.ChannelParticipantAdmin,
|
||||||
types.ChannelParticipantBanned,
|
types.ChannelParticipantBanned,
|
||||||
types.ChatBannedRights
|
types.ChatBannedRights
|
||||||
]
|
]
|
||||||
) -> "ChatPermissions":
|
) -> "ChatPermissions":
|
||||||
if isinstance(entity, types.ChannelParticipantAdmin):
|
if isinstance(entity, types.ChannelParticipantAdmin):
|
||||||
permissions = entity.admin_rights
|
permissions = entity.admin_rights
|
||||||
@ -171,8 +171,8 @@ class ChatPermissions(PyrogramType):
|
|||||||
can_send_messages=not denied_permissions.send_messages,
|
can_send_messages=not denied_permissions.send_messages,
|
||||||
can_send_media_messages=not denied_permissions.send_media,
|
can_send_media_messages=not denied_permissions.send_media,
|
||||||
can_send_other_messages=(
|
can_send_other_messages=(
|
||||||
not denied_permissions.send_stickers or not denied_permissions.send_gifs or
|
not denied_permissions.send_stickers or not denied_permissions.send_gifs or
|
||||||
not denied_permissions.send_games or not denied_permissions.send_inline
|
not denied_permissions.send_games or not denied_permissions.send_inline
|
||||||
),
|
),
|
||||||
can_add_web_page_previews=not denied_permissions.embed_links,
|
can_add_web_page_previews=not denied_permissions.embed_links,
|
||||||
can_send_polls=not denied_permissions.send_polls,
|
can_send_polls=not denied_permissions.send_polls,
|
||||||
|
@ -40,9 +40,7 @@ class TCPAbridgedO(TCP):
|
|||||||
while True:
|
while True:
|
||||||
nonce = bytearray(os.urandom(64))
|
nonce = bytearray(os.urandom(64))
|
||||||
|
|
||||||
if (nonce[0] != b"\xef"
|
if nonce[0] != b"\xef" and nonce[:4] not in self.RESERVED and nonce[4:4] != b"\x00" * 4:
|
||||||
and nonce[:4] not in self.RESERVED
|
|
||||||
and nonce[4:4] != b"\x00" * 4):
|
|
||||||
nonce[56] = nonce[57] = nonce[58] = nonce[59] = 0xef
|
nonce[56] = nonce[57] = nonce[58] = nonce[59] = 0xef
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -41,9 +41,7 @@ class TCPIntermediateO(TCP):
|
|||||||
while True:
|
while True:
|
||||||
nonce = bytearray(os.urandom(64))
|
nonce = bytearray(os.urandom(64))
|
||||||
|
|
||||||
if (nonce[0] != b"\xef"
|
if nonce[0] != b"\xef" and nonce[:4] not in self.RESERVED and nonce[4:4] != b"\x00" * 4:
|
||||||
and nonce[:4] not in self.RESERVED
|
|
||||||
and nonce[4:4] != b"\x00" * 4):
|
|
||||||
nonce[56] = nonce[57] = nonce[58] = nonce[59] = 0xee
|
nonce[56] = nonce[57] = nonce[58] = nonce[59] = 0xee
|
||||||
break
|
break
|
||||||
|
|
||||||
|
83
pyrogram/vendor/typing/typing.py
vendored
83
pyrogram/vendor/typing/typing.py
vendored
@ -1,17 +1,18 @@
|
|||||||
import abc
|
import abc
|
||||||
from abc import abstractmethod, abstractproperty
|
|
||||||
import collections
|
import collections
|
||||||
import contextlib
|
import contextlib
|
||||||
import functools
|
import functools
|
||||||
import re as stdlib_re # Avoid confusion with the re we export.
|
import re as stdlib_re # Avoid confusion with the re we export.
|
||||||
import sys
|
import sys
|
||||||
import types
|
import types
|
||||||
|
from abc import abstractmethod, abstractproperty
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import collections.abc as collections_abc
|
import collections.abc as collections_abc
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import collections as collections_abc # Fallback for PY3.2.
|
import collections as collections_abc # Fallback for PY3.2.
|
||||||
if sys.version_info[:2] >= (3, 6):
|
if sys.version_info[:2] >= (3, 6):
|
||||||
import _collections_abc # Needed for private function _check_methods # noqa
|
pass
|
||||||
try:
|
try:
|
||||||
from types import WrapperDescriptorType, MethodWrapperType, MethodDescriptorType
|
from types import WrapperDescriptorType, MethodWrapperType, MethodDescriptorType
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@ -19,7 +20,6 @@ except ImportError:
|
|||||||
MethodWrapperType = type(object().__str__)
|
MethodWrapperType = type(object().__str__)
|
||||||
MethodDescriptorType = type(str.join)
|
MethodDescriptorType = type(str.join)
|
||||||
|
|
||||||
|
|
||||||
# Please keep __all__ alphabetized within each category.
|
# Please keep __all__ alphabetized within each category.
|
||||||
__all__ = [
|
__all__ = [
|
||||||
# Super-special typing primitives.
|
# Super-special typing primitives.
|
||||||
@ -36,7 +36,7 @@ __all__ = [
|
|||||||
# ABCs (from collections.abc).
|
# ABCs (from collections.abc).
|
||||||
'AbstractSet', # collections.abc.Set.
|
'AbstractSet', # collections.abc.Set.
|
||||||
'GenericMeta', # subclass of abc.ABCMeta and a metaclass
|
'GenericMeta', # subclass of abc.ABCMeta and a metaclass
|
||||||
# for 'Generic' and ABCs below.
|
# for 'Generic' and ABCs below.
|
||||||
'ByteString',
|
'ByteString',
|
||||||
'Container',
|
'Container',
|
||||||
'ContextManager',
|
'ContextManager',
|
||||||
@ -96,6 +96,7 @@ __all__ = [
|
|||||||
'TYPE_CHECKING',
|
'TYPE_CHECKING',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
# The pseudo-submodules 're' and 'io' are part of the public
|
# The pseudo-submodules 're' and 'io' are part of the public
|
||||||
# namespace, but excluded from __all__ because they might stomp on
|
# namespace, but excluded from __all__ because they might stomp on
|
||||||
# legitimate imports of those modules.
|
# legitimate imports of those modules.
|
||||||
@ -173,8 +174,8 @@ class _TypingBase(metaclass=TypingMeta, _root=True):
|
|||||||
someone tries to subclass a special typing object (not a good idea).
|
someone tries to subclass a special typing object (not a good idea).
|
||||||
"""
|
"""
|
||||||
if (len(args) == 3 and
|
if (len(args) == 3 and
|
||||||
isinstance(args[0], str) and
|
isinstance(args[0], str) and
|
||||||
isinstance(args[1], tuple)):
|
isinstance(args[1], tuple)):
|
||||||
# Close enough.
|
# Close enough.
|
||||||
raise TypeError("Cannot subclass %r" % cls)
|
raise TypeError("Cannot subclass %r" % cls)
|
||||||
return super().__new__(cls)
|
return super().__new__(cls)
|
||||||
@ -396,7 +397,7 @@ def _type_repr(obj):
|
|||||||
return _qualname(obj)
|
return _qualname(obj)
|
||||||
return '%s.%s' % (obj.__module__, _qualname(obj))
|
return '%s.%s' % (obj.__module__, _qualname(obj))
|
||||||
if obj is ...:
|
if obj is ...:
|
||||||
return('...')
|
return ('...')
|
||||||
if isinstance(obj, types.FunctionType):
|
if isinstance(obj, types.FunctionType):
|
||||||
return obj.__name__
|
return obj.__name__
|
||||||
return repr(obj)
|
return repr(obj)
|
||||||
@ -681,6 +682,7 @@ def _tp_cache(func):
|
|||||||
except TypeError:
|
except TypeError:
|
||||||
pass # All real errors (not unhashable args) are raised below.
|
pass # All real errors (not unhashable args) are raised below.
|
||||||
return func(*args, **kwds)
|
return func(*args, **kwds)
|
||||||
|
|
||||||
return inner
|
return inner
|
||||||
|
|
||||||
|
|
||||||
@ -948,7 +950,7 @@ class GenericMeta(TypingMeta, abc.ABCMeta):
|
|||||||
if base is Generic:
|
if base is Generic:
|
||||||
raise TypeError("Cannot inherit from plain Generic")
|
raise TypeError("Cannot inherit from plain Generic")
|
||||||
if (isinstance(base, GenericMeta) and
|
if (isinstance(base, GenericMeta) and
|
||||||
base.__origin__ is Generic):
|
base.__origin__ is Generic):
|
||||||
if gvars is not None:
|
if gvars is not None:
|
||||||
raise TypeError(
|
raise TypeError(
|
||||||
"Cannot inherit from Generic[...] multiple types.")
|
"Cannot inherit from Generic[...] multiple types.")
|
||||||
@ -1183,14 +1185,14 @@ def _generic_new(base_cls, cls, *args, **kwds):
|
|||||||
# but attempt to store it in __orig_class__
|
# but attempt to store it in __orig_class__
|
||||||
if cls.__origin__ is None:
|
if cls.__origin__ is None:
|
||||||
if (base_cls.__new__ is object.__new__ and
|
if (base_cls.__new__ is object.__new__ and
|
||||||
cls.__init__ is not object.__init__):
|
cls.__init__ is not object.__init__):
|
||||||
return base_cls.__new__(cls)
|
return base_cls.__new__(cls)
|
||||||
else:
|
else:
|
||||||
return base_cls.__new__(cls, *args, **kwds)
|
return base_cls.__new__(cls, *args, **kwds)
|
||||||
else:
|
else:
|
||||||
origin = cls._gorg
|
origin = cls._gorg
|
||||||
if (base_cls.__new__ is object.__new__ and
|
if (base_cls.__new__ is object.__new__ and
|
||||||
cls.__init__ is not object.__init__):
|
cls.__init__ is not object.__init__):
|
||||||
obj = base_cls.__new__(origin)
|
obj = base_cls.__new__(origin)
|
||||||
else:
|
else:
|
||||||
obj = base_cls.__new__(origin, *args, **kwds)
|
obj = base_cls.__new__(origin, *args, **kwds)
|
||||||
@ -1399,7 +1401,7 @@ class _ClassVar(_FinalTypingBase, _root=True):
|
|||||||
cls = type(self)
|
cls = type(self)
|
||||||
if self.__type__ is None:
|
if self.__type__ is None:
|
||||||
return cls(_type_check(item,
|
return cls(_type_check(item,
|
||||||
'{} accepts only single type.'.format(cls.__name__[1:])),
|
'{} accepts only single type.'.format(cls.__name__[1:])),
|
||||||
_root=True)
|
_root=True)
|
||||||
raise TypeError('{} cannot be further subscripted'
|
raise TypeError('{} cannot be further subscripted'
|
||||||
.format(cls.__name__[1:]))
|
.format(cls.__name__[1:]))
|
||||||
@ -1671,26 +1673,26 @@ class _ProtocolMeta(GenericMeta):
|
|||||||
# Include attributes not defined in any non-protocol bases.
|
# Include attributes not defined in any non-protocol bases.
|
||||||
for c in self.__mro__:
|
for c in self.__mro__:
|
||||||
if (c is not base and attr in c.__dict__ and
|
if (c is not base and attr in c.__dict__ and
|
||||||
not getattr(c, '_is_protocol', False)):
|
not getattr(c, '_is_protocol', False)):
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
if (not attr.startswith('_abc_') and
|
if (not attr.startswith('_abc_') and
|
||||||
attr != '__abstractmethods__' and
|
attr != '__abstractmethods__' and
|
||||||
attr != '__annotations__' and
|
attr != '__annotations__' and
|
||||||
attr != '__weakref__' and
|
attr != '__weakref__' and
|
||||||
attr != '_is_protocol' and
|
attr != '_is_protocol' and
|
||||||
attr != '_gorg' and
|
attr != '_gorg' and
|
||||||
attr != '__dict__' and
|
attr != '__dict__' and
|
||||||
attr != '__args__' and
|
attr != '__args__' and
|
||||||
attr != '__slots__' and
|
attr != '__slots__' and
|
||||||
attr != '_get_protocol_attrs' and
|
attr != '_get_protocol_attrs' and
|
||||||
attr != '__next_in_mro__' and
|
attr != '__next_in_mro__' and
|
||||||
attr != '__parameters__' and
|
attr != '__parameters__' and
|
||||||
attr != '__origin__' and
|
attr != '__origin__' and
|
||||||
attr != '__orig_bases__' and
|
attr != '__orig_bases__' and
|
||||||
attr != '__extra__' and
|
attr != '__extra__' and
|
||||||
attr != '__tree_hash__' and
|
attr != '__tree_hash__' and
|
||||||
attr != '__module__'):
|
attr != '__module__'):
|
||||||
attrs.add(attr)
|
attrs.add(attr)
|
||||||
|
|
||||||
return attrs
|
return attrs
|
||||||
@ -1714,31 +1716,31 @@ class _Protocol(metaclass=_ProtocolMeta):
|
|||||||
|
|
||||||
Hashable = collections_abc.Hashable # Not generic.
|
Hashable = collections_abc.Hashable # Not generic.
|
||||||
|
|
||||||
|
|
||||||
if hasattr(collections_abc, 'Awaitable'):
|
if hasattr(collections_abc, 'Awaitable'):
|
||||||
class Awaitable(Generic[T_co], extra=collections_abc.Awaitable):
|
class Awaitable(Generic[T_co], extra=collections_abc.Awaitable):
|
||||||
__slots__ = ()
|
__slots__ = ()
|
||||||
|
|
||||||
__all__.append('Awaitable')
|
|
||||||
|
|
||||||
|
__all__.append('Awaitable')
|
||||||
|
|
||||||
if hasattr(collections_abc, 'Coroutine'):
|
if hasattr(collections_abc, 'Coroutine'):
|
||||||
class Coroutine(Awaitable[V_co], Generic[T_co, T_contra, V_co],
|
class Coroutine(Awaitable[V_co], Generic[T_co, T_contra, V_co],
|
||||||
extra=collections_abc.Coroutine):
|
extra=collections_abc.Coroutine):
|
||||||
__slots__ = ()
|
__slots__ = ()
|
||||||
|
|
||||||
|
|
||||||
__all__.append('Coroutine')
|
__all__.append('Coroutine')
|
||||||
|
|
||||||
|
|
||||||
if hasattr(collections_abc, 'AsyncIterable'):
|
if hasattr(collections_abc, 'AsyncIterable'):
|
||||||
|
|
||||||
class AsyncIterable(Generic[T_co], extra=collections_abc.AsyncIterable):
|
class AsyncIterable(Generic[T_co], extra=collections_abc.AsyncIterable):
|
||||||
__slots__ = ()
|
__slots__ = ()
|
||||||
|
|
||||||
|
|
||||||
class AsyncIterator(AsyncIterable[T_co],
|
class AsyncIterator(AsyncIterable[T_co],
|
||||||
extra=collections_abc.AsyncIterator):
|
extra=collections_abc.AsyncIterator):
|
||||||
__slots__ = ()
|
__slots__ = ()
|
||||||
|
|
||||||
|
|
||||||
__all__.append('AsyncIterable')
|
__all__.append('AsyncIterable')
|
||||||
__all__.append('AsyncIterator')
|
__all__.append('AsyncIterator')
|
||||||
|
|
||||||
@ -1810,7 +1812,6 @@ else:
|
|||||||
def __reversed__(self) -> 'Iterator[T_co]':
|
def __reversed__(self) -> 'Iterator[T_co]':
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
Sized = collections_abc.Sized # Not generic.
|
Sized = collections_abc.Sized # Not generic.
|
||||||
|
|
||||||
|
|
||||||
@ -1823,8 +1824,8 @@ if hasattr(collections_abc, 'Collection'):
|
|||||||
extra=collections_abc.Collection):
|
extra=collections_abc.Collection):
|
||||||
__slots__ = ()
|
__slots__ = ()
|
||||||
|
|
||||||
__all__.append('Collection')
|
|
||||||
|
|
||||||
|
__all__.append('Collection')
|
||||||
|
|
||||||
# Callable was defined earlier.
|
# Callable was defined earlier.
|
||||||
|
|
||||||
@ -1881,7 +1882,6 @@ class ByteString(Sequence[int], extra=collections_abc.ByteString):
|
|||||||
|
|
||||||
|
|
||||||
class List(list, MutableSequence[T], extra=list):
|
class List(list, MutableSequence[T], extra=list):
|
||||||
|
|
||||||
__slots__ = ()
|
__slots__ = ()
|
||||||
|
|
||||||
def __new__(cls, *args, **kwds):
|
def __new__(cls, *args, **kwds):
|
||||||
@ -1892,7 +1892,6 @@ class List(list, MutableSequence[T], extra=list):
|
|||||||
|
|
||||||
|
|
||||||
class Deque(collections.deque, MutableSequence[T], extra=collections.deque):
|
class Deque(collections.deque, MutableSequence[T], extra=collections.deque):
|
||||||
|
|
||||||
__slots__ = ()
|
__slots__ = ()
|
||||||
|
|
||||||
def __new__(cls, *args, **kwds):
|
def __new__(cls, *args, **kwds):
|
||||||
@ -1902,7 +1901,6 @@ class Deque(collections.deque, MutableSequence[T], extra=collections.deque):
|
|||||||
|
|
||||||
|
|
||||||
class Set(set, MutableSet[T], extra=set):
|
class Set(set, MutableSet[T], extra=set):
|
||||||
|
|
||||||
__slots__ = ()
|
__slots__ = ()
|
||||||
|
|
||||||
def __new__(cls, *args, **kwds):
|
def __new__(cls, *args, **kwds):
|
||||||
@ -1969,12 +1967,12 @@ else:
|
|||||||
return True
|
return True
|
||||||
return NotImplemented
|
return NotImplemented
|
||||||
|
|
||||||
|
|
||||||
if hasattr(contextlib, 'AbstractAsyncContextManager'):
|
if hasattr(contextlib, 'AbstractAsyncContextManager'):
|
||||||
class AsyncContextManager(Generic[T_co],
|
class AsyncContextManager(Generic[T_co],
|
||||||
extra=contextlib.AbstractAsyncContextManager):
|
extra=contextlib.AbstractAsyncContextManager):
|
||||||
__slots__ = ()
|
__slots__ = ()
|
||||||
|
|
||||||
|
|
||||||
__all__.append('AsyncContextManager')
|
__all__.append('AsyncContextManager')
|
||||||
elif sys.version_info[:2] >= (3, 5):
|
elif sys.version_info[:2] >= (3, 5):
|
||||||
exec("""
|
exec("""
|
||||||
@ -2003,7 +2001,6 @@ __all__.append('AsyncContextManager')
|
|||||||
|
|
||||||
|
|
||||||
class Dict(dict, MutableMapping[KT, VT], extra=dict):
|
class Dict(dict, MutableMapping[KT, VT], extra=dict):
|
||||||
|
|
||||||
__slots__ = ()
|
__slots__ = ()
|
||||||
|
|
||||||
def __new__(cls, *args, **kwds):
|
def __new__(cls, *args, **kwds):
|
||||||
@ -2015,7 +2012,6 @@ class Dict(dict, MutableMapping[KT, VT], extra=dict):
|
|||||||
|
|
||||||
class DefaultDict(collections.defaultdict, MutableMapping[KT, VT],
|
class DefaultDict(collections.defaultdict, MutableMapping[KT, VT],
|
||||||
extra=collections.defaultdict):
|
extra=collections.defaultdict):
|
||||||
|
|
||||||
__slots__ = ()
|
__slots__ = ()
|
||||||
|
|
||||||
def __new__(cls, *args, **kwds):
|
def __new__(cls, *args, **kwds):
|
||||||
@ -2025,7 +2021,6 @@ class DefaultDict(collections.defaultdict, MutableMapping[KT, VT],
|
|||||||
|
|
||||||
|
|
||||||
class Counter(collections.Counter, Dict[T, int], extra=collections.Counter):
|
class Counter(collections.Counter, Dict[T, int], extra=collections.Counter):
|
||||||
|
|
||||||
__slots__ = ()
|
__slots__ = ()
|
||||||
|
|
||||||
def __new__(cls, *args, **kwds):
|
def __new__(cls, *args, **kwds):
|
||||||
@ -2038,6 +2033,7 @@ if hasattr(collections, 'ChainMap'):
|
|||||||
# ChainMap only exists in 3.3+
|
# ChainMap only exists in 3.3+
|
||||||
__all__.append('ChainMap')
|
__all__.append('ChainMap')
|
||||||
|
|
||||||
|
|
||||||
class ChainMap(collections.ChainMap, MutableMapping[KT, VT],
|
class ChainMap(collections.ChainMap, MutableMapping[KT, VT],
|
||||||
extra=collections.ChainMap):
|
extra=collections.ChainMap):
|
||||||
|
|
||||||
@ -2048,7 +2044,6 @@ if hasattr(collections, 'ChainMap'):
|
|||||||
return collections.ChainMap(*args, **kwds)
|
return collections.ChainMap(*args, **kwds)
|
||||||
return _generic_new(collections.ChainMap, cls, *args, **kwds)
|
return _generic_new(collections.ChainMap, cls, *args, **kwds)
|
||||||
|
|
||||||
|
|
||||||
# Determine what base class to use for Generator.
|
# Determine what base class to use for Generator.
|
||||||
if hasattr(collections_abc, 'Generator'):
|
if hasattr(collections_abc, 'Generator'):
|
||||||
# Sufficiently recent versions of 3.5 have a Generator ABC.
|
# Sufficiently recent versions of 3.5 have a Generator ABC.
|
||||||
@ -2074,8 +2069,8 @@ if hasattr(collections_abc, 'AsyncGenerator'):
|
|||||||
extra=collections_abc.AsyncGenerator):
|
extra=collections_abc.AsyncGenerator):
|
||||||
__slots__ = ()
|
__slots__ = ()
|
||||||
|
|
||||||
__all__.append('AsyncGenerator')
|
|
||||||
|
|
||||||
|
__all__.append('AsyncGenerator')
|
||||||
|
|
||||||
# Internal type variable used for Type[].
|
# Internal type variable used for Type[].
|
||||||
CT_co = TypeVar('CT_co', covariant=True, bound=type)
|
CT_co = TypeVar('CT_co', covariant=True, bound=type)
|
||||||
@ -2237,7 +2232,6 @@ def NewType(name, tp):
|
|||||||
# Python-version-specific alias (Python 2: unicode; Python 3: str)
|
# Python-version-specific alias (Python 2: unicode; Python 3: str)
|
||||||
Text = str
|
Text = str
|
||||||
|
|
||||||
|
|
||||||
# Constant that's True when type checking, but False here.
|
# Constant that's True when type checking, but False here.
|
||||||
TYPE_CHECKING = False
|
TYPE_CHECKING = False
|
||||||
|
|
||||||
@ -2394,7 +2388,6 @@ class io:
|
|||||||
io.__name__ = __name__ + '.io'
|
io.__name__ = __name__ + '.io'
|
||||||
sys.modules[io.__name__] = io
|
sys.modules[io.__name__] = io
|
||||||
|
|
||||||
|
|
||||||
Pattern = _TypeAlias('Pattern', AnyStr, type(stdlib_re.compile('')),
|
Pattern = _TypeAlias('Pattern', AnyStr, type(stdlib_re.compile('')),
|
||||||
lambda p: p.pattern)
|
lambda p: p.pattern)
|
||||||
Match = _TypeAlias('Match', AnyStr, type(stdlib_re.match('', '')),
|
Match = _TypeAlias('Match', AnyStr, type(stdlib_re.match('', '')),
|
||||||
|
Loading…
Reference in New Issue
Block a user