Skip to content

Commit 006a792

Browse files
srittauJelleZijlstra
authored andcommitted
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
1 parent f362cf4 commit 006a792

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+567
-547
lines changed

.flake8

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,13 @@
1010
# 4 E741 ambiguous variable name
1111

1212
# Nice-to-haves ignored for now
13-
# 159 E128 continuation line under-indented for visual indent
14-
# 34 E127 continuation line over-indented for visual indent
15-
# E252 missing whitespace around parameter equals
1613
# 2307 E501 line too long
1714

1815
# Other ignored warnings
1916
# W504 line break after binary operator
2017

2118
[flake8]
22-
ignore = F401, F403, F405, F811, E127, E128, E252, E301, E302, E305, E501, E701, E704, E741, B303, W504
19+
ignore = F401, F403, F405, F811, E301, E302, E305, E501, E701, E704, E741, B303, W504
2320
# We are checking with Python 3 but many of the stubs are Python 2 stubs.
2421
# A nice future improvement would be to provide separate .flake8
2522
# configurations for Python 2 and Python 3 files.

stdlib/2/__builtin__.pyi

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ class staticmethod(object): # Special, only valid as a decorator.
5555

5656
def __init__(self, f: function) -> None: ...
5757
def __new__(cls: Type[_T], *args: Any, **kwargs: Any) -> _T: ...
58-
def __get__(self, obj: _T, type: Optional[Type[_T]]=...) -> function: ...
58+
def __get__(self, obj: _T, type: Optional[Type[_T]] = ...) -> function: ...
5959

6060
class classmethod(object): # Special, only valid as a decorator.
6161
__func__ = ... # type: function
6262

6363
def __init__(self, f: function) -> None: ...
6464
def __new__(cls: Type[_T], *args: Any, **kwargs: Any) -> _T: ...
65-
def __get__(self, obj: _T, type: Optional[Type[_T]]=...) -> function: ...
65+
def __get__(self, obj: _T, type: Optional[Type[_T]] = ...) -> function: ...
6666

