summaryrefslogtreecommitdiff
path: root/pycodestyle.py
diff options
context:
space:
mode:
authorTomer Keren <tomer.keren.dev@gmail.com>2018-12-08 01:37:22 +0200
committerIan Stapleton Cordasco <graffatcolmingov@gmail.com>2018-12-07 17:37:22 -0600
commitbd17ca651a57f8cdd278a8fac84d6a09a178a3eb (patch)
treeb85f003fd09f9f814345b58546e05bf644ba4518 /pycodestyle.py
parentc507b725d9e0bed14505f87cd2397ac7ac489485 (diff)
downloadpep8-bd17ca651a57f8cdd278a8fac84d6a09a178a3eb.tar.gz
Add whitespace around -> annotating operator (#809)
* Test for whitespace around -> operator Tests will pass after fixing issue #803 * Require whitespace around -> operator Closes: #803 * Move tests to correct cases * Whitelist python3 only tests * Fix whitespace test errors Huge thanks to @asottile! * Address code review Pushing this directly to run full testsuite on travis * :bug:Change error code to space around bitwise operator E227 * Check for -> annotation only in py3.5+ * Skip tests meant for higher versions of python * Move type annotation tests to python3.5 testsuite Type annotations were first introduced in PEP 484,https://www.python.org/dev/peps/pep-0484/ implemented in python3.5 * Shorten line skipping tests by version * Replace test skipping logic As requested in code review * Run formatting to avoid long lines
Diffstat (limited to 'pycodestyle.py')
-rwxr-xr-xpycodestyle.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/pycodestyle.py b/pycodestyle.py
index 73f4076..4372e3b 100755
--- a/pycodestyle.py
+++ b/pycodestyle.py
@@ -115,9 +115,12 @@ KEYWORDS = frozenset(keyword.kwlist + ['print', 'async']) - SINGLETONS
UNARY_OPERATORS = frozenset(['>>', '**', '*', '+', '-'])
ARITHMETIC_OP = frozenset(['**', '*', '/', '//', '+', '-'])
WS_OPTIONAL_OPERATORS = ARITHMETIC_OP.union(['^', '&', '|', '<<', '>>', '%'])
+# Warn for -> function annotation operator in py3.5+ (issue 803)
+FUNCTION_RETURN_ANNOTATION_OP = ['->'] if sys.version_info >= (3, 5) else []
WS_NEEDED_OPERATORS = frozenset([
'**=', '*=', '/=', '//=', '+=', '-=', '!=', '<>', '<', '>',
- '%=', '^=', '&=', '|=', '==', '<=', '>=', '<<=', '>>=', '='])
+ '%=', '^=', '&=', '|=', '==', '<=', '>=', '<<=', '>>=', '='] +
+ FUNCTION_RETURN_ANNOTATION_OP)
WHITESPACE = frozenset(' \t')
NEWLINE = frozenset([tokenize.NL, tokenize.NEWLINE])
SKIP_TOKENS = NEWLINE.union([tokenize.INDENT, tokenize.DEDENT])