Fix flake8 errors

This is a combination of:
- Fixing some issues upstream.
- Modifying our cleanup script to carry over noqa comments, and
  copying over the new versions of some files.
- A small addition to our flake8 config.
This commit is contained in:
Benjamin Woodruff 2019-07-17 18:34:15 -07:00
parent 4b358efca6
commit 46799cefcf
14 changed files with 22 additions and 23 deletions

View file

@ -86,6 +86,7 @@ ignore =
# I think these are internal to pycodestyle?
# E901, # SyntaxError or IndentationError
# E902, # IOError
F811, # isn't aware of type-only imports, results in false-positives
W191, # indentation contains tabs
W291, # trailing whitespace; is same as TXT6 (Trailing Whitespace).
W292, # no newline at end of file; is same as TXT4 (File Does Not End in

View file

@ -15,7 +15,7 @@ except ImportError: # py36
from typing import _ForwardRef as ForwardRef
def is_value_of_type(
def is_value_of_type( # noqa: C901 "too complex"
value: Any, expected_type: Any, invariant_check: bool = False
) -> bool:
"""

View file

@ -25,7 +25,7 @@ from libcst.visitors import CSTNodeT, CSTVisitor
if TYPE_CHECKING:
from libcst.metadata.base_provider import BaseMetadataProvider
from libcst.metadata.base_provider import BaseMetadataProvider # noqa: F401
VisitorMethod = Callable[[cst.CSTNode], None]

View file

@ -10,8 +10,8 @@ from typing import TYPE_CHECKING, ClassVar, Sequence, Type, TypeVar
if TYPE_CHECKING:
# Circular dependency for typing reasons only
from libcst.nodes._base import CSTNode
from libcst.metadata.base_provider import BaseMetadataProvider
from libcst.nodes._base import CSTNode # noqa: F401
from libcst.metadata.base_provider import BaseMetadataProvider # noqa: F401
_T = TypeVar("_T")

View file

@ -14,9 +14,9 @@ grammar in a whitespace-sensitive fashion, forming a "Concrete" Syntax Tree (CST
# implementation details. Those base classes shouldn't be useful outside of this
# package.
from libcst.nodes._base import CSTNode, CSTValidationError
from libcst.nodes._dummy import DummyNode
from libcst.nodes._expression import (
from libcst.nodes._base import CSTNode, CSTValidationError # noqa: F401
from libcst.nodes._dummy import DummyNode # noqa: F401
from libcst.nodes._expression import ( # noqa: F401
Annotation,
Arg,
Asynchronous,
@ -75,8 +75,8 @@ from libcst.nodes._expression import (
UnaryOperation,
Yield,
)
from libcst.nodes._module import Module
from libcst.nodes._op import (
from libcst.nodes._module import Module # noqa: F401
from libcst.nodes._op import ( # noqa: F401
Add,
AddAssign,
And,
@ -131,7 +131,7 @@ from libcst.nodes._op import (
Subtract,
SubtractAssign,
)
from libcst.nodes._statement import (
from libcst.nodes._statement import ( # noqa: F401
AnnAssign,
AsName,
Assert,
@ -170,7 +170,7 @@ from libcst.nodes._statement import (
With,
WithItem,
)
from libcst.nodes._whitespace import (
from libcst.nodes._whitespace import ( # noqa: F401
Comment,
EmptyLine,
Newline,

View file

@ -26,7 +26,7 @@ from libcst.visitors import CSTTransformer, CSTVisitor, CSTVisitorT
if TYPE_CHECKING:
from libcst.metadata.base_provider import BaseMetadataProvider
from libcst.metadata.base_provider import BaseMetadataProvider # noqa: F401
_T = TypeVar("_T")

View file

@ -13,7 +13,7 @@ from libcst._removal_sentinel import RemovalSentinel
from libcst.nodes._base import CSTNode, CSTValidationError
from libcst.nodes._expression import LeftParen, RightParen
from libcst.nodes._internal import CodegenState, visit_sequence
from libcst.nodes._whitespace import EmptyLine, TrailingWhitespace
from libcst.nodes._whitespace import EmptyLine, TrailingWhitespace # noqa: F401
from libcst.visitors import CSTVisitorT

View file

@ -29,9 +29,9 @@ from libcst._removal_sentinel import RemovalSentinel
if TYPE_CHECKING:
# These are circular dependencies only used for typing purposes
from libcst.nodes._base import CSTNode
from libcst.nodes._base import CSTNode # noqa: F401
from libcst.visitors import CSTVisitorT
from libcst.metadata.position_provider import (
from libcst.metadata.position_provider import ( # noqa: F401
BasicPositionProvider,
SyntacticPositionProvider,
)

View file

@ -22,7 +22,7 @@ from libcst.visitors import CSTVisitorT
if TYPE_CHECKING:
# These are circular dependencies only used for typing purposes
from libcst.metadata.position_provider import (
from libcst.metadata.position_provider import ( # noqa: F401
BasicPositionProvider,
SyntacticPositionProvider,
)

View file

@ -41,7 +41,7 @@ class BaseParenthesizableWhitespace(CSTNode, ABC):
https://docs.python.org/3/reference/lexical_analysis.html#implicit-line-joining
ParenthesizableWhitespace may contain a backslash character (`\`), when used as a
ParenthesizableWhitespace may contain a backslash character (`\\`), when used as a
line-continuation character. While the continuation character isn't technically
"whitespace", it serves the same purpose.
@ -84,7 +84,7 @@ class Newline(BaseLeaf):
TrailingWhitespace).
Other newlines may occur in the document after continuation characters (the
backslash, `\`), but those newlines are treated as part of the SimpleWhitespace.
backslash, `\\`), but those newlines are treated as part of the SimpleWhitespace.
"""
# A value of 'None' indicates that the module's default newline sequence should be

View file

@ -14,7 +14,7 @@ from libcst.parser._types.partials import ParamStarPartial
from libcst.parser._whitespace_parser import parse_parenthesizable_whitespace
@with_production(
@with_production( # noqa: C901: too complex
"typedargslist",
(
"(tfpdef_assign (',' tfpdef_assign)* "

View file

@ -6,7 +6,6 @@
# pyre-strict
from dataclasses import dataclass
from enum import Enum
from typing import Generic, Optional, Sequence, TypeVar, Union
import libcst.nodes as cst

View file

@ -105,7 +105,7 @@ def tokenize_lines(
yield _convert_token(state, curr_token, None)
def _convert_token(
def _convert_token( # noqa: C901: too complex
state: _TokenizeState, curr_token: OrigToken, next_token: Optional[OrigToken]
) -> Token:
ct_type = curr_token.type

View file

@ -9,7 +9,6 @@
# python -m libcst.tool print python_file.py
# pyre-strict
import argparse
import dataclasses
import sys
@ -23,7 +22,7 @@ from libcst.parser import parse_module
_DEFAULT_INDENT: str = " "
def _node_repr_recursive(
def _node_repr_recursive( # noqa: C901
node: object,
*,
indent: str = _DEFAULT_INDENT,