6767
class type(object):
6868
__bases__ = ... # type: Tuple[type, ...]
@@ -871,8 +871,7 @@ def open(file: unicode, mode: unicode = ..., buffering: int = ...) -> BinaryIO:
871871
def open(file: int, mode: unicode = ..., buffering: int = ...) -> BinaryIO: ...
872872
def ord(c: unicode) -> int: ...
873873
# This is only available after from __future__ import print_function.
874-
def print(*values: Any, sep: unicode = ..., end: unicode = ...,
875-
file: IO[Any] = ...) -> None: ...
874+
def print(*values: Any, sep: unicode = ..., end: unicode = ..., file: IO[Any] = ...) -> None: ...
876875
@overload
877876
def pow(x: int, y: int) -> Any: ... # The return type can be int or float, depending on y.
878877
@overload
@@ -925,12 +924,10 @@ def zip(iter1: Iterable[_T1], iter2: Iterable[_T2],
925924
iter3: Iterable[_T3]) -> List[Tuple[_T1, _T2, _T3]]: ...
926925
@overload
927926
def zip(iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3],
928-
iter4: Iterable[_T4]) -> List[Tuple[_T1, _T2,
929-
_T3, _T4]]: ...
927+
iter4: Iterable[_T4]) -> List[Tuple[_T1, _T2, _T3, _T4]]: ...
930928
@overload
931929
def zip(iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3],
932-
iter4: Iterable[_T4], iter5: Iterable[_T5]) -> List[Tuple[_T1, _T2,
933-
_T3, _T4, _T5]]: ...
930+
iter4: Iterable[_T4], iter5: Iterable[_T5]) -> List[Tuple[_T1, _T2, _T3, _T4, _T5]]: ...
934931
@overload
935932
def zip(iter1: Iterable[Any], iter2: Iterable[Any], iter3: Iterable[Any],
936933
iter4: Iterable[Any], iter5: Iterable[Any], iter6: Iterable[Any],

stdlib/2/_socket.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ class SocketType(object):
275275
raise error
276276
def recvfrom_into(self, buffer: bytearray, nbytes: int = ...,
277277
flags: int = ...) -> int: ...
278-
def send(self, data: str, flags: int =...) -> int: ...
278+
def send(self, data: str, flags: int = ...) -> int: ...
279279
def sendall(self, data: str, flags: int = ...) -> None: ...
280280
@overload
281281
def sendto(self, data: str, address: tuple) -> int: ...

stdlib/2/builtins.pyi

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ class staticmethod(object): # Special, only valid as a decorator.
5555

5656
def __init__(self, f: function) -> None: ...
5757
def __new__(cls: Type[_T], *args: Any, **kwargs: Any) -> _T: ...
58-
def __get__(self, obj: _T, type: Optional[Type[_T]]=...) -> function: ...
58+
def __get__(self, obj: _T, type: Optional[Type[_T]] = ...) -> function: ...
5959

6060
class classmethod(object): # Special, only valid as a decorator.
6161
__func__ = ... # type: function
6262

6363
def __init__(self, f: function) -> None: ...
6464
def __new__(cls: Type[_T], *args: Any, **kwargs: Any) -> _T: ...
65-
def __get__(self, obj: _T, type: Optional[Type[_T]]=...) -> function: ...
65+
def __get__(self, obj: _T, type: Optional[Type[_T]] = ...) -> function: ...
6666

6767
class type(object):
6868
__bases__ = ... # type: Tuple[type, ...]
@@ -871,8 +871,7 @@ def open(file: unicode, mode: unicode = ..., buffering: int = ...) -> BinaryIO:
871871
def open(file: int, mode: unicode = ..., buffering: int = ...) -> BinaryIO: ...
872872
def ord(c: unicode) -> int: ...
873873
# This is only available after from __future__ import print_function.
874-
def print(*values: Any, sep: unicode = ..., end: unicode = ...,
875-
file: IO[Any] = ...) -> None: ...
874+
def print(*values: Any, sep: unicode = ..., end: unicode = ..., file: IO[Any] = ...) -> None: ...
876875
@overload
877876
def pow(x: int, y: int) -> Any: ... # The return type can be int or float, depending on y.
878877
@overload
@@ -925,12 +924,10 @@ def zip(iter1: Iterable[_T1], iter2: Iterable[_T2],
925924
iter3: Iterable[_T3]) -> List[Tuple[_T1, _T2, _T3]]: ...
926925
@overload
927926
def zip(iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3],
928-
iter4: Iterable[_T4]) -> List[Tuple[_T1, _T2,
929-
_T3, _T4]]: ...
927+
iter4: Iterable[_T4]) -> List[Tuple[_T1, _T2, _T3, _T4]]: ...
930928
@overload
931929
def zip(iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3],
932-
iter4: Iterable[_T4], iter5: Iterable[_T5]) -> List[Tuple[_T1, _T2,
933-
_T3, _T4, _T5]]: ...
930+
iter4: Iterable[_T4], iter5: Iterable[_T5]) -> List[Tuple[_T1, _T2, _T3, _T4, _T5]]: ...
934931
@overload
935932
def zip(iter1: Iterable[Any], iter2: Iterable[Any], iter3: Iterable[Any],
936933
iter4: Iterable[Any], iter5: Iterable[Any], iter6: Iterable[Any],

stdlib/2/getopt.pyi

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,10 @@ from typing import List, Tuple
33
class GetoptError(Exception):
44
opt = ... # type: str
55
msg = ... # type: str
6-
def __init__(self, msg: str, opt: str=...) -> None: ...
6+
def __init__(self, msg: str, opt: str = ...) -> None: ...
77
def __str__(self) -> str: ...
88

99
error = GetoptError
1010

11-
def getopt(args: List[str], shortopts: str,
12-
longopts: List[str]=...) -> Tuple[List[Tuple[str, str]],
13-
List[str]]: ...
14-
15-
def gnu_getopt(args: List[str], shortopts: str,
16-
longopts: List[str]=...) -> Tuple[List[Tuple[str, str]],
17-
List[str]]: ...
11+
def getopt(args: List[str], shortopts: str, longopts: List[str] = ...) -> Tuple[List[Tuple[str, str]], List[str]]: ...
12+
def gnu_getopt(args: List[str], shortopts: str, longopts: List[str] = ...) -> Tuple[List[Tuple[str, str]], List[str]]: ...

stdlib/2/httplib.pyi

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class HTTPResponse:
2828
chunk_left = ... # type: Any
2929
length = ... # type: Any
3030
will_close = ... # type: Any
31-
def __init__(self, sock, debuglevel=0, strict=0, method=None, buffering: bool=...) -> None: ...
31+
def __init__(self, sock, debuglevel=0, strict=0, method=None, buffering: bool = ...) -> None: ...
3232
def begin(self): ...
3333
def close(self): ...
3434
def isclosed(self): ...
@@ -56,16 +56,16 @@ class HTTPConnection:
5656
def putheader(self, header, *values): ...
5757
def endheaders(self, message_body=None): ...
5858
def request(self, method, url, body=None, headers=...): ...
59-
def getresponse(self, buffering: bool=...): ...
59+
def getresponse(self, buffering: bool = ...): ...
6060

6161
class HTTP:
6262
debuglevel = ... # type: Any
63-
def __init__(self, host: str=..., port=None, strict=None) -> None: ...
63+
def __init__(self, host: str = ..., port=None, strict=None) -> None: ...
6464
def connect(self, host=None, port=None): ...
6565
def getfile(self): ...
6666
file = ... # type: Any
6767
headers = ... # type: Any
68-
def getreply(self, buffering: bool=...): ...
68+
def getreply(self, buffering: bool = ...): ...
6969
def close(self): ...
7070

7171
class HTTPSConnection(HTTPConnection):
@@ -79,7 +79,7 @@ class HTTPSConnection(HTTPConnection):
7979
class HTTPS(HTTP):
8080
key_file = ... # type: Any
8181
cert_file = ... # type: Any
82-
def __init__(self, host: str=..., port=None, key_file=None, cert_file=None, strict=None, context=None) -> None: ...
82+
def __init__(self, host: str = ..., port=None, key_file=None, cert_file=None, strict=None, context=None) -> None: ...
8383

8484
class HTTPException(Exception): ...
8585
class NotConnected(HTTPException): ...

stdlib/2/inspect.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ def getargs(co: CodeType) -> Arguments: ...
9494
def getargspec(func: object) -> ArgSpec: ...
9595
def getargvalues(frame: FrameType) -> ArgInfo: ...
9696
def formatargspec(args, varargs=..., varkw=..., defaults=...,
97-
formatarg=..., formatvarargs=..., formatvarkw=..., formatvalue=...,
98-
join=...) -> str: ...
97+
formatarg=..., formatvarargs=..., formatvarkw=..., formatvalue=...,
98+
join=...) -> str: ...
9999
def formatargvalues(args, varargs=..., varkw=..., defaults=...,
100-
formatarg=..., formatvarargs=..., formatvarkw=..., formatvalue=...,
101-
join=...) -> str: ...
100+
formatarg=..., formatvarargs=..., formatvarkw=..., formatvalue=...,
101+
join=...) -> str: ...
102102
def getmro(cls: type) -> Tuple[type, ...]: ...
103103
def getcallargs(func, *args, **kwds) -> Dict[str, Any]: ...
104104

