Flake8 fixes (#2549)

* Fix over-indented continuation lines

* Fix under-indented continuation lines

* Fix whitespace around default operator problems

* Limit line lengths

* Fix inconsistent files
This commit is contained in:
Sebastian Rittau
2018-10-24 16:20:53 +02:00
committed by Jelle Zijlstra
parent f362cf47fa
commit 006a79220f
83 changed files with 567 additions and 547 deletions

View File

@@ -22,8 +22,7 @@ _TransProtPair = Tuple[BaseTransport, BaseProtocol]
class Handle:
_cancelled = False
_args = ... # type: List[Any]
def __init__(self, callback: Callable[..., Any], args: List[Any],
loop: AbstractEventLoop) -> None: ...
def __init__(self, callback: Callable[..., Any], args: List[Any], loop: AbstractEventLoop) -> None: ...
def __repr__(self) -> str: ...
def cancel(self) -> None: ...
def _run(self) -> None: ...
@@ -90,7 +89,7 @@ class AbstractEventLoop(metaclass=ABCMeta):
@abstractmethod
@coroutine
def run_in_executor(self, executor: Any,
func: Callable[..., _T], *args: Any) -> Generator[Any, None, _T]: ...
func: Callable[..., _T], *args: Any) -> Generator[Any, None, _T]: ...
@abstractmethod
def set_default_executor(self, executor: Any) -> None: ...
# Network I/O methods returning Futures.
@@ -99,7 +98,8 @@ class AbstractEventLoop(metaclass=ABCMeta):
# TODO the "Tuple[Any, ...]" should be "Union[Tuple[str, int], Tuple[str, int, int, int]]" but that triggers
# https://github.com/python/mypy/issues/2509
def getaddrinfo(self, host: Optional[str], port: Union[str, int, None], *,
family: int = ..., type: int = ..., proto: int = ..., flags: int = ...) -> Generator[Any, None, List[Tuple[int, int, int, str, Tuple[Any, ...]]]]: ...
family: int = ..., type: int = ..., proto: int = ...,
flags: int = ...) -> Generator[Any, None, List[Tuple[int, int, int, str, Tuple[Any, ...]]]]: ...
@abstractmethod
@coroutine
def getnameinfo(self, sockaddr: tuple, flags: int = ...) -> Generator[Any, None, Tuple[str, int]]: ...

View File

@@ -64,9 +64,9 @@ class FlowControlMixin(protocols.Protocol): ...
class StreamReaderProtocol(FlowControlMixin, protocols.Protocol):
def __init__(self,
stream_reader: StreamReader,
client_connected_cb: _ClientConnectedCallback = ...,
loop: Optional[events.AbstractEventLoop] = ...) -> None: ...
stream_reader: StreamReader,
client_connected_cb: _ClientConnectedCallback = ...,
loop: Optional[events.AbstractEventLoop] = ...) -> None: ...
def connection_made(self, transport: transports.BaseTransport) -> None: ...
def connection_lost(self, exc: Optional[Exception]) -> None: ...
def data_received(self, data: bytes) -> None: ...
@@ -74,10 +74,10 @@ class StreamReaderProtocol(FlowControlMixin, protocols.Protocol):
class StreamWriter:
def __init__(self,
transport: transports.BaseTransport,
protocol: protocols.BaseProtocol,
reader: StreamReader,
loop: events.AbstractEventLoop) -> None: ...
transport: transports.BaseTransport,
protocol: protocols.BaseProtocol,
reader: StreamReader,
loop: events.AbstractEventLoop) -> None: ...
@property
def transport(self) -> transports.BaseTransport: ...
def write(self, data: bytes) -> None: ...
@@ -91,8 +91,8 @@ class StreamWriter:
class StreamReader:
def __init__(self,
limit: int = ...,
loop: Optional[events.AbstractEventLoop] = ...) -> None: ...
limit: int = ...,
loop: Optional[events.AbstractEventLoop] = ...) -> None: ...
def exception(self) -> Exception: ...
def set_exception(self, exc: Exception) -> None: ...
def set_transport(self, transport: transports.BaseTransport) -> None: ...

View File

