2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-29 05:18:10 +00:00

Reformat code

This commit is contained in:
Dan 2019-03-16 17:51:37 +01:00
parent c3470b2713
commit def3bdaa63
12 changed files with 114 additions and 126 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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.
@ -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.
@ -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
@ -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('', '')),