stdlib/2/io.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ from _io import UnsupportedOperation as UnsupportedOperation
2222
from _io import open as open
2323

2424
def _OpenWrapper(file: Union[str, unicode, int],
25-
mode: unicode = ..., buffering: int = ..., encoding: unicode = ...,
26-
errors: unicode = ..., newline: unicode = ...,
27-
closefd: bool = ...) -> IO[Any]: ...
25+
mode: unicode = ..., buffering: int = ..., encoding: unicode = ...,
26+
errors: unicode = ..., newline: unicode = ...,
27+
closefd: bool = ...) -> IO[Any]: ...
2828

2929
SEEK_SET = ... # type: int
3030
SEEK_CUR = ... # type: int

stdlib/2/itertools.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ _T6 = TypeVar('_T6')
5454
def imap(func: Callable[[_T1], _S], iter1: Iterable[_T1]) -> Iterator[_S]: ...
5555
@overload
5656
def imap(func: Callable[[_T1, _T2], _S],
57-
iter1: Iterable[_T1],
58-
iter2: Iterable[_T2]) -> Iterator[_S]: ...
57+
iter1: Iterable[_T1],
58+
iter2: Iterable[_T2]) -> Iterator[_S]: ...
5959
@overload
6060
def imap(func: Callable[[_T1, _T2, _T3], _S],
6161
iter1: Iterable[_T1], iter2: Iterable[_T2],

stdlib/2/json.pyi

Lines changed: 56 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -7,67 +7,63 @@ class JSONDecodeError(ValueError):
77
def load(self, fp: IO[str]) -> Any: ...
88

99
def dumps(obj: Any,
10-
skipkeys: bool = ...,
11-
ensure_ascii: bool = ...,
12-
check_circular: bool = ...,
13-
allow_nan: bool = ...,
14-
cls: Any = ...,
15-
indent: Optional[int] = ...,
16-
separators: Optional[Tuple[str, str]] = ...,
17-
encoding: str = ...,
18-
default: Optional[Callable[[Any], Any]] = ...,
19-
sort_keys: bool = ...,
20-
**kwds: Any) -> str: ...
10+
skipkeys: bool = ...,
11+
ensure_ascii: bool = ...,
12+
check_circular: bool = ...,
13+
allow_nan: bool = ...,
14+
cls: Any = ...,
15+
indent: Optional[int] = ...,
16+
separators: Optional[Tuple[str, str]] = ...,
17+
encoding: str = ...,
18+
default: Optional[Callable[[Any], Any]] = ...,
19+
sort_keys: bool = ...,
20+
**kwds: Any) -> str: ...
2121

