diff options
-rwxr-xr-x | pycodestyle.py | 5 | ||||
-rw-r--r-- | testsuite/python35.py | 6 | ||||
-rw-r--r-- | testsuite/support.py | 7 |
3 files changed, 17 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]) 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'] |