dev-python/pyflakes: Sync with gentoo

It's from gentoo commit 4310a23bf61f2afcb1e696e5b96baed8afcac903.
This commit is contained in:
Krzesimir Nowak 2021-11-17 21:05:32 +01:00
parent 81593b01b3
commit 6f7bb2a810
13 changed files with 263 additions and 426 deletions

View File

@ -1,14 +1,3 @@
AUX 1.0.0-fix-pypy-tests.patch 9242 SHA256 fe0ba7b792e54ff3208ad73f2f1350e9654689259121292c74ca3ba9709e8519 SHA512 4772c32ea90e163030953f3ade2bd2434a10cf0e3c9234f4acaf596a44a812581ba92ef1498998566a7bf78e1bb8c7051260ebf8aca4ca2cd3a04e21e307bbfc WHIRLPOOL a03c86520964ae7a2e48ccc0d532a6e1c2182792cb745438cfdeb4e8144f7a3e112723a6958ea20ce38a610299a68501783f3e3b4c1650463ae485eb94f0bb92
DIST pyflakes-0.7.2.tar.gz 30107 SHA256 e971804569e26a120ded70ca94882cbbf360390538fc3b5861f8ccecaf291178 SHA512 9f50c78ae47f55e30ed264b351325321f6c5d889ca6b2c7509d6c5cb029e27c230849cecc729bb18664cc2eb3d003a38a2e7a20f48563b6fa72c621a783bea64 WHIRLPOOL b23d09999a550784769444fdb1f3592dd54b1938b73e1ec40951eab5d3fad3dc80c0c79fbaa31e1544d74b5c8bcd96ca2f01ee83e0e79d8bfb6228308c20ae4c
DIST pyflakes-0.8.1.tar.gz 32981 SHA256 3fa80a10b36d51686bf7744f5dc99622cd5c98ce8ed64022e629868aafc17769 SHA512 b9843637891f3e82a8430121395ceb4ec5df48b5ba73b96a307ebcb4a393e8cebee1681e094ee1f71a85b58bd2f32562b78fbd61d3fa85634f3ac448b1244637 WHIRLPOOL 0939b6ded3659e53316e6707ca5bf57a6702073c376df611a6a473c43ada36ee8822c9bbf2e106cc1836b46f04ce90612f4ebc73c6cb2d557aa6edb89d0eb949
DIST pyflakes-1.0.0.tar.gz 35365 SHA256 f39e33a4c03beead8774f005bd3ecf0c3f2f264fa0201de965fce0aff1d34263 SHA512 89a9ee2e5be87d32d5c259c0cb88bbeadb96d27a3bc5eb3cf6f86afa51907ea01107a5336decbf003679b7de65ed9a16d7fbf55a457e0c9bbb1b53500f719bcb WHIRLPOOL c4700fcb9f9a62ed8e38db5c2fb7376b1d03e85b1e1f9fb7d570eb905249337f204664fd87a94b32701c0c67fa8624749d36b64721cb0425bad36ded5da26cdb
DIST pyflakes-1.2.3.tar.gz 44776 SHA256 2e4a1b636d8809d8f0a69f341acf15b2e401a3221ede11be439911d23ce2139e SHA512 e0b49b4cd388b39c4f4f5ab836520cfc2ee940ce24de084fbeca0a2f13beca23b3ca89741e297a6f450d211ec27ebd91a7d23a80105e50d14960a3888d7693f2 WHIRLPOOL adf0d723bf79591d9cd321925bf3974a4456c864bbe7144260c6c99efa76399c0ba3bb25d7322a9e16621b2226a58899731a19b9971f55c27cb19757c5c6781e
DIST pyflakes-1.5.0.tar.gz 47526 SHA256 aa0d4dff45c0cc2214ba158d29280f8fa1129f3e87858ef825930845146337f4 SHA512 32a676bab3ee7e528b7425b4b9dd5f4e5bdf57c983e2eac9e46f029b98683a55a5281b08886a0ced464db5b5d52213a00822ee86096098a4c55828ffa229b501 WHIRLPOOL 7a1b5ef9632d92eaab931e254a99df755dcf72811b13418cfd31785505defb5c36036bae2a73536dde1d70bbe1395b894b9c9ac85b0b0d00f506d213ba365b08
EBUILD pyflakes-0.7.2.ebuild 718 SHA256 d44c00a8b5177c117d7038a50f8783768c75bbccf8045ecb54f7e7200c585fdc SHA512 5e57b51f4370dd6b1f23e269dd17548424058e80e340d7e75d915188dd8fdf002c3f54be6df4c2c911a7ff51abe9fa8bb439127c3c4d37e30e69d117117848ab WHIRLPOOL 84abbeba1878e5df81f5ced0e4e5a50e7eb535353badb8a1ae702877f48665baece77e208fda87bce0f95352056c602f57380262094e5e1be5a9f0a97d1b260b
EBUILD pyflakes-0.8.1.ebuild 729 SHA256 8899fe8fddd1714fd3d6742a72f93ed6578e56bfdcadc1b895cbb935ae42ffea SHA512 dfa0476c0215e3162ec398b78fb42141a9113f11a6bd0f7ba2ff617aacf6d2af26146ddf1a6eaf053164fe9e32444edd23bc09644dcd28a76b226832908dc9c2 WHIRLPOOL b2c97df2addeaede05076eaf4fca64f1f5b72ac95d6603c023c1bead1bf716d263c43abddf8986881e99ea9d7ed5517f76736c62fcb3d8299949674837e3da81
EBUILD pyflakes-1.0.0.ebuild 760 SHA256 0c2d8a5b9acc3fff2c46352b9842a185330ffa339c72537a5d8f633778a74ec8 SHA512 3c01eddbbd902dab6614b04884b8da0c3a9026b54a73572fb778ab2fc43ee30e69642e19fe54825d5965c2a5b68d0ef8f884f10bdcb801d4049ac55d873a4513 WHIRLPOOL 26964fcfa336cea0fc4be7f81fb714904a19decfb14beea660bb6a181779700e0e9609eafe8fc95e0b42f1fcaa7e93369753c4bce2be14b47ad848d9aa1f7e57
EBUILD pyflakes-1.2.3.ebuild 703 SHA256 356990109e54b64db8b0a23c7f1c27b364086ea12e23d84e049b638654be6094 SHA512 b6d811f6e3a4c3e73abcbf3a457de3676641d65b4a7e8b6df6ea047ba7a19bc672cb14e8683333b41b6ab481d7105b5a657611336c0f0b9bcfeb46c82d312e6a WHIRLPOOL 58054c052c6d1b1b4c2ef982e8c05f579b9259ed4a569fb98a6a3a1f31baadbed0e7bf06701b38e67ba6c11b407c33f24ade924c9c5414f37d7ba69bff3f410c
EBUILD pyflakes-1.5.0.ebuild 711 SHA256 15351153b428cdf2978929456d7378a7ce0245ece6da4f08c9dc3a10841200b5 SHA512 702e018268b3fdfa08183d909bd4d20f45412afe89ae1a78fb48cdefbc0f7f2264b1f7bd54b5bdf56c6ef2cdd3463316f35b1059b8059ff6b2517b2ac6435e8f WHIRLPOOL c6681ac56bc3fa6059dda2c343d8a4a9ffb51002c581fd738c8a18a57e02ba0b8633b21e65a818431caddba96060b517956cde575fee7d35a2fd887581f5dcd8
MISC ChangeLog 5089 SHA256 819ca1642ab7a9ead72f88aa9b6fc32564a3e9e84e6cde15d8966fe691d3085b SHA512 537999ec9dc0708b07dd2c35935fbd9740d774268c6549a33633b8aaddc309d967e7fbf9327b68019984a740dc1c9d6c3607a4d0785a6c88a102b8b1131e110a WHIRLPOOL 989383545aeb6e292b94f568d4b8329291150b38c478b6c9ac01a3300e2e34dcb5ec463ddf4f1eb4ceaba95b1f5738378812c83091a8d4c2cbf4d35d8b54be7d
MISC ChangeLog-2015 7279 SHA256 b8c0cf5b4b6aa2161fb3479721495248780a975febcacbbe5741163fb49d6b29 SHA512 8edef4e7ef1dd626b972b39b3483f0af4e6b6b55b21e9cc479904f5124091e417357b1f050cf6a99ec853716721055dac35d5dda4cfd14e5008fb1a289f39d68 WHIRLPOOL e1fd24feb36b9288832ce8142a8163c0c8091fc4f061e1c4aa7adce749975e73707cbd16e4c7bcfb3d43c3fd373b429a63141b0db29f4d38e5a31f1e00b8cfba
MISC metadata.xml 731 SHA256 9d4072da51cb08ba2424db827e2357d779c1f477ea11edf17e2cb53d6200601a SHA512 8963649976b8d2598a4b4bf285410c753df338d2a3469faf7bff4a38231585a64ed37b6717119a3f9e73a0ee2d02685162e3da637e6741271707c9e716a93594 WHIRLPOOL 07bcd0ca31a0789c5a7fbca55370fc6eb4d8e84d47f489c71e9a23930bf68ecfdd1100c1fcfb6e73b53a834d2aa7940570ff7aa6ade12bc3e051960017993574
DIST pyflakes-2.2.0.tar.gz 65307 BLAKE2B e48e0cb0497f90b6482c0fd08c182d766ab50755fe348352df510841f4ad43f7c1d6486753ce774603a3624f49c9b0165ad930bb1451ef30cf2e828d732e0652 SHA512 6a411efef261874c216b71bcb095412448a8cbeefdf7fa5577d4f4edd48a4a740a4433665e87e5dda2c08fd9ee3bfb7f134f56c7523e1303243edfa92b0ccb35
DIST pyflakes-2.3.1.tar.gz 68567 BLAKE2B 0eee1eb87bf1dcae68afcdb250644aa8a1189ca3d8d22608e25727bf01b94465cceb6c65be669b18779434c8879594dd92cfb3a108b7aff584cfda788f6e2f4f SHA512 85d3a2737d31ed4b5f4c2e3621759a5951d1320f95d74313fec09fa551648105b3ab84db94f7bffe5b77623e4adbea1d8ad12b9ce2fee7e81c41581a3ea81cc6
DIST pyflakes-2.4.0.tar.gz 69101 BLAKE2B 852e50f3545138947761f9a8413fd6463bb9a28977c008feb1c3a81afb3854501b8fd3c05840d9d75bc6ebf505b545e62c047b87780b0bc764fd4225ea6a1e21 SHA512 f4c6512eb811511c897623f52c4f88e50275a3292582d7dd34462e90e39fecce939818cb92e750eebdd66eab25b91c23540104fc4530c42621d7cfeb1d33c577