2222
def dump(obj: Any,
23-
fp: Union[IO[str], IO[Text]],
24-
skipkeys: bool = ...,
25-
ensure_ascii: bool = ...,
26-
check_circular: bool = ...,
27-
allow_nan: bool = ...,
28-
cls: Any = ...,
29-
indent: Optional[int] = ...,
30-
separators: Optional[Tuple[str, str]] = ...,
31-
encoding: str = ...,
32-
default: Optional[Callable[[Any], Any]] = ...,
33-
sort_keys: bool = ...,
34-
**kwds: Any) -> None: ...
23+
fp: Union[IO[str], IO[Text]],
24+
skipkeys: bool = ...,
25+
ensure_ascii: bool = ...,
26+
check_circular: bool = ...,
27+
allow_nan: bool = ...,
28+
cls: Any = ...,
29+
indent: Optional[int] = ...,
30+
separators: Optional[Tuple[str, str]] = ...,
31+
encoding: str = ...,
32+
default: Optional[Callable[[Any], Any]] = ...,
33+
sort_keys: bool = ...,
34+
**kwds: Any) -> None: ...
3535

3636
def loads(s: Union[Text, bytes],
37-
encoding: Any = ...,
38-
cls: Any = ...,
39-
object_hook: Optional[Callable[[Dict], Any]] = ...,
40-
parse_float: Optional[Callable[[str], Any]] = ...,
41-
parse_int: Optional[Callable[[str], Any]] = ...,
42-
parse_constant: Optional[Callable[[str], Any]] = ...,
43-
object_pairs_hook: Optional[Callable[[List[Tuple[Any, Any]]], Any]] = ...,
44-
**kwds: Any) -> Any: ...
37+
encoding: Any = ...,
38+
cls: Any = ...,
39+
object_hook: Optional[Callable[[Dict], Any]] = ...,
40+
parse_float: Optional[Callable[[str], Any]] = ...,
41+
parse_int: Optional[Callable[[str], Any]] = ...,
42+
parse_constant: Optional[Callable[[str], Any]] = ...,
43+
object_pairs_hook: Optional[Callable[[List[Tuple[Any, Any]]], Any]] = ...,
44+
**kwds: Any) -> Any: ...
4545

4646
def load(fp: IO[str],
47-
encoding: Optional[str] = ...,
48-
cls: Any = ...,
49-
object_hook: Optional[Callable[[Dict], Any]] = ...,
50-
parse_float: Optional[Callable[[str], Any]] = ...,
51-
parse_int: Optional[Callable[[str], Any]] = ...,
52-
parse_constant: Optional[Callable[[str], Any]] = ...,
53-
object_pairs_hook: Optional[Callable[[List[Tuple[Any, Any]]], Any]] = ...,
54-
**kwds: Any) -> Any: ...
47+
encoding: Optional[str] = ...,
48+
cls: Any = ...,
49+
object_hook: Optional[Callable[[Dict], Any]] = ...,
50+
parse_float: Optional[Callable[[str], Any]] = ...,
51+
parse_int: Optional[Callable[[str], Any]] = ...,
52+
parse_constant: Optional[Callable[[str], Any]] = ...,
53+
object_pairs_hook: Optional[Callable[[List[Tuple[Any, Any]]], Any]] = ...,
54+
**kwds: Any) -> Any: ...
5555