@@ -29,9 +29,9 @@ class Process:
stderr = ... # type: Optional[streams.StreamReader]
pid = ... # type: int
def __init__(self,
transport: transports.BaseTransport,
protocol: protocols.BaseProtocol,
loop: events.AbstractEventLoop) -> None: ...
transport: transports.BaseTransport,
protocol: protocols.BaseProtocol,
loop: events.AbstractEventLoop) -> None: ...
@property
def returncode(self) -> int: ...
@coroutine

View File

@@ -53,8 +53,7 @@ def run_coroutine_threadsafe(coro: _FutureT[_T],
loop: AbstractEventLoop) -> concurrent.futures.Future[_T]: ...
def shield(arg: _FutureT[_T], *, loop: AbstractEventLoop = ...) -> Future[_T]: ...
def sleep(delay: float, result: _T = ..., loop: AbstractEventLoop = ...) -> Future[_T]: ...
def wait(fs: Iterable[_FutureT[_T]], *, loop: AbstractEventLoop = ...,
timeout: Optional[float] = ...,
def wait(fs: Iterable[_FutureT[_T]], *, loop: AbstractEventLoop = ..., timeout: Optional[float] = ...,
return_when: str = ...) -> Future[Tuple[Set[Future[_T]], Set[Future[_T]]]]: ...
def wait_for(fut: _FutureT[_T], timeout: Optional[float],
*, loop: AbstractEventLoop = ...) -> Future[_T]: ...

View File

@@ -63,7 +63,7 @@ class staticmethod: # Special, only valid as a decorator.
def __init__(self, f: function) -> None: ...
def __new__(cls: Type[_T], *args: Any, **kwargs: Any) -> _T: ...
def __get__(self, obj: _T, type: Optional[Type[_T]]=...) -> function: ...
def __get__(self, obj: _T, type: Optional[Type[_T]] = ...) -> function: ...
class classmethod: # Special, only valid as a decorator.
__func__ = ... # type: function
@@ -71,7 +71,7 @@ class classmethod: # Special, only valid as a decorator.
def __init__(self, f: function) -> None: ...
def __new__(cls: Type[_T], *args: Any, **kwargs: Any) -> _T: ...
def __get__(self, obj: _T, type: Optional[Type[_T]]=...) -> function: ...
def __get__(self, obj: _T, type: Optional[Type[_T]] = ...) -> function: ...
class type:
__bases__ = ... # type: Tuple[type, ...]
@@ -935,12 +935,10 @@ def zip(iter1: Iterable[_T1], iter2: Iterable[_T2],
iter3: Iterable[_T3]) -> Iterator[Tuple[_T1, _T2, _T3]]: ...
@overload
def zip(iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3],
iter4: Iterable[_T4]) -> Iterator[Tuple[_T1, _T2,
_T3, _T4]]: ...
iter4: Iterable[_T4]) -> Iterator[Tuple[_T1, _T2, _T3, _T4]]: ...
@overload
def zip(iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3],
iter4: Iterable[_T4], iter5: Iterable[_T5]) -> Iterator[Tuple[_T1, _T2,
_T3, _T4, _T5]]: ...
iter4: Iterable[_T4], iter5: Iterable[_T5]) -> Iterator[Tuple[_T1, _T2, _T3, _T4, _T5]]: ...
@overload
def zip(iter1: Iterable[Any], iter2: Iterable[Any], iter3: Iterable[Any],
iter4: Iterable[Any], iter5: Iterable[Any], iter6: Iterable[Any],

View File

@@ -42,7 +42,8 @@ class Future(Generic[_T]):
class Executor:
def submit(self, fn: Callable[..., _T], *args: Any, **kwargs: Any) -> Future[_T]: ...
if sys.version_info >= (3, 5):
def map(self, func: Callable[..., _T], *iterables: Iterable[Any], timeout: Optional[float] = ..., chunksize: int = ...) -> Iterator[_T]: ...
def map(self, func: Callable[..., _T], *iterables: Iterable[Any], timeout: Optional[float] = ...,
chunksize: int = ...) -> Iterator[_T]: ...
else:
def map(self, func: Callable[..., _T], *iterables: Iterable[Any], timeout: Optional[float] = ...,) -> Iterator[_T]: ...
def shutdown(self, wait: bool = ...) -> None: ...
@@ -51,4 +52,5 @@ class Executor:
def as_completed(fs: Iterable[Future[_T]], timeout: Optional[float] = ...) -> Iterator[Future[_T]]: ...
def wait(fs: Iterable[Future[_T]], timeout: Optional[float] = ..., return_when: str = ...) -> Tuple[Set[Future[_T]], Set[Future[_T]]]: ...
def wait(fs: Iterable[Future[_T]], timeout: Optional[float] = ..., return_when: str = ...) -> Tuple[Set[Future[_T]],
Set[Future[_T]]]: ...

View File

@@ -5,7 +5,7 @@ def rectangle(win: _CursesWindow, uly: int, ulx: int, lry: int, lrx: int) -> Non
class Textbox:
stripspaces: bool
def __init__(self, w: _CursesWindow, insert_mode: bool= ...) -> None: ...
def __init__(self, w: _CursesWindow, insert_mode: bool = ...) -> None: ...
def edit(self, validate: Callable[[int], int]) -> str: ...
def do_command(self, ch: Union[str, int]) -> None: ...
def gather(self) -> str: ...

View File

@@ -5,15 +5,10 @@ import sys
from email.message import Message
from email.policy import Policy
def message_from_string(s: str, _class: Callable[[], Message] = ..., *,
policy: Policy = ...) -> Message: ...
def message_from_bytes(s: bytes, _class: Callable[[], Message] = ..., *,
policy: Policy = ...) -> Message: ...
def message_from_file(fp: IO[str], _class: Callable[[], Message] = ..., *,
policy: Policy = ...) -> Message: ...
def message_from_binary_file(fp: IO[bytes],
_class: Callable[[], Message] = ..., *,
policy: Policy = ...) -> Message: ...
def message_from_string(s: str, _class: Callable[[], Message] = ..., *, policy: Policy = ...) -> Message: ...
def message_from_bytes(s: bytes, _class: Callable[[], Message] = ..., *, policy: Policy = ...) -> Message: ...
def message_from_file(fp: IO[str], _class: Callable[[], Message] = ..., *, policy: Policy = ...) -> Message: ...
def message_from_binary_file(fp: IO[bytes], _class: Callable[[], Message] = ..., *, policy: Policy = ...) -> Message: ...
# Names in __all__ with no definition:
# base64mime

View File

@@ -11,7 +11,7 @@ class Generator:
maxheaderlen: int = ..., *,
policy: Policy = ...) -> None: ...
def flatten(self, msg: Message, unixfrom: bool = ...,
linesep: Optional[str] =...) -> None: ...
linesep: Optional[str] = ...) -> None: ...
class BytesGenerator:
def clone(self, fp: TextIO) -> Generator: ...
@@ -20,7 +20,7 @@ class BytesGenerator:
maxheaderlen: int = ..., *,
policy: Policy = ...) -> None: ...
def flatten(self, msg: Message, unixfrom: bool = ...,
linesep: Optional[str] =...) -> None: ...
linesep: Optional[str] = ...) -> None: ...
class DecodedGenerator(Generator):
# TODO `fmt` is positional

