From a5686d6cda0e8c548b7725572b4bd6147bbaa1e8 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Fri, 5 Apr 2019 16:25:45 +0200 Subject: [PATCH] PEP 8 --- parso/python/errors.py | 25 +++++++++++++------------ setup.cfg | 10 ++++++++++ 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/parso/python/errors.py b/parso/python/errors.py index 8300301..956b0c0 100644 --- a/parso/python/errors.py +++ b/parso/python/errors.py @@ -6,7 +6,6 @@ from contextlib import contextmanager from parso.normalizer import Normalizer, NormalizerConfig, Issue, Rule from parso.python.tree import search_ancestor -from parso.parser import ParserSyntaxError _BLOCK_STMTS = ('if_stmt', 'while_stmt', 'for_stmt', 'try_stmt', 'with_stmt') _STAR_EXPR_PARENTS = ('testlist_star_expr', 'testlist_comp', 'exprlist') @@ -107,6 +106,7 @@ def _iter_definition_exprs_from_lists(exprlist): yield child + def _get_expr_stmt_definition_exprs(expr_stmt): exprs = [] for list_ in expr_stmt.children[:-2:2]: @@ -273,13 +273,12 @@ class ErrorFinder(Normalizer): def visit(self, node): if node.type == 'error_node': with self.visit_node(node): - # Don't need to investigate the inners of an error node. We - # might find errors in there that should be ignored, because - # the error node itself already shows that there's an issue. - return '' + # Don't need to investigate the inners of an error node. We + # might find errors in there that should be ignored, because + # the error node itself already shows that there's an issue. + return '' return super(ErrorFinder, self).visit(node) - @contextmanager def visit_node(self, node): self._check_type_rules(node) @@ -455,7 +454,7 @@ class _YieldFromCheck(SyntaxRule): def is_issue(self, leaf): return leaf.parent.type == 'yield_arg' \ - and self._normalizer.context.is_async_funcdef() + and self._normalizer.context.is_async_funcdef() @ErrorFinder.register_rule(type='name') @@ -618,7 +617,7 @@ class _FutureImportRule(SyntaxRule): allowed_futures.append('generator_stop') if name == 'braces': - self.add_issue(node, message = "not a chance") + self.add_issue(node, message="not a chance") elif name == 'barry_as_FLUFL': m = "Seriously I'm not implementing this :) ~ Dave" self.add_issue(node, message=m) @@ -715,8 +714,8 @@ class _AnnotatorRule(SyntaxRule): if not (lhs.type == 'name' # subscript/attributes are allowed or lhs.type in ('atom_expr', 'power') - and trailer.type == 'trailer' - and trailer.children[0] != '('): + and trailer.type == 'trailer' + and trailer.children[0] != '('): return True else: # x, y: str @@ -787,7 +786,8 @@ class _ArglistRule(SyntaxRule): if first == '*': if kw_unpacking_only: # foo(**kwargs, *args) - message = "iterable argument unpacking follows keyword argument unpacking" + message = "iterable argument unpacking " \ + "follows keyword argument unpacking" self.add_issue(argument, message=message) else: kw_unpacking_only = True @@ -809,6 +809,7 @@ class _ArglistRule(SyntaxRule): message = "positional argument follows keyword argument" self.add_issue(argument, message=message) + @ErrorFinder.register_rule(type='parameters') @ErrorFinder.register_rule(type='lambdef') class _ParameterRule(SyntaxRule): @@ -929,7 +930,7 @@ class _CheckAssignmentRule(SyntaxRule): elif type_ in ('testlist_star_expr', 'exprlist', 'testlist'): for child in node.children[::2]: self._check_assignment(child, is_deletion) - elif ('expr' in type_ and type_ != 'star_expr' # is a substring + elif ('expr' in type_ and type_ != 'star_expr' # is a substring or '_test' in type_ or type_ in ('term', 'factor')): error = 'operator' diff --git a/setup.cfg b/setup.cfg index 3c6e79c..1295389 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,2 +1,12 @@ [bdist_wheel] universal=1 + +[flake8] +max-line-length = 100 +ignore = + # do not use bare 'except' + E722, + # don't know why this was ever even an option, 1+1 should be possible. + E226, + # line break before binary operator + W503,