From a913af9523675dc526acab3cc379d1334bb0602c Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Tue, 2 Jun 2020 23:08:54 +0200 Subject: [PATCH] flake8: Enable F811 (#4158) --- .flake8 | 6 ++++-- requirements-tests-py3.txt | 2 +- stdlib/2/__builtin__.pyi | 4 ++-- stdlib/2/_json.pyi | 2 +- stdlib/2and3/builtins.pyi | 4 ++-- stdlib/2and3/distutils/dist.pyi | 2 +- stdlib/2and3/hmac.pyi | 2 +- stdlib/3/multiprocessing/managers.pyi | 4 ++-- third_party/2and3/click/termui.pyi | 1 - third_party/2and3/flask/app.pyi | 1 - third_party/2and3/markupsafe/__init__.pyi | 4 ++-- third_party/2and3/typing_extensions.pyi | 2 +- third_party/3/waitress/proxy_headers.pyi | 2 +- third_party/3/waitress/server.pyi | 1 - third_party/3/waitress/task.pyi | 2 +- 15 files changed, 19 insertions(+), 20 deletions(-) diff --git a/.flake8 b/.flake8 index b29cac969..68e39f79b 100644 --- a/.flake8 +++ b/.flake8 @@ -7,7 +7,6 @@ # F401 imported but unused # F403 import *' used; unable to detect undefined names # F405 defined from star imports -# F811 redefinition (should be fixed in pyflakes 2.1.2) # F822 undefined name in __all__ # Nice-to-haves ignored for now @@ -15,7 +14,10 @@ [flake8] per-file-ignores = - *.pyi: E301, E302, E305, E501, E701, E741, F401, F403, F405, F811, F822 + *.pyi: E301, E302, E305, E501, E701, E741, F401, F403, F405, F822 + # Since typing.pyi defines "overload" this is not recognized by flake8 as typing.overload. + # Unfortunately, flake8 does not allow to "noqa" just a specific error inside the file itself. + typing.pyi: E301, E302, E305, E501, E701, E741, F401, F403, F405, F811, F822 # We are checking with Python 3 but many of the stubs are Python 2 stubs. builtins = StandardError,apply,basestring,buffer,cmp,coerce,execfile,file,intern,long,raw_input,reduce,reload,unichr,unicode,xrange diff --git a/requirements-tests-py3.txt b/requirements-tests-py3.txt index ffbbceec9..5b61d9fab 100644 --- a/requirements-tests-py3.txt +++ b/requirements-tests-py3.txt @@ -1,7 +1,7 @@ git+https://github.com/python/mypy.git@master typed-ast>=1.0.4 black==19.3b0 -flake8==3.8.1 +flake8==3.8.2 flake8-bugbear==20.1.4 flake8-pyi==20.5.0 isort==4.3.21 diff --git a/stdlib/2/__builtin__.pyi b/stdlib/2/__builtin__.pyi index 0eea968d2..c99df6cad 100644 --- a/stdlib/2/__builtin__.pyi +++ b/stdlib/2/__builtin__.pyi @@ -52,7 +52,7 @@ class object: @property def __class__(self: _T) -> Type[_T]: ... @__class__.setter - def __class__(self, __type: Type[object]) -> None: ... + def __class__(self, __type: Type[object]) -> None: ... # noqa: F811 def __init__(self) -> None: ... def __new__(cls) -> Any: ... def __setattr__(self, name: str, value: Any) -> None: ... @@ -1503,7 +1503,7 @@ else: def pow(__base: _SupportsPow3[_E, _M, _T_co], __exp: _E, __mod: _M) -> _T_co: ... def quit(code: object = ...) -> NoReturn: ... if sys.version_info < (3,): - def range(__x: int, __y: int = ..., __step: int = ...) -> List[int]: ... + def range(__x: int, __y: int = ..., __step: int = ...) -> List[int]: ... # noqa: F811 def raw_input(__prompt: Any = ...) -> str: ... @overload def reduce(__function: Callable[[_T, _S], _T], __iterable: Iterable[_S], __initializer: _T) -> _T: ... diff --git a/stdlib/2/_json.pyi b/stdlib/2/_json.pyi index f8bd265ac..1c8e0409f 100644 --- a/stdlib/2/_json.pyi +++ b/stdlib/2/_json.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Tuple, Dict, Generic, Tuple +from typing import Any, Dict, Generic, List, Tuple def encode_basestring_ascii(*args, **kwargs) -> str: ... def scanstring(a, b, *args, **kwargs) -> Tuple[Any, ...]: ... diff --git a/stdlib/2and3/builtins.pyi b/stdlib/2and3/builtins.pyi index 0eea968d2..c99df6cad 100644 --- a/stdlib/2and3/builtins.pyi +++ b/stdlib/2and3/builtins.pyi @@ -52,7 +52,7 @@ class object: @property def __class__(self: _T) -> Type[_T]: ... @__class__.setter - def __class__(self, __type: Type[object]) -> None: ... + def __class__(self, __type: Type[object]) -> None: ... # noqa: F811 def __init__(self) -> None: ... def __new__(cls) -> Any: ... def __setattr__(self, name: str, value: Any) -> None: ... @@ -1503,7 +1503,7 @@ else: def pow(__base: _SupportsPow3[_E, _M, _T_co], __exp: _E, __mod: _M) -> _T_co: ... def quit(code: object = ...) -> NoReturn: ... if sys.version_info < (3,): - def range(__x: int, __y: int = ..., __step: int = ...) -> List[int]: ... + def range(__x: int, __y: int = ..., __step: int = ...) -> List[int]: ... # noqa: F811 def raw_input(__prompt: Any = ...) -> str: ... @overload def reduce(__function: Callable[[_T, _S], _T], __iterable: Iterable[_S], __initializer: _T) -> _T: ... diff --git a/stdlib/2and3/distutils/dist.pyi b/stdlib/2and3/distutils/dist.pyi index 24f06d9c5..92ef8ae49 100644 --- a/stdlib/2and3/distutils/dist.pyi +++ b/stdlib/2and3/distutils/dist.pyi @@ -1,7 +1,7 @@ # Stubs for distutils.dist from distutils.cmd import Command -from typing import Any, Dict, Mapping, Optional, Dict, Tuple, Iterable, Text, Type +from typing import Any, Dict, Iterable, Mapping, Optional, Text, Tuple, Type class Distribution: diff --git a/stdlib/2and3/hmac.pyi b/stdlib/2and3/hmac.pyi index fd550e320..1f280918d 100644 --- a/stdlib/2and3/hmac.pyi +++ b/stdlib/2and3/hmac.pyi @@ -1,6 +1,6 @@ # Stubs for hmac -from typing import Any, Callable, Optional, Union, overload, AnyStr, overload +from typing import Any, AnyStr, Callable, Optional, Union, overload from types import ModuleType import sys diff --git a/stdlib/3/multiprocessing/managers.pyi b/stdlib/3/multiprocessing/managers.pyi index 8cb1b63e5..99f441fc8 100644 --- a/stdlib/3/multiprocessing/managers.pyi +++ b/stdlib/3/multiprocessing/managers.pyi @@ -103,5 +103,5 @@ if sys.version_info >= (3, 8): class SharedMemoryServer(Server): ... class SharedMemoryManager(BaseManager): def get_server(self) -> SharedMemoryServer: ... - def SharedMemory(self, size: int) -> SharedMemory: ... - def ShareableList(self, sequence: Optional[Iterable[_SLT]]) -> ShareableList[_SLT]: ... + def SharedMemory(self, size: int) -> SharedMemory: ... # noqa: F811 + def ShareableList(self, sequence: Optional[Iterable[_SLT]]) -> ShareableList[_SLT]: ... # noqa: F811 diff --git a/third_party/2and3/click/termui.pyi b/third_party/2and3/click/termui.pyi index 87e9bdcc9..136ea9a23 100644 --- a/third_party/2and3/click/termui.pyi +++ b/third_party/2and3/click/termui.pyi @@ -6,7 +6,6 @@ from typing import ( IO, List, Optional, - Text, overload, Text, Tuple, diff --git a/third_party/2and3/flask/app.pyi b/third_party/2and3/flask/app.pyi index 1d0a5ee9e..0308291d3 100644 --- a/third_party/2and3/flask/app.pyi +++ b/third_party/2and3/flask/app.pyi @@ -5,7 +5,6 @@ from .blueprints import Blueprint from .config import Config, ConfigAttribute from .ctx import AppContext, RequestContext, _AppCtxGlobals -from .globals import _request_ctx_stack, g, request, session from .helpers import _PackageBoundObject, find_package, get_debug_flag, get_env, get_flashed_messages, get_load_dotenv, locked_cached_property, url_for from .logging import create_logger from .sessions import SecureCookieSessionInterface diff --git a/third_party/2and3/markupsafe/__init__.pyi b/third_party/2and3/markupsafe/__init__.pyi index 6bedd2476..5ff0b3524 100644 --- a/third_party/2and3/markupsafe/__init__.pyi +++ b/third_party/2and3/markupsafe/__init__.pyi @@ -21,7 +21,7 @@ class Markup(text_type): def unescape(self) -> Text: ... def striptags(self) -> Text: ... @classmethod - def escape(cls, s: text_type) -> Markup: ... + def escape(cls, s: text_type) -> Markup: ... # noqa: F811 def partition(self, sep: text_type) -> Tuple[Markup, Markup, Markup]: ... def rpartition(self, sep: text_type) -> Tuple[Markup, Markup, Markup]: ... def format(self, *args, **kwargs) -> Markup: ... @@ -46,7 +46,7 @@ class Markup(text_type): class EscapeFormatter(string.Formatter): escape: Callable[[text_type], Markup] - def __init__(self, escape: Callable[[text_type], Markup]) -> None: ... + def __init__(self, escape: Callable[[text_type], Markup]) -> None: ... # noqa: F811 def format_field(self, value: text_type, format_spec: text_type) -> Markup: ... if sys.version_info >= (3,): diff --git a/third_party/2and3/typing_extensions.pyi b/third_party/2and3/typing_extensions.pyi index 1bb5da609..ead27ca34 100644 --- a/third_party/2and3/typing_extensions.pyi +++ b/third_party/2and3/typing_extensions.pyi @@ -12,7 +12,7 @@ from typing import overload as overload from typing import Text as Text from typing import Type as Type from typing import TYPE_CHECKING as TYPE_CHECKING -from typing import TypeVar, Any, Mapping, ItemsView, KeysView, Optional, ValuesView, Dict, Type +from typing import TypeVar, Any, Mapping, ItemsView, KeysView, Optional, ValuesView, Dict _T = TypeVar('_T') _F = TypeVar('_F', bound=Callable[..., Any]) diff --git a/third_party/3/waitress/proxy_headers.pyi b/third_party/3/waitress/proxy_headers.pyi index 996fd3147..a750cd305 100644 --- a/third_party/3/waitress/proxy_headers.pyi +++ b/third_party/3/waitress/proxy_headers.pyi @@ -1,4 +1,4 @@ -from .utilities import BadRequest, logger, undquote +from .utilities import BadRequest from collections import namedtuple from logging import Logger from typing import Any, Callable, Mapping, Sequence, Optional, Set diff --git a/third_party/3/waitress/server.pyi b/third_party/3/waitress/server.pyi index 840d19b10..6c6430749 100644 --- a/third_party/3/waitress/server.pyi +++ b/third_party/3/waitress/server.pyi @@ -2,7 +2,6 @@ from . import wasyncore from .proxy_headers import proxy_headers_middleware from socket import SocketType from typing import Any, Sequence, Optional, Tuple, Union -from waitress import trigger from waitress.adjustments import Adjustments from waitress.channel import HTTPChannel from waitress.compat import IPPROTO_IPV6, IPV6_V6ONLY diff --git a/third_party/3/waitress/task.pyi b/third_party/3/waitress/task.pyi index 04f907bc8..4fb2bf401 100644 --- a/third_party/3/waitress/task.pyi +++ b/third_party/3/waitress/task.pyi @@ -1,7 +1,7 @@ from .buffers import ReadOnlyFileBasedBuffer from .channel import HTTPChannel from .compat import reraise, tobytes -from .utilities import Error, build_http_date, logger, queue_logger +from .utilities import Error from logging import Logger from threading import Condition, Lock from typing import Any, Deque, Mapping, Sequence, Optional, Set, Tuple