View File

@@ -20,6 +20,6 @@ class Header:
def decode_header(header: Union[Header, str]) -> List[Tuple[bytes, Optional[str]]]: ...
def make_header(decoded_seq: List[Tuple[bytes, Optional[str]]],
maxlinelen: Optional[int] =...,
maxlinelen: Optional[int] = ...,
header_name: Optional[str] = ...,
continuation_ws: str = ...) -> Header: ...

View File

@@ -86,7 +86,7 @@ class Address:
def __init__(self, display_name: str = ...,
username: Optional[str] = ...,
domain: Optional[str] = ...,
addr_spec: Optional[str]=...) -> None: ...
addr_spec: Optional[str] = ...) -> None: ...
def __str__(self) -> str: ...
class Group:

View File

@@ -4,13 +4,8 @@
from typing import List, Tuple
def getopt(args: List[str], shortopts: str,
longopts: List[str]=...) -> Tuple[List[Tuple[str, str]],
List[str]]: ...
def gnu_getopt(args: List[str], shortopts: str,
longopts: List[str]=...) -> Tuple[List[Tuple[str, str]],
List[str]]: ...
def getopt(args: List[str], shortopts: str, longopts: List[str] = ...) -> Tuple[List[Tuple[str, str]], List[str]]: ...
def gnu_getopt(args: List[str], shortopts: str, longopts: List[str] = ...) -> Tuple[List[Tuple[str, str]], List[str]]: ...
class GetoptError(Exception):
msg = ... # type: str

