From 4a37706b95a49ff61a44202f9775146de1e895db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Gr=C3=B6nholm?= Date: Fri, 8 Apr 2016 14:54:57 +0300 Subject: Fix false E251 error involving square brackets Fixed a case where a comma is erroneously interpreted as an argument separator when square brackets are used in an argument annotation with a default value. Closes #496 --- pep8.py | 4 ++-- testsuite/E25.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pep8.py b/pep8.py index ec19dc5..8ec21e1 100755 --- a/pep8.py +++ b/pep8.py @@ -794,9 +794,9 @@ def whitespace_around_named_parameter_equals(logical_line, tokens): if start != prev_end: yield (prev_end, message) if token_type == tokenize.OP: - if text == '(': + if text in '([': parens += 1 - elif text == ')': + elif text in ')]': parens -= 1 elif in_def and text == ':' and parens == 1: annotated_func_arg = True diff --git a/testsuite/E25.py b/testsuite/E25.py index ad8db88..7d00310 100644 --- a/testsuite/E25.py +++ b/testsuite/E25.py @@ -32,5 +32,6 @@ d[type(None)] = _deepcopy_atomic # Annotated Function Definitions #: Okay -def munge(input: AnyStr, sep: AnyStr = None, limit=1000) -> AnyStr: +def munge(input: AnyStr, sep: AnyStr = None, limit=1000, + extra: Union[str, dict] = None) -> AnyStr: pass -- cgit v1.2.1