summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CONTRIBUTING.rst6
-rwxr-xr-xpycodestyle.py7
-rw-r--r--testsuite/W60.py4
-rw-r--r--testsuite/python35.py6
-rw-r--r--testsuite/support.py7
5 files changed, 25 insertions, 5 deletions
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
index 9c29ba9..3361c46 100644
--- a/CONTRIBUTING.rst
+++ b/CONTRIBUTING.rst
@@ -76,7 +76,7 @@ The current tests are written in 2 styles:
Running unittest
~~~~~~~~~~~~~~~~
-The tests are written using stdlib `unittest` module, the existing tests
+The tests are written using stdlib ``unittest`` module, the existing tests
include unit, integration and functional tests.
To run the tests::
@@ -86,8 +86,8 @@ To run the tests::
Running functional
~~~~~~~~~~~~~~~~~~
-When installed in dev mode, pycodestyle will have the `--testsuite`
-option which can be used to run the tests::
+When installed in dev mode, pycodestyle will have the ``--testsuite`` option
+which can be used to run the tests::
$ pip install -e .
$ # Run all tests.
diff --git a/pycodestyle.py b/pycodestyle.py
index 18a16ca..9fc1874 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])
@@ -1587,7 +1590,7 @@ def python_3000_async_await_keywords(logical_line, tokens):
else:
error = True
elif state[0] == 'await':
- if token_type in (tokenize.NAME, tokenize.NUMBER, tokenize.STRING):
+ if token_type == tokenize.NAME:
# An await expression. Return to looking for async/await
# names.
state = None
diff --git a/testsuite/W60.py b/testsuite/W60.py
index aba6d32..42a8c6d 100644
--- a/testsuite/W60.py
+++ b/testsuite/W60.py
@@ -45,6 +45,10 @@ async = 42
#: W606
await = 42
#: W606
+await 42
+#: W606
+await 'test'
+#: W606
def async():
pass
#: W606
diff --git a/testsuite/python35.py b/testsuite/python35.py
new file mode 100644
index 0000000..1bedee5
--- /dev/null
+++ b/testsuite/python35.py
@@ -0,0 +1,6 @@
+#: E225
+def bar(a, b)->int:
+ pass
+#: Okay
+def baz(a, b) -> int:
+ pass
diff --git a/testsuite/support.py b/testsuite/support.py
index cbe2f46..8241a92 100644
--- a/testsuite/support.py
+++ b/testsuite/support.py
@@ -168,6 +168,13 @@ def init_tests(pep8style):
def run_tests(filename):
"""Run all the tests from a file."""
+ # Skip tests meant for higher versions of python
+ ver_match = re.search(r'python(\d)(\d)?\.py$', filename)
+ if ver_match:
+ test_against_version = tuple(int(val or 0)
+ for val in ver_match.groups())
+ if sys.version_info < test_against_version:
+ return
lines = readlines(filename) + ['#:\n']
line_offset = 0
codes = ['Okay']