diff options
author | Bill Wendling <morbo@google.com> | 2021-11-04 03:32:37 -0700 |
---|---|---|
committer | Bill Wendling <morbo@google.com> | 2021-11-04 03:32:37 -0700 |
commit | 7d16a183dbe628383c5182d412cdc411286e8f80 (patch) | |
tree | 298c1c3c3aa8f71447ed8aaa1c3ea11041e309da | |
parent | 8ec4ed6fdd68c2a70809b99c788b7061876a746b (diff) | |
download | yapf-7d16a183dbe628383c5182d412cdc411286e8f80.tar.gz |
Reformat so that flake8 is happy.
-rw-r--r-- | .flake8 | 15 | ||||
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | yapf/yapflib/blank_line_calculator.py | 4 | ||||
-rw-r--r-- | yapf/yapflib/comment_splicer.py | 4 | ||||
-rw-r--r-- | yapf/yapflib/file_resources.py | 9 | ||||
-rw-r--r-- | yapf/yapflib/format_decision_state.py | 4 | ||||
-rw-r--r-- | yapf/yapflib/reformatter.py | 6 | ||||
-rw-r--r-- | yapf/yapflib/style.py | 27 | ||||
-rw-r--r-- | yapf/yapflib/yapf_api.py | 2 |
9 files changed, 45 insertions, 27 deletions
@@ -1,8 +1,15 @@ [flake8] ignore = - # indentation is not a multiple of four, - E111,E114, + # continuation line over-indented for hanging indent + E126, # visually indented line with same indent as next logical line, - E129 + E129, + # line break after binary operator + W504 -max-line-length=80 +exclude = + yapf/yapflib/py3compat.py + +disable-noqa +indent-size = 2 +max-line-length = 80 @@ -10,6 +10,7 @@ syntax trees. ### Changes - Change tests to support "pytest". +- Reformat so that "flake8" is happy. ### Fixed - Enable `BLANK_LINE_BEFORE_NESTED_CLASS_OR_DEF` knob for "pep8" style, so method definitions inside a class are surrounded by a single blank line as diff --git a/yapf/yapflib/blank_line_calculator.py b/yapf/yapflib/blank_line_calculator.py index 3741348..f3f14da 100644 --- a/yapf/yapflib/blank_line_calculator.py +++ b/yapf/yapflib/blank_line_calculator.py @@ -139,8 +139,8 @@ class _BlankLineCalculator(pytree_visitor.PyTreeVisitor): if not self.last_was_decorator: _SetNumNewlines(node.children[index].children[0], _ONE_BLANK_LINE) index += 1 - if (index and node.children[index].lineno - 1 - == node.children[index - 1].children[0].lineno): + if (index and node.children[index].lineno - 1 == + node.children[index - 1].children[0].lineno): _SetNumNewlines(node.children[index], _NO_BLANK_LINES) else: if self.last_comment_lineno + 1 == node.children[index].lineno: diff --git a/yapf/yapflib/comment_splicer.py b/yapf/yapflib/comment_splicer.py index 8d64684..535711b 100644 --- a/yapf/yapflib/comment_splicer.py +++ b/yapf/yapflib/comment_splicer.py @@ -120,9 +120,9 @@ def SpliceComments(tree): for comment_column, comment_indent, comment_group in comment_groups: ancestor_at_indent = _FindAncestorAtIndent(child, comment_indent) if ancestor_at_indent.type == token.DEDENT: - InsertNodes = pytree_utils.InsertNodesBefore # pylint: disable=invalid-name + InsertNodes = pytree_utils.InsertNodesBefore # pylint: disable=invalid-name # noqa else: - InsertNodes = pytree_utils.InsertNodesAfter # pylint: disable=invalid-name + InsertNodes = pytree_utils.InsertNodesAfter # pylint: disable=invalid-name # noqa InsertNodes( _CreateCommentsFromPrefix( '\n'.join(comment_group) + '\n', diff --git a/yapf/yapflib/file_resources.py b/yapf/yapflib/file_resources.py index 1c405a2..0c88fc1 100644 --- a/yapf/yapflib/file_resources.py +++ b/yapf/yapflib/file_resources.py @@ -54,7 +54,8 @@ def _GetExcludePatternsFromPyprojectToml(filename): import toml except ImportError: raise errors.YapfError( - "toml package is needed for using pyproject.toml as a configuration file" + "toml package is needed for using pyproject.toml as a " + "configuration file" ) if os.path.isfile(filename) and os.access(filename, os.R_OK): @@ -95,7 +96,8 @@ def GetExcludePatternsForDir(dirname): def GetDefaultStyleForDir(dirname, default_style=style.DEFAULT_STYLE): """Return default style name for a given directory. - Looks for .style.yapf or setup.cfg or pyproject.toml in the parent directories. + Looks for .style.yapf or setup.cfg or pyproject.toml in the parent + directories. Arguments: dirname: (unicode) The name of the directory. @@ -137,7 +139,8 @@ def GetDefaultStyleForDir(dirname, default_style=style.DEFAULT_STYLE): import toml except ImportError: raise errors.YapfError( - "toml package is needed for using pyproject.toml as a configuration file" + "toml package is needed for using pyproject.toml as a " + "configuration file" ) pyproject_toml = toml.load(config_file) diff --git a/yapf/yapflib/format_decision_state.py b/yapf/yapflib/format_decision_state.py index 3c0db37..f6fb07f 100644 --- a/yapf/yapflib/format_decision_state.py +++ b/yapf/yapflib/format_decision_state.py @@ -981,8 +981,8 @@ class FormatDecisionState(object): if (self.param_list_stack and not self.param_list_stack[-1].SplitBeforeClosingBracket( - top_of_stack.indent) and top_of_stack.indent - == ((self.line.depth + 1) * style.Get('INDENT_WIDTH'))): + top_of_stack.indent) and top_of_stack.indent == + ((self.line.depth + 1) * style.Get('INDENT_WIDTH'))): if (format_token.Subtype.PARAMETER_START in current.subtypes or (previous.is_comment and format_token.Subtype.PARAMETER_START in previous.subtypes)): diff --git a/yapf/yapflib/reformatter.py b/yapf/yapflib/reformatter.py index 5695ed9..8af27c8 100644 --- a/yapf/yapflib/reformatter.py +++ b/yapf/yapflib/reformatter.py @@ -298,7 +298,7 @@ def _AlignTrailingComments(final_lines): assert this_line.tokens if (all_pc_line_lengths and this_line.tokens[0].formatted_whitespace_prefix.startswith('\n\n') - ): + ): break if this_line.disable: @@ -486,8 +486,8 @@ def _AnalyzeSolutionSpace(initial_state): if count > 10000: node.state.ignore_stack_for_comparison = True - # Unconditionally add the state and check if it was present to avoid having to - # hash it twice in the common case (state hashing is expensive). + # Unconditionally add the state and check if it was present to avoid having + # to hash it twice in the common case (state hashing is expensive). before_seen_count = len(seen) seen.add(node.state) # If seen didn't change size, the state was already present. diff --git a/yapf/yapflib/style.py b/yapf/yapflib/style.py index a1e6940..85bb08c 100644 --- a/yapf/yapflib/style.py +++ b/yapf/yapflib/style.py @@ -235,7 +235,8 @@ _STYLE_HELP = dict( SPACES_AROUND_DEFAULT_OR_NAMED_ASSIGN=textwrap.dedent("""\ Use spaces around default or named assigns."""), SPACES_AROUND_DICT_DELIMITERS=textwrap.dedent("""\ - Adds a space after the opening '{' and before the ending '}' dict delimiters. + Adds a space after the opening '{' and before the ending '}' dict + delimiters. {1: 2} @@ -244,7 +245,8 @@ _STYLE_HELP = dict( { 1: 2 } """), SPACES_AROUND_LIST_DELIMITERS=textwrap.dedent("""\ - Adds a space after the opening '[' and before the ending ']' list delimiters. + Adds a space after the opening '[' and before the ending ']' list + delimiters. [1, 2] @@ -258,7 +260,8 @@ _STYLE_HELP = dict( my_list[1 : 10 : 2] """), SPACES_AROUND_TUPLE_DELIMITERS=textwrap.dedent("""\ - Adds a space after the opening '(' and before the ending ')' tuple delimiters. + Adds a space after the opening '(' and before the ending ')' tuple + delimiters. (1, 2, 3) @@ -280,7 +283,8 @@ _STYLE_HELP = dict( will be formatted as: - 1 + 1 # Adding values <-- 5 spaces between the end of the statement and comment + 1 + 1 # Adding values <-- 5 spaces between the end of the + # statement and comment With spaces_before_comment=15, 20: @@ -295,16 +299,18 @@ _STYLE_HELP = dict( will be formatted as: - 1 + 1 # Adding values <-- end of line comments in block aligned to col 15 + 1 + 1 # Adding values <-- end of line comments in block + # aligned to col 15 two + two # More adding - longer_statement # This is a longer statement <-- end of line comments in block aligned to col 20 + longer_statement # This is a longer statement <-- end of line + # comments in block aligned to col 20 short # This is a shorter statement a_very_long_statement_that_extends_beyond_the_final_column # Comment <-- the end of line comments are aligned based on the line length short # This is a shorter statement - """), + """), # noqa SPLIT_ARGUMENTS_WHEN_COMMA_TERMINATED=textwrap.dedent("""\ Split before arguments if the argument list is terminated by a comma."""), @@ -339,7 +345,7 @@ _STYLE_HELP = dict( foo = ('This is a really long string: {}, {}, {}, {}' .format(a, b, c, d)) - """), + """), # noqa SPLIT_BEFORE_EXPRESSION_AFTER_OPENING_PAREN=textwrap.dedent("""\ Split after the opening paren which surrounds an expression if it doesn't fit on a single line. @@ -399,7 +405,7 @@ _STYLE_HELP = dict( from a_very_long_or_indented_module_name_yada_yad import ( long_argument_1, long_argument_2, long_argument_3) - """), + """), # noqa SPLIT_PENALTY_LOGICAL_OPERATOR=textwrap.dedent("""\ The penalty of splitting the line around the 'and' and 'or' operators."""), @@ -747,7 +753,8 @@ def _CreateConfigParserFromConfigFile(config_filename): import toml except ImportError: raise errors.YapfError( - "toml package is needed for using pyproject.toml as a configuration file" + "toml package is needed for using pyproject.toml as a " + "configuration file" ) pyproject_toml = toml.load(style_file) diff --git a/yapf/yapflib/yapf_api.py b/yapf/yapflib/yapf_api.py index 479c8ca..0ef2a1e 100644 --- a/yapf/yapflib/yapf_api.py +++ b/yapf/yapflib/yapf_api.py @@ -193,7 +193,7 @@ def FormatCode(unformatted_source, unformatted_source, reformatted_source, filename=filename) if print_diff: - return code_diff, code_diff.strip() != '' # pylint: disable=g-explicit-bool-comparison + return code_diff, code_diff.strip() != '' # pylint: disable=g-explicit-bool-comparison # noqa return reformatted_source, True |