5656
class JSONDecoder(object):
5757
def __init__(self,
58-
encoding: Union[Text, bytes] = ...,
59-
object_hook: Callable[..., Any] = ...,
60-
parse_float: Callable[[str], float] = ...,
61-
parse_int: Callable[[str], int] = ...,
62-
parse_constant: Callable[[str], Any] = ...,
63-
strict: bool = ...,
64-
object_pairs_hook: Callable[..., Any] = ...) -> None: ...
65-
58+
encoding: Union[Text, bytes] = ...,
59+
object_hook: Callable[..., Any] = ...,
60+
parse_float: Callable[[str], float] = ...,
61+
parse_int: Callable[[str], int] = ...,
62+
parse_constant: Callable[[str], Any] = ...,
63+
strict: bool = ...,
64+
object_pairs_hook: Callable[..., Any] = ...) -> None: ...
6665
def decode(self, s: Union[Text, bytes], _w: Any = ...) -> Any: ...
67-
68-
def raw_decode(self,
69-
s: Union[Text, bytes],
70-
idx: int = ...) -> Tuple[Any, Any]: ...
66+
def raw_decode(self, s: Union[Text, bytes], idx: int = ...) -> Tuple[Any, Any]: ...
7167

7268
class JSONEncoder(object):
7369
item_separator = ... # type: str
@@ -80,15 +76,15 @@ class JSONEncoder(object):
8076
indent = ... # type: int
8177

8278
def __init__(self,
83-
skipkeys: bool = ...,
84-
ensure_ascii: bool = ...,
85-
check_circular: bool = ...,
86-
allow_nan: bool = ...,
87-
sort_keys: bool = ...,
88-
indent: int = ...,
89-
separators: Tuple[Union[Text, bytes], Union[Text, bytes]] = ...,
90-
encoding: Union[Text, bytes] = ...,
91-
default: Callable[..., Any] = ...) -> None: ...
79+
skipkeys: bool = ...,
80+
ensure_ascii: bool = ...,
81+
check_circular: bool = ...,
82+
allow_nan: bool = ...,
83+
sort_keys: bool = ...,
84+
indent: int = ...,
85+
separators: Tuple[Union[Text, bytes], Union[Text, bytes]] = ...,
86+
encoding: Union[Text, bytes] = ...,
87+
default: Callable[..., Any] = ...) -> None: ...
9288

9389
def default(self, o: Any) -> Any: ...
9490

stdlib/2/multiprocessing/pool.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ class Pool(ContextManager[Pool]):
2525
args: Iterable[Any] = ...,
2626
kwds: Dict[str, Any] = ...) -> Any: ...
2727
def apply_async(self,
28-
func: Callable[..., Any],
29-
args: Iterable[Any] = ...,
30-
kwds: Dict[str, Any] = ...,
31-
callback: Optional[Callable[..., None]] = ...) -> AsyncResult: ...
28+
func: Callable[..., Any],
29+
args: Iterable[Any] = ...,
30+
kwds: Dict[str, Any] = ...,
31+
callback: Optional[Callable[..., None]] = ...) -> AsyncResult: ...
3232
def map(self,
3333
func: Callable[..., Any],
3434
iterable: Iterable[Any] = ...,

stdlib/2/random.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ class Random(_random.Random):
3131
def sample(self, population: Union[Sequence[_T], AbstractSet[_T]], k: int) -> List[_T]: ...
3232
def random(self) -> float: ...
3333
def uniform(self, a: float, b: float) -> float: ...
34-
def triangular(self, low: float = ..., high: float = ...,
35-
mode: float = ...) -> float: ...
34+
def triangular(self, low: float = ..., high: float = ..., mode: float = ...) -> float: ...
3635
def betavariate(self, alpha: float, beta: float) -> float: ...
3736
def expovariate(self, lambd: float) -> float: ...
3837
def gammavariate(self, alpha: float, beta: float) -> float: ...

0 commit comments

Comments
 (0)