View File

@@ -24,7 +24,7 @@ def find(domain: str, localedir: str = ..., languages: List[str] = ...,
def translation(domain: str, localedir: str = ..., languages: List[str] = ...,
class_: Callable[[IO[str]], NullTranslations] = ...,
fallback: bool =..., codeset: Any = ...) -> NullTranslations: ...
fallback: bool = ..., codeset: Any = ...) -> NullTranslations: ...
def install(domain: str, localedir: str = ..., codeset: Any = ...,
names: List[str] = ...): ...

View File

@@ -69,7 +69,7 @@ class DefaultCookiePolicy(CookiePolicy):
rfc2965: bool = ...,
rfc2109_as_netscape: Optional[bool] = ...,
hide_cookie2: bool = ..., strict_domain: bool = ...,
strict_rfc2965_unverifiable: bool =...,
strict_rfc2965_unverifiable: bool = ...,
strict_ns_unverifiable: bool = ...,
strict_ns_domain: int = ...,
strict_ns_set_initial_dollar: bool = ...,

View File

@@ -12,14 +12,14 @@ if sys.version_info >= (3, 7):
def open_binary(package: Package, resource: Resource) -> BinaryIO: ...
def open_text(package: Package,
resource: Resource,
encoding: str = ...,
errors: str = ...) -> TextIO: ...
resource: Resource,
encoding: str = ...,
errors: str = ...) -> TextIO: ...
def read_binary(package: Package, resource: Resource) -> bytes: ...
def read_text(package: Package,
resource: Resource,
encoding: str = ...,
errors: str = ...) -> str: ...
resource: Resource,
encoding: str = ...,
errors: str = ...) -> str: ...
def path(package: Package, resource: Resource) -> ContextManager[Path]: ...
def is_resource(package: Package, name: str) -> bool: ...
def contents(package: Package) -> Iterator[str]: ...

View File

@@ -7,52 +7,52 @@ if sys.version_info >= (3, 5):
from .decoder import JSONDecodeError as JSONDecodeError
def dumps(obj: Any,
skipkeys: bool = ...,
ensure_ascii: bool = ...,
check_circular: bool = ...,
allow_nan: bool = ...,
cls: Any = ...,
indent: Union[None, int, str] = ...,
separators: Optional[Tuple[str, str]] = ...,
default: Optional[Callable[[Any], Any]] = ...,
sort_keys: bool = ...,
**kwds: Any) -> str: ...
skipkeys: bool = ...,
ensure_ascii: bool = ...,
check_circular: bool = ...,
allow_nan: bool = ...,
cls: Any = ...,
indent: Union[None, int, str] = ...,
separators: Optional[Tuple[str, str]] = ...,
default: Optional[Callable[[Any], Any]] = ...,
sort_keys: bool = ...,
**kwds: Any) -> str: ...
def dump(obj: Any,
fp: IO[str],
skipkeys: bool = ...,
ensure_ascii: bool = ...,
check_circular: bool = ...,
allow_nan: bool = ...,
cls: Any = ...,
indent: Union[None, int, str] = ...,
separators: Optional[Tuple[str, str]] = ...,
default: Optional[Callable[[Any], Any]] = ...,
sort_keys: bool = ...,
**kwds: Any) -> None: ...
fp: IO[str],
skipkeys: bool = ...,
ensure_ascii: bool = ...,
check_circular: bool = ...,
allow_nan: bool = ...,
cls: Any = ...,
indent: Union[None, int, str] = ...,
separators: Optional[Tuple[str, str]] = ...,
default: Optional[Callable[[Any], Any]] = ...,
sort_keys: bool = ...,
**kwds: Any) -> None: ...
if sys.version_info >= (3, 6):
_LoadsString = Union[str, bytes, bytearray]
else:
_LoadsString = str
def loads(s: _LoadsString,
encoding: Any = ..., # ignored and deprecated
cls: Any = ...,
object_hook: Optional[Callable[[Dict], Any]] = ...,
parse_float: Optional[Callable[[str], Any]] = ...,
parse_int: Optional[Callable[[str], Any]] = ...,
parse_constant: Optional[Callable[[str], Any]] = ...,
object_pairs_hook: Optional[Callable[[List[Tuple[Any, Any]]], Any]] = ...,
**kwds: Any) -> Any: ...
encoding: Any = ..., # ignored and deprecated
cls: Any = ...,
object_hook: Optional[Callable[[Dict], Any]] = ...,
parse_float: Optional[Callable[[str], Any]] = ...,
parse_int: Optional[Callable[[str], Any]] = ...,
parse_constant: Optional[Callable[[str], Any]] = ...,
object_pairs_hook: Optional[Callable[[List[Tuple[Any, Any]]], Any]] = ...,
**kwds: Any) -> Any: ...
class _Reader(Protocol):
def read(self) -> _LoadsString: ...
def load(fp: _Reader,
cls: Any = ...,
object_hook: Optional[Callable[[Dict], Any]] = ...,
parse_float: Optional[Callable[[str], Any]] = ...,
parse_int: Optional[Callable[[str], Any]] = ...,
parse_constant: Optional[Callable[[str], Any]] = ...,
object_pairs_hook: Optional[Callable[[List[Tuple[Any, Any]]], Any]] = ...,
**kwds: Any) -> Any: ...
cls: Any = ...,
object_hook: Optional[Callable[[Dict], Any]] = ...,
parse_float: Optional[Callable[[str], Any]] = ...,
parse_int: Optional[Callable[[str], Any]] = ...,
parse_constant: Optional[Callable[[str], Any]] = ...,
object_pairs_hook: Optional[Callable[[List[Tuple[Any, Any]]], Any]] = ...,
**kwds: Any) -> Any: ...

