Accepting request 1099247 from home:anag:branches:devel:languages:python

Fix python-codestyle FTBFS, this is blocking cloud-init in staging

OBS-URL: https://build.opensuse.org/request/show/1099247
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-pycodestyle?expand=0&rev=32
This commit is contained in:
Steve Kowalik 2023-07-18 11:36:18 +00:00 committed by Git OBS Bridge
parent 4de6fe54d0
commit ae379a7fa3
3 changed files with 164 additions and 0 deletions

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Tue Jul 18 11:27:38 UTC 2023 - Ana Guerrero <ana.guerrero@suse.com>
- Add patch to fix testsuite with python 3.11.4 and 3.12
testsuite_fixes.patch
-------------------------------------------------------------------
Tue May 9 05:08:31 UTC 2023 - Johannes Kastl <kastl@b1-systems.de>

View File

@ -25,6 +25,7 @@ License: MIT
Group: Development/Languages/Python
URL: https://pycodestyle.readthedocs.io/
Source: https://files.pythonhosted.org/packages/source/p/pycodestyle/pycodestyle-%{version}.tar.gz
Patch01: testsuite_fixes.patch
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module setuptools}
BuildRequires: fdupes

157
testsuite_fixes.patch Normal file
View File

@ -0,0 +1,157 @@
Testsuite fixes to pass with python 3.11.4 and python 3.12
Fixes taken from upstream commits:
e20394e5cbd8d440c9c1868ddc25d036afcbfe45
e8d84098da10d013ee686027e174814dbe4dd908
diff -Nrua pycodestyle-2.10.0.original/pycodestyle.py pycodestyle-2.10.0/pycodestyle.py
--- pycodestyle-2.10.0.original/pycodestyle.py 2022-11-23 19:26:34.000000000 +0100
+++ pycodestyle-2.10.0/pycodestyle.py 2023-07-18 13:15:24.537262524 +0200
@@ -196,7 +196,6 @@
These options are highly recommended!
Okay: if a == 0:\n a = 1\n b = 1
- E101: if a == 0:\n a = 1\n\tb = 1
"""
indent = INDENT_REGEX.match(physical_line).group(1)
for offset, char in enumerate(indent):
@@ -802,9 +801,10 @@
(index < 2 or tokens[index - 2][1] != 'class') and
# Allow "return (a.foo for a in range(5))"
not keyword.iskeyword(prev_text) and
- # 'match' and 'case' are only soft keywords
(
sys.version_info < (3, 9) or
+ # 3.12+: type is a soft keyword but no braces after
+ prev_text == 'type' or
not keyword.issoftkeyword(prev_text)
)
):
diff -Nrua pycodestyle-2.10.0.original/testsuite/E10.py pycodestyle-2.10.0/testsuite/E10.py
--- pycodestyle-2.10.0.original/testsuite/E10.py 2022-11-23 19:26:34.000000000 +0100
+++ pycodestyle-2.10.0/testsuite/E10.py 2023-07-18 13:15:24.537262524 +0200
@@ -1,8 +1,3 @@
-#: E101 W191
-for a in 'abc':
- for b in 'xyz':
- print a # indented with 8 spaces
- print b # indented with 1 tab
#: E101 E122 W191 W191
if True:
pass
diff -Nrua pycodestyle-2.10.0.original/testsuite/E90.py pycodestyle-2.10.0/testsuite/E90.py
--- pycodestyle-2.10.0.original/testsuite/E90.py 2022-11-23 19:26:34.000000000 +0100
+++ pycodestyle-2.10.0/testsuite/E90.py 2023-07-18 13:15:24.541262682 +0200
@@ -1,6 +1,4 @@
#: E901
-}
-#: E901
= [x
#: E901 E101 W191
while True:
@@ -8,14 +6,6 @@
pass
except:
print 'Whoops'
-#: E122 E225 E251 E251
-
-# Do not crash if code is invalid
-if msg:
- errmsg = msg % progress.get(cr_dbname))
-
-def lasting(self, duration=300):
- progress = self._progress.setdefault('foo', {}
#: Okay
# Issue #119
diff -Nrua pycodestyle-2.10.0.original/testsuite/python312.py pycodestyle-2.10.0/testsuite/python312.py
--- pycodestyle-2.10.0.original/testsuite/python312.py 1970-01-01 01:00:00.000000000 +0100
+++ pycodestyle-2.10.0/testsuite/python312.py 2023-07-18 13:15:24.541262682 +0200
@@ -0,0 +1,9 @@
+#: Okay
+# https://github.com/python/cpython/issues/90432: fixed in 3.12
+def foo():
+ pas
+
+\
+
+def bar():
+ pass
diff -Nrua pycodestyle-2.10.0.original/testsuite/test_api.py pycodestyle-2.10.0/testsuite/test_api.py
--- pycodestyle-2.10.0.original/testsuite/test_api.py 2022-11-23 19:26:34.000000000 +0100
+++ pycodestyle-2.10.0/testsuite/test_api.py 2023-07-18 13:15:24.541262682 +0200
@@ -329,12 +329,18 @@
count_errors = pep8style.input_file('stdin', lines=['\x00\n'])
stdout = sys.stdout.getvalue()
- expected = "stdin:1:1: E901 ValueError"
- self.assertTrue(stdout.startswith(expected),
- msg='Output %r does not start with %r' %
- (stdout, expected))
+ if sys.version_info < (3, 11, 4):
+ expected = ["stdin:1:1: E901 ValueError: source code string cannot contain null bytes"] # noqa: E501
+ elif sys.version_info < (3, 12):
+ expected = ["stdin:1:1: E901 SyntaxError: source code string cannot contain null bytes"] # noqa: E501
+ else:
+ expected = [
+ "stdin:1:1: E901 SyntaxError: source code string cannot contain null bytes", # noqa: E501
+ "stdin:1:1: E901 TokenError: source code cannot contain null bytes", # noqa: E501
+ ]
+ self.assertEqual(stdout.splitlines(), expected)
self.assertFalse(sys.stderr)
- self.assertEqual(count_errors, 1)
+ self.assertEqual(count_errors, len(expected))
def test_styleguide_unmatched_triple_quotes(self):
pycodestyle.register_check(DummyChecker, ['Z701'])
@@ -347,35 +353,22 @@
pep8style.input_file('stdin', lines=lines)
stdout = sys.stdout.getvalue()
- expected = 'stdin:2:5: E901 TokenError: EOF in multi-line string'
- self.assertTrue(expected in stdout)
-
- def test_styleguide_continuation_line_outdented(self):
- pycodestyle.register_check(DummyChecker, ['Z701'])
- lines = [
- 'def foo():\n',
- ' pass\n',
- '\n',
- '\\\n',
- '\n',
- 'def bar():\n',
- ' pass\n',
- ]
-
- pep8style = pycodestyle.StyleGuide()
- count_errors = pep8style.input_file('stdin', lines=lines)
- self.assertEqual(count_errors, 2)
- stdout = sys.stdout.getvalue()
- expected = (
- 'stdin:6:1: '
- 'E122 continuation line missing indentation or outdented'
- )
- self.assertTrue(expected in stdout)
- expected = 'stdin:6:1: E302 expected 2 blank lines, found 1'
- self.assertTrue(expected in stdout)
-
- # TODO: runner
- # TODO: input_file
+ if sys.version_info < (3, 10):
+ expected = [
+ 'stdin:2:5: E901 TokenError: EOF in multi-line string',
+ 'stdin:2:26: E901 SyntaxError: EOF while scanning triple-quoted string literal', # noqa: E501
+ ]
+ elif sys.version_info < (3, 12):
+ expected = [
+ 'stdin:2:5: E901 TokenError: EOF in multi-line string',
+ 'stdin:2:6: E901 SyntaxError: unterminated triple-quoted string literal (detected at line 2)', # noqa: E501
+ ]
+ else:
+ expected = [
+ 'stdin:2:6: E901 SyntaxError: unterminated triple-quoted string literal (detected at line 2)', # noqa: E501
+ 'stdin:2:6: E901 TokenError: EOF in multi-line string',
+ ]
+ self.assertEqual(stdout.splitlines(), expected)
def test_styleguides_other_indent_size(self):
pycodestyle.register_check(DummyChecker, ['Z701'])