View File

@ -1,282 +0,0 @@
#https://github.com/jayvdb/pyflakes/commit/3088ffbd6256521e0213b361bc2294c1e218e6fb
diff --git a/pyflakes/api.py b/pyflakes/api.py #index 3bc2330..2a46a0d 100644
--- a/pyflakes/api.py
+++ b/pyflakes/api.py
@@ -41,6 +41,18 @@ def check(codeString, filename, reporter=None):
(lineno, offset, text) = value.lineno, value.offset, value.text
+ if checker.PYPY:
+ if text is None:
+ lines = codeString.splitlines()
+ if len(lines) >= lineno:
+ text = lines[lineno - 1]
+ if sys.version_info >= (3, ) and isinstance(text, bytes):
+ try:
+ text = text.decode('ascii')
+ except UnicodeDecodeError:
+ text = None
+ offset -= 1
+
# If there's an encoding problem with the file, the text is None.
if text is None:
# Avoid using msg, since for the only known case, it contains a
diff --git a/pyflakes/checker.py b/pyflakes/checker.py
index 753fa9b..f538d3f 100644
--- a/pyflakes/checker.py
+++ b/pyflakes/checker.py
@@ -11,6 +11,12 @@
PY2 = sys.version_info < (3, 0)
PY32 = sys.version_info < (3, 3) # Python 2.5 to 3.2
PY33 = sys.version_info < (3, 4) # Python 2.5 to 3.3
+try:
+ sys.pypy_version_info
+ PYPY = True
+except AttributeError:
+ PYPY = False
+
builtin_vars = dir(__import__('__builtin__' if PY2 else 'builtins'))
try:
@@ -594,8 +600,13 @@ def getDocstring(self, node):
node = node.value
if not isinstance(node, ast.Str):
return (None, None)
- # Computed incorrectly if the docstring has backslash
- doctest_lineno = node.lineno - node.s.count('\n') - 1
+
+ if PYPY:
+ doctest_lineno = node.lineno - 1
+ else:
+ # Computed incorrectly if the docstring has backslash
+ doctest_lineno = node.lineno - node.s.count('\n') - 1
+
return (node.s, doctest_lineno)
def handleNode(self, node, parent):
@@ -642,6 +653,8 @@ def handleDoctests(self, node):
tree = compile(example.source, "<doctest>", "exec", ast.PyCF_ONLY_AST)
except SyntaxError:
e = sys.exc_info()[1]
+ if PYPY:
+ e.offset += 1
position = (node_lineno + example.lineno + e.lineno,
example.indent + 4 + (e.offset or 0))
self.report(messages.DoctestSyntaxError, node, position)
diff --git a/pyflakes/test/test_api.py b/pyflakes/test/test_api.py
index 34a59bc..d2a5036 100644
--- a/pyflakes/test/test_api.py
+++ b/pyflakes/test/test_api.py
@@ -23,6 +23,14 @@
from io import StringIO
unichr = chr
+try:
+ sys.pypy_version_info
+ PYPY = True
+except AttributeError:
+ PYPY = False
+
+ERROR_HAS_COL_NUM = ERROR_HAS_LAST_LINE = sys.version_info >= (3, 2) or PYPY
+
def withStderrTo(stderr, f, *args, **kwargs):
"""
@@ -312,18 +320,25 @@ def evaluate(source):
evaluate(source)
except SyntaxError:
e = sys.exc_info()[1]
- self.assertTrue(e.text.count('\n') > 1)
+ if not PYPY:
+ self.assertTrue(e.text.count('\n') > 1)
else:
self.fail()
sourcePath = self.makeTempFile(source)
+
+ if PYPY:
+ message = 'EOF while scanning triple-quoted string literal'
+ else:
+ message = 'invalid syntax'
+
self.assertHasErrors(
sourcePath,
["""\
-%s:8:11: invalid syntax
+%s:8:11: %s
'''quux'''
^
-""" % (sourcePath,)])
+""" % (sourcePath, message)])
def test_eofSyntaxError(self):
"""
@@ -331,13 +346,22 @@ def test_eofSyntaxError(self):
syntax error reflects the cause for the syntax error.
"""
sourcePath = self.makeTempFile("def foo(")
- self.assertHasErrors(
- sourcePath,
- ["""\
+ if PYPY:
+ result = """\
+%s:1:7: parenthesis is never closed
+def foo(
+ ^
+""" % (sourcePath,)
+ else:
+ result = """\
%s:1:9: unexpected EOF while parsing
def foo(
^
-""" % (sourcePath,)])
+""" % (sourcePath,)
+
+ self.assertHasErrors(
+ sourcePath,
+ [result])
def test_eofSyntaxErrorWithTab(self):
"""
@@ -345,13 +369,16 @@ def test_eofSyntaxErrorWithTab(self):
syntax error reflects the cause for the syntax error.
"""
sourcePath = self.makeTempFile("if True:\n\tfoo =")
+ column = 5 if PYPY else 7
+ last_line = '\t ^' if PYPY else '\t ^'
+
self.assertHasErrors(
sourcePath,
["""\
-%s:2:7: invalid syntax
+%s:2:%s: invalid syntax
\tfoo =
-\t ^
-""" % (sourcePath,)])
+%s
+""" % (sourcePath, column, last_line)])
def test_nonDefaultFollowsDefaultSyntaxError(self):
"""
@@ -364,8 +391,8 @@ def foo(bar=baz, bax):
pass
"""
sourcePath = self.makeTempFile(source)
- last_line = ' ^\n' if sys.version_info >= (3, 2) else ''
- column = '8:' if sys.version_info >= (3, 2) else ''
+ last_line = ' ^\n' if ERROR_HAS_LAST_LINE else ''
+ column = '8:' if ERROR_HAS_COL_NUM else ''
self.assertHasErrors(
sourcePath,
["""\
@@ -383,8 +410,8 @@ def test_nonKeywordAfterKeywordSyntaxError(self):
foo(bar=baz, bax)
"""
sourcePath = self.makeTempFile(source)
- last_line = ' ^\n' if sys.version_info >= (3, 2) else ''
- column = '13:' if sys.version_info >= (3, 2) else ''
+ last_line = ' ^\n' if ERROR_HAS_LAST_LINE else ''
+ column = '13:' if ERROR_HAS_COL_NUM or PYPY else ''
if sys.version_info >= (3, 5):
message = 'positional argument follows keyword argument'
@@ -407,8 +434,15 @@ def test_invalidEscape(self):
sourcePath = self.makeTempFile(r"foo = '\xyz'")
if ver < (3,):
decoding_error = "%s: problem decoding source\n" % (sourcePath,)
+ elif PYPY:
+ # pypy3 only
+ decoding_error = """\
+%s:1:6: %s: ('unicodeescape', b'\\\\xyz', 0, 2, 'truncated \\\\xXX escape')
+foo = '\\xyz'
+ ^
+""" % (sourcePath, 'UnicodeDecodeError')
else:
- last_line = ' ^\n' if ver >= (3, 2) else ''
+ last_line = ' ^\n' if ERROR_HAS_LAST_LINE else ''
# Column has been "fixed" since 3.2.4 and 3.3.1
col = 1 if ver >= (3, 3, 1) or ((3, 2, 4) <= ver < (3, 3)) else 2
decoding_error = """\
@@ -474,8 +508,21 @@ def test_misencodedFileUTF8(self):
x = "%s"
""" % SNOWMAN).encode('utf-8')
sourcePath = self.makeTempFile(source)
+
+ if PYPY and sys.version_info < (3, ):
+ message = ('\'ascii\' codec can\'t decode byte 0xe2 '
+ 'in position 21: ordinal not in range(128)')
+ result = """\
+%s:0:0: %s
+x = "\xe2\x98\x83"
+ ^\n""" % (sourcePath, message)
+
+ else:
+ message = 'problem decoding source'
+ result = "%s: problem decoding source\n" % (sourcePath,)
+
self.assertHasErrors(
- sourcePath, ["%s: problem decoding source\n" % (sourcePath,)])
+ sourcePath, [result])
def test_misencodedFileUTF16(self):
"""
diff --git a/pyflakes/test/test_doctests.py b/pyflakes/test/test_doctests.py
index f15acb8..6793da9 100644
--- a/pyflakes/test/test_doctests.py
+++ b/pyflakes/test/test_doctests.py
@@ -1,3 +1,4 @@
+import sys
import textwrap
from pyflakes import messages as m
@@ -11,6 +12,12 @@
from pyflakes.test.test_undefined_names import Test as TestUndefinedNames
from pyflakes.test.harness import TestCase, skip
+try:
+ sys.pypy_version_info
+ PYPY = True
+except AttributeError:
+ PYPY = False
+
class _DoctestMixin(object):
@@ -273,12 +280,22 @@ def doctest_stuff():
exc = exceptions[0]
self.assertEqual(exc.lineno, 4)
self.assertEqual(exc.col, 26)
+
+ # PyPy error column offset is 0,
+ # for the second and third line of the doctest
+ # i.e. at the beginning of the line
exc = exceptions[1]
self.assertEqual(exc.lineno, 5)
- self.assertEqual(exc.col, 16)
+ if PYPY:
+ self.assertEqual(exc.col, 13)
+ else:
+ self.assertEqual(exc.col, 16)
exc = exceptions[2]
self.assertEqual(exc.lineno, 6)
- self.assertEqual(exc.col, 18)
+ if PYPY:
+ self.assertEqual(exc.col, 13)
+ else:
+ self.assertEqual(exc.col, 18)
def test_indentationErrorInDoctest(self):
exc = self.flakes('''
@@ -289,7 +306,10 @@ def doctest_stuff():
"""
''', m.DoctestSyntaxError).messages[0]
self.assertEqual(exc.lineno, 5)
- self.assertEqual(exc.col, 16)
+ if PYPY:
+ self.assertEqual(exc.col, 13)
+ else:
+ self.assertEqual(exc.col, 16)
def test_offsetWithMultiLineArgs(self):
(exc1, exc2) = self.flakes(

View File

@ -0,0 +1,97 @@
diff --git a/pyflakes/test/test_api.py b/pyflakes/test/test_api.py
index b579ac8..d379b3b 100644
--- a/pyflakes/test/test_api.py
+++ b/pyflakes/test/test_api.py
@@ -515,8 +513,10 @@ def foo(bar=baz, bax):
"""
with self.makeTempFile(source) as sourcePath:
if ERROR_HAS_LAST_LINE:
- if PYPY and sys.version_info >= (3,):
+ if PYPY:
column = 7
+ elif sys.version_info >= (3, 9):
+ column = 21
elif sys.version_info >= (3, 8):
column = 9
else:
@@ -543,8 +543,10 @@ foo(bar=baz, bax)
"""
with self.makeTempFile(source) as sourcePath:
if ERROR_HAS_LAST_LINE:
- if PYPY and sys.version_info >= (3,):
+ if PYPY:
column = 12
+ elif sys.version_info >= (3, 9):
+ column = 17
elif sys.version_info >= (3, 8):
column = 14
else:
@@ -578,7 +580,9 @@ foo(bar=baz, bax)
else:
position_end = 1
if PYPY:
- column = 6
+ column = 5
+ elif ver >= (3, 9):
+ column = 13
else:
column = 7
# Column has been "fixed" since 3.2.4 and 3.3.1
@@ -717,13 +721,6 @@ class IntegrationTests(TestCase):
"""
Tests of the pyflakes script that actually spawn the script.
"""
-
- # https://bitbucket.org/pypy/pypy/issues/3069/pypy36-on-windows-incorrect-line-separator
- if PYPY and sys.version_info >= (3,) and WIN:
- LINESEP = '\n'
- else:
- LINESEP = os.linesep
-
def setUp(self):
self.tempdir = tempfile.mkdtemp()
self.tempfilepath = os.path.join(self.tempdir, 'temp')
@@ -784,7 +781,7 @@ class IntegrationTests(TestCase):
fd.write("import contraband\n".encode('ascii'))
d = self.runPyflakes([self.tempfilepath])
expected = UnusedImport(self.tempfilepath, Node(1), 'contraband')
- self.assertEqual(d, ("%s%s" % (expected, self.LINESEP), '', 1))
+ self.assertEqual(d, ("%s%s" % (expected, os.linesep), '', 1))
def test_errors_io(self):
"""
@@ -794,7 +791,7 @@ class IntegrationTests(TestCase):
"""
d = self.runPyflakes([self.tempfilepath])
error_msg = '%s: No such file or directory%s' % (self.tempfilepath,
- self.LINESEP)
+ os.linesep)
self.assertEqual(d, ('', error_msg, 1))
def test_errors_syntax(self):
@@ -807,7 +804,7 @@ class IntegrationTests(TestCase):
fd.write("import".encode('ascii'))
d = self.runPyflakes([self.tempfilepath])
error_msg = '{0}:1:{2}: invalid syntax{1}import{1} {3}^{1}'.format(
- self.tempfilepath, self.LINESEP, 6 if PYPY else 7, '' if PYPY else ' ')
+ self.tempfilepath, os.linesep, 6 if PYPY else 7, '' if PYPY else ' ')
self.assertEqual(d, ('', error_msg, 1))
def test_readFromStdin(self):
@@ -816,15 +813,13 @@ class IntegrationTests(TestCase):
"""
d = self.runPyflakes([], stdin='import contraband')
expected = UnusedImport('<stdin>', Node(1), 'contraband')
- self.assertEqual(d, ("%s%s" % (expected, self.LINESEP), '', 1))
+ self.assertEqual(d, ("%s%s" % (expected, os.linesep), '', 1))
class TestMain(IntegrationTests):
"""
Tests of the pyflakes main function.
"""
- LINESEP = os.linesep
-
def runPyflakes(self, paths, stdin=None):
try:
with SysStreamCapturing(stdin) as capture:

View File

@ -0,0 +1,91 @@
From f3b1b44bf3d2d5927004fa1c2fcf1ab2def816b9 Mon Sep 17 00:00:00 2001
From: Anthony Sottile <asottile@umich.edu>
Date: Thu, 20 May 2021 07:23:19 -0700
Subject: [PATCH] fix syntax error offsets for python 3.10 (#635)
---
.github/workflows/test.yml | 2 +-
pyflakes/test/test_api.py | 43 +++++++++++++++++++++++++-------------
tox.ini | 2 +-
3 files changed, 30 insertions(+), 17 deletions(-)
diff --git a/pyflakes/test/test_api.py b/pyflakes/test/test_api.py
index d379b3b7..2c1cf19d 100644
--- a/pyflakes/test/test_api.py
+++ b/pyflakes/test/test_api.py
@@ -441,7 +441,7 @@ def evaluate(source):
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 evaluate(source):
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 test_eofSyntaxError(self):
"""
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):

View File

@ -1,18 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
<maintainer type="project">
<email>python@gentoo.org</email>
<name>Python</name>
</maintainer>
<longdescription>PyFlakes is a Lint-like tool for Python, like PyChecker. It is
focused on identifying common errors quickly without executing
Python code.
Its primary advantage over PyChecker is that it is fast. You don't
have to sit around for minutes waiting for the checker to run; it
runs on most large projects in only a few seconds.</longdescription>
<longdescription>
PyFlakes is a Lint-like tool for Python, like PyChecker. It is focused
on identifying common errors quickly without executing Python code.
Its primary advantage over PyChecker is that it is fast. You don't have
to sit around for minutes waiting for the checker to run; it runs on
most large projects in only a few seconds.
</longdescription>
<stabilize-allarches/>
<upstream>
<remote-id type="pypi">pyflakes</remote-id>
<remote-id type="launchpad">pyflakes</remote-id>
<remote-id type="github">PyCQA/pyflakes</remote-id>
</upstream>
</pkgmetadata>

View File

@ -1,26 +0,0 @@
# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
EAPI=5
PYTHON_COMPAT=(python2_7 )
inherit distutils-r1
DESCRIPTION="Passive checker for Python programs"
HOMEPAGE="https://launchpad.net/pyflakes https://pypi.python.org/pypi/pyflakes"
SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
LICENSE="MIT"
SLOT="0"
KEYWORDS="amd64 ~ppc ~ppc64 x86 ~amd64-linux ~arm-linux ~x86-linux ~x86-macos"
IUSE="test"
RDEPEND="dev-python/setuptools[${PYTHON_USEDEP}]"
DEPEND="${RDEPEND}
test? ( dev-python/unittest2[${PYTHON_USEDEP}] )"
python_test() {
# a known failure of 1 test in py3.2.4
# https://bugs.launchpad.net/pyflakes/+bug/1172463
esetup.py test --quiet
}

View File

@ -1,26 +0,0 @@
# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
EAPI=5
PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
inherit distutils-r1
DESCRIPTION="Passive checker for Python programs"
HOMEPAGE="https://launchpad.net/pyflakes https://pypi.python.org/pypi/pyflakes"
SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
LICENSE="MIT"
SLOT="0"
KEYWORDS="alpha amd64 arm hppa ia64 ppc ppc64 sparc x86 ~amd64-linux ~arm-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
IUSE=""
DEPEND="dev-python/setuptools[${PYTHON_USEDEP}]"
RDEPEND="${DEPEND}"
DOCS=(AUTHORS NEWS.txt README.rst)
python_test() {
esetup.py test --quiet
}

View File

@ -1,25 +0,0 @@
# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
EAPI=5
PYTHON_COMPAT=( python2_7 python3_{4,5,6} pypy )
inherit distutils-r1
DESCRIPTION="Passive checker for Python programs"
HOMEPAGE="https://launchpad.net/pyflakes https://pypi.python.org/pypi/pyflakes"
SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
LICENSE="MIT"
SLOT="0"
KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~ppc ~ppc64 ~sparc ~x86 ~amd64-linux ~arm-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
IUSE=""
DEPEND="dev-python/setuptools[${PYTHON_USEDEP}]"
RDEPEND="${DEPEND}"
PATCHES=( "${FILESDIR}"/${PV}-fix-pypy-tests.patch )
python_test() {
esetup.py test --quiet
}

View File

@ -1,23 +0,0 @@
# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
EAPI=6
PYTHON_COMPAT=( python2_7 python3_{4,5,6} pypy pypy3 )
inherit distutils-r1
DESCRIPTION="Passive checker for Python programs"
HOMEPAGE="https://launchpad.net/pyflakes https://pypi.python.org/pypi/pyflakes"
SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
LICENSE="MIT"
SLOT="0"
KEYWORDS="alpha amd64 arm hppa ia64 ppc ppc64 sparc x86 ~amd64-linux ~arm-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
IUSE=""
DEPEND="dev-python/setuptools[${PYTHON_USEDEP}]"
RDEPEND="${DEPEND}"
python_test() {
esetup.py test --quiet
}

View File

@ -1,22 +0,0 @@
# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
EAPI=6
PYTHON_COMPAT=( python2_7 python3_{4,5,6} pypy pypy3 )
inherit distutils-r1
DESCRIPTION="Passive checker for Python programs"
HOMEPAGE="https://launchpad.net/pyflakes https://pypi.python.org/pypi/pyflakes"
SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
LICENSE="MIT"
SLOT="0"
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~ppc ~ppc64 ~sparc ~x86 ~amd64-linux ~arm-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
DEPEND="dev-python/setuptools[${PYTHON_USEDEP}]"
RDEPEND="${DEPEND}"
python_test() {
esetup.py test --quiet
}

View File

@ -0,0 +1,23 @@
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=7
PYTHON_COMPAT=( pypy3 python3_{7..9} )
# Uses pkg_resources
DISTUTILS_USE_SETUPTOOLS=rdepend
inherit distutils-r1
DESCRIPTION="Passive checker for Python programs"
HOMEPAGE="https://github.com/PyCQA/pyflakes https://pypi.org/project/pyflakes/"
SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
LICENSE="MIT"
SLOT="0"
KEYWORDS="~alpha amd64 arm arm64 ~hppa ~ia64 ~mips ppc ppc64 ~s390 sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
# Should be included in the next release
PATCHES=( "${FILESDIR}/${P}-fix-tests.patch" )
distutils_enable_tests unittest

View File

@ -0,0 +1,21 @@
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=7
PYTHON_COMPAT=( pypy3 python3_{8..10} )
inherit distutils-r1
DESCRIPTION="Passive checker for Python programs"
HOMEPAGE="https://github.com/PyCQA/pyflakes https://pypi.org/project/pyflakes/"
SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
LICENSE="MIT"
SLOT="0"
KEYWORDS="~alpha amd64 arm arm64 ~hppa ~ia64 ~m68k ~mips ppc ppc64 ~riscv ~s390 sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
PATCHES=(
"${FILESDIR}/${P}-fix-py3.10-tests.patch"
)
distutils_enable_tests unittest

View File

@ -0,0 +1,17 @@
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
PYTHON_COMPAT=( pypy3 python3_{8..10} )
inherit distutils-r1
DESCRIPTION="Passive checker for Python programs"
HOMEPAGE="https://github.com/PyCQA/pyflakes https://pypi.org/project/pyflakes/"
SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
LICENSE="MIT"
SLOT="0"
KEYWORDS="~alpha ~amd64 ~arm ~arm64 hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
distutils_enable_tests unittest