View File

@@ -19,10 +19,10 @@ class JSONDecoder:
object_pairs_hook = ... # type: Callable[[List[Tuple[str, Any]]], Any]
def __init__(self, object_hook: Optional[Callable[[Dict[str, Any]], Any]] = ...,
parse_float: Optional[Callable[[str], Any]] = ...,
parse_int: Optional[Callable[[str], Any]] = ...,
parse_constant: Optional[Callable[[str], Any]] = ...,
strict: bool = ...,
object_pairs_hook: Optional[Callable[[List[Tuple[str, Any]]], Any]] = ...) -> None: ...
parse_float: Optional[Callable[[str], Any]] = ...,
parse_int: Optional[Callable[[str], Any]] = ...,
parse_constant: Optional[Callable[[str], Any]] = ...,
strict: bool = ...,
object_pairs_hook: Optional[Callable[[List[Tuple[str, Any]]], Any]] = ...) -> None: ...
def decode(self, s: str) -> Any: ...
def raw_decode(self, s: str, idx: int = ...) -> Tuple[Any, int]: ...

View File

@@ -12,8 +12,9 @@ class JSONEncoder:
indent = ... # type: int
def __init__(self, skipkeys: bool = ..., ensure_ascii: bool = ...,
check_circular: bool = ..., allow_nan: bool = ..., sort_keys: bool = ...,
indent: Optional[int] = ..., separators: Optional[Tuple[str, str]] = ..., default: Optional[Callable] = ...) -> None: ...
check_circular: bool = ..., allow_nan: bool = ..., sort_keys: bool = ...,
indent: Optional[int] = ..., separators: Optional[Tuple[str, str]] = ...,
default: Optional[Callable] = ...) -> None: ...
def default(self, o: Any) -> Any: ...
def encode(self, o: Any) -> str: ...

View File

@@ -18,7 +18,7 @@ class Connection(object):
def __exit__(self, exc_type, exc_value, exc_tb) -> None: ...
def __init__(self, _in, _out) -> None: ...
def close(self) -> None: ...
def poll(self, timeout: float=...) -> bool: ...
def poll(self, timeout: float = ...) -> bool: ...
class Listener(object):
_backlog_queue = ... # type: Optional[Queue]
@@ -32,4 +32,4 @@ class Listener(object):
def Client(address) -> Connection: ...
def Pipe(duplex: bool=...) -> Tuple[Connection, Connection]: ...
def Pipe(duplex: bool = ...) -> Tuple[Connection, Connection]: ...

