summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Sottile <asottile@umich.edu>2021-05-20 07:23:19 -0700
committerGitHub <noreply@github.com>2021-05-20 07:23:19 -0700
commitf3b1b44bf3d2d5927004fa1c2fcf1ab2def816b9 (patch)
tree4974e580839247c7932a5a5935f2a232245d33b7
parent95fe313ba5ca384041472cd171ea60fad910c207 (diff)
downloadpyflakes-f3b1b44bf3d2d5927004fa1c2fcf1ab2def816b9.tar.gz
fix syntax error offsets for python 3.10 (#635)
-rw-r--r--.github/workflows/test.yml2
-rw-r--r--pyflakes/test/test_api.py43
-rw-r--r--tox.ini2
3 files changed, 30 insertions, 17 deletions
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 39ba139..8c078ae 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -8,7 +8,7 @@ jobs:
strategy:
fail-fast: false
matrix:
- python-version: ["2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "pypy2", "pypy3"]
+ python-version: ["2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10-dev", "pypy2", "pypy3"]
os: [ubuntu-latest]
# Include py2 + minimum py3 + maximum py3 + pypy + pypy3 on Windows
include:
diff --git a/pyflakes/test/test_api.py b/pyflakes/test/test_api.py
index d379b3b..2c1cf19 100644
--- a/pyflakes/test/test_api.py
+++ b/pyflakes/test/test_api.py
@@ -441,7 +441,7 @@ def baz():
evaluate(source)
except SyntaxError:
e = sys.exc_info()[1]
- if not PYPY:
+ if not PYPY and sys.version_info < (3, 10):
self.assertTrue(e.text.count('\n') > 1)
else:
self.fail()
@@ -449,10 +449,17 @@ def baz():
with self.makeTempFile(source) as sourcePath:
if PYPY:
message = 'end of file (EOF) while scanning triple-quoted string literal'
+ elif sys.version_info >= (3, 10):
+ message = 'unterminated triple-quoted string literal (detected at line 8)' # noqa: E501
else:
message = 'invalid syntax'
- column = 8 if sys.version_info >= (3, 8) else 11
+ if sys.version_info >= (3, 10):
+ column = 12
+ elif sys.version_info >= (3, 8):
+ column = 8
+ else:
+ column = 11
self.assertHasErrors(
sourcePath,
["""\
@@ -468,21 +475,25 @@ def baz():
"""
with self.makeTempFile("def foo(") as sourcePath:
if PYPY:
- result = """\
-%s:1:7: parenthesis is never closed
-def foo(
- ^
-""" % (sourcePath,)
+ msg = 'parenthesis is never closed'
+ elif sys.version_info >= (3, 10):
+ msg = "'(' was never closed"
else:
- result = """\
-%s:1:9: unexpected EOF while parsing
-def foo(
- ^
-""" % (sourcePath,)
+ msg = 'unexpected EOF while parsing'
- self.assertHasErrors(
- sourcePath,
- [result])
+ if PYPY:
+ column = 7
+ elif sys.version_info >= (3, 10):
+ column = 8
+ else:
+ column = 9
+
+ spaces = ' ' * (column - 1)
+ expected = '{}:1:{}: {}\ndef foo(\n{}^\n'.format(
+ sourcePath, column, msg, spaces
+ )
+
+ self.assertHasErrors(sourcePath, [expected])
def test_eofSyntaxErrorWithTab(self):
"""
@@ -515,6 +526,8 @@ def foo(bar=baz, bax):
if ERROR_HAS_LAST_LINE:
if PYPY:
column = 7
+ elif sys.version_info >= (3, 10):
+ column = 18
elif sys.version_info >= (3, 9):
column = 21
elif sys.version_info >= (3, 8):
diff --git a/tox.ini b/tox.ini
index c88831a..0396f02 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,7 +1,7 @@
[tox]
skip_missing_interpreters = True
envlist =
- py27,py34,py35,py36,py37,py38,pypy,pypy3
+ py27,py35,py36,py37,py38,py39,py310,pypy,pypy3
[testenv]
deps = flake8==3.6.0