summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdi Roiban <adi.roiban@chevah.com>2018-03-24 13:06:24 +0000
committerIan Stapleton Cordasco <graffatcolmingov@gmail.com>2018-03-24 08:06:24 -0500
commit368e62cb6c57ff386b5a08659a5a9d2866b80a2f (patch)
treedc4b1abdfa67d1dbaef745d8203293df8ecd3a3e
parenteb91b79ab38aad4d44a3b52b02605412f32ba5ae (diff)
downloadpep8-368e62cb6c57ff386b5a08659a5a9d2866b80a2f.tar.gz
Finalize support for Python 3.7
Python 3.7 added a warning for a future feature of nested regular expressions. To avoid this warning we escape what is not a nested regex. This also keeps track of the `async` keyword and handles it appropriately. Closes gh-728
-rwxr-xr-xpycodestyle.py4
-rw-r--r--testsuite/E25.py2
-rw-r--r--testsuite/E30.py2
-rw-r--r--testsuite/E70.py2
4 files changed, 5 insertions, 5 deletions
diff --git a/pycodestyle.py b/pycodestyle.py
index 5f02187..3e574c8 100755
--- a/pycodestyle.py
+++ b/pycodestyle.py
@@ -102,7 +102,7 @@ REPORT_FORMAT = {
PyCF_ONLY_AST = 1024
SINGLETONS = frozenset(['False', 'None', 'True'])
-KEYWORDS = frozenset(keyword.kwlist + ['print']) - SINGLETONS
+KEYWORDS = frozenset(keyword.kwlist + ['print', 'async']) - SINGLETONS
UNARY_OPERATORS = frozenset(['>>', '**', '*', '+', '-'])
ARITHMETIC_OP = frozenset(['**', '*', '/', '//', '+', '-'])
WS_OPTIONAL_OPERATORS = ARITHMETIC_OP.union(['^', '&', '|', '<<', '>>', '%'])
@@ -121,7 +121,7 @@ RAISE_COMMA_REGEX = re.compile(r'raise\s+\w+\s*,')
RERAISE_COMMA_REGEX = re.compile(r'raise\s+\w+\s*,.*,\s*\w+\s*$')
ERRORCODE_REGEX = re.compile(r'\b[A-Z]\d{3}\b')
DOCSTRING_REGEX = re.compile(r'u?r?["\']')
-EXTRANEOUS_WHITESPACE_REGEX = re.compile(r'[[({] | []}),;:]')
+EXTRANEOUS_WHITESPACE_REGEX = re.compile(r'[\[({] | [\]}),;:]')
WHITESPACE_AFTER_COMMA_REGEX = re.compile(r'[,;:]\s*(?: |\t)')
COMPARE_SINGLETON_REGEX = re.compile(r'(\bNone|\bFalse|\bTrue)?\s*([=!]=)'
r'\s*(?(1)|(None|False|True))\b')
diff --git a/testsuite/E25.py b/testsuite/E25.py
index 71d3f80..55ed438 100644
--- a/testsuite/E25.py
+++ b/testsuite/E25.py
@@ -39,7 +39,7 @@ def munge(input: AnyStr, sep: AnyStr = None, limit=1000,
async def add(a: int = 0, b: int = 0) -> int:
return a + b
# Previously E251 four times
-#: E272:1:6
+#: E271:1:6
async def add(a: int = 0, b: int = 0) -> int:
return a + b
#: E252:1:15 E252:1:16 E252:1:27 E252:1:36
diff --git a/testsuite/E30.py b/testsuite/E30.py
index bd74b80..ad5518b 100644
--- a/testsuite/E30.py
+++ b/testsuite/E30.py
@@ -157,7 +157,7 @@ def main():
if __name__ == '__main__':
main()
# Previously just E272:1:6 E272:4:6
-#: E302:4:1 E272:1:6 E272:4:6
+#: E302:4:1 E271:1:6 E271:4:6
async def x():
pass
diff --git a/testsuite/E70.py b/testsuite/E70.py
index caafe45..7c01edb 100644
--- a/testsuite/E70.py
+++ b/testsuite/E70.py
@@ -14,7 +14,7 @@ del a[:]; a.append(42);
def f(x): return 2
#: E704:1:1
async def f(x): return 2
-#: E704:1:1 E272:1:6
+#: E704:1:1 E271:1:6
async def f(x): return 2
#: E704:1:1 E226:1:19
def f(x): return 2*x