View File

@@ -31,11 +31,11 @@ class Pool(ContextManager[Pool]):
args: Iterable[Any] = ...,
kwds: Mapping[str, Any] = ...) -> _T: ...
def apply_async(self,
func: Callable[..., _T],
args: Iterable[Any] = ...,
kwds: Mapping[str, Any] = ...,
callback: Optional[Callable[[_T], None]] = ...,
error_callback: Optional[Callable[[BaseException], None]] = ...) -> AsyncResult[_T]: ...
func: Callable[..., _T],
args: Iterable[Any] = ...,
kwds: Mapping[str, Any] = ...,
callback: Optional[Callable[[_T], None]] = ...,
error_callback: Optional[Callable[[BaseException], None]] = ...) -> AsyncResult[_T]: ...
def map(self,
func: Callable[[_S], _T],
iterable: Iterable[_S] = ...,

View File

@@ -482,7 +482,7 @@ else:
def renames(old: _PathType, new: _PathType) -> None: ...
if sys.version_info >= (3, 3):
def replace(src: _PathType, dst: _PathType, *,
src_dir_fd: Optional[int] = ..., dst_dir_fd: Optional[int] = ...) -> None: ...
src_dir_fd: Optional[int] = ..., dst_dir_fd: Optional[int] = ...) -> None: ...
def rmdir(path: _PathType, *, dir_fd: Optional[int] = ...) -> None: ...
else:
def rmdir(path: _PathType) -> None: ...

View File

@@ -45,8 +45,13 @@ class stat_result:
st_creator: int
st_type: int
uname_result = NamedTuple('uname_result', [('sysname', str), ('nodename', str),
('release', str), ('version', str), ('machine', str)])
uname_result = NamedTuple('uname_result', [
('sysname', str),
('nodename', str),
('release', str),
('version', str),
('machine', str),
])
times_result = NamedTuple('times_result', [
('user', float),

View File

@@ -29,8 +29,7 @@ class Random(_random.Random):
def sample(self, population: Union[Sequence[_T], AbstractSet[_T]], k: int) -> List[_T]: ...
def random(self) -> float: ...
def uniform(self, a: float, b: float) -> float: ...
def triangular(self, low: float = ..., high: float = ...,
mode: float = ...) -> float: ...
def triangular(self, low: float = ..., high: float = ..., mode: float = ...) -> float: ...
def betavariate(self, alpha: float, beta: float) -> float: ...
def expovariate(self, lambd: float) -> float: ...
def gammavariate(self, alpha: float, beta: float) -> float: ...

View File

@@ -23,7 +23,7 @@ if sys.version_info >= (3, 5):
def NamedTemporaryFile(
mode: str = ..., buffering: int = ..., encoding: Optional[str] = ...,
newline: Optional[str] = ..., suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ...,
dir: Optional[AnyStr] = ..., delete: bool =...
dir: Optional[AnyStr] = ..., delete: bool = ...
) -> IO[Any]:
...
def SpooledTemporaryFile(
@@ -61,7 +61,7 @@ else:
def NamedTemporaryFile(
mode: str = ..., buffering: int = ..., encoding: Optional[str] = ...,
newline: Optional[str] = ..., suffix: str = ..., prefix: str = ...,
dir: Optional[str] = ..., delete: bool =...
dir: Optional[str] = ..., delete: bool = ...
) -> IO[Any]:
...
def SpooledTemporaryFile(

View File

@@ -51,8 +51,8 @@ class Request:
unverifiable: bool
method: Optional[str]
def __init__(self, url: str, data: Optional[bytes] = ...,
headers: Dict[str, str] =..., origin_req_host: Optional[str] = ...,
unverifiable: bool = ..., method: Optional[str] = ...) -> None: ...
headers: Dict[str, str] = ..., origin_req_host: Optional[str] = ...,
unverifiable: bool = ..., method: Optional[str] = ...) -> None: ...
def get_method(self) -> str: ...
def add_header(self, key: str, val: str) -> None: ...
def add_unredirected_header(self, key: str, val: str) -> None: ...