From bb4ba557723d0e80c3737a130a601b369c216180e021a434a0aad673b2a35522 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Tue, 2 Oct 2018 15:04:14 +0000 Subject: [PATCH] Accepting request 639619 from home:mcepl:work - Add comp_w_changes_tokenize.patch to make tests more stable (gh#pycqa/pycodestyle#786) OBS-URL: https://build.opensuse.org/request/show/639619 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-pycodestyle?expand=0&rev=10 --- comp_w_changes_tokenize.patch | 35 +++++++++++++++++++++++++++++++++++ python-pycodestyle.changes | 6 ++++++ python-pycodestyle.spec | 4 +++- 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 comp_w_changes_tokenize.patch diff --git a/comp_w_changes_tokenize.patch b/comp_w_changes_tokenize.patch new file mode 100644 index 0000000..da9cb42 --- /dev/null +++ b/comp_w_changes_tokenize.patch @@ -0,0 +1,35 @@ +From 397463014fda3cdefe8d6c9d117ae16d878dc494 Mon Sep 17 00:00:00 2001 +From: Michael Hudson-Doyle +Date: Tue, 25 Sep 2018 14:58:57 +1200 +Subject: [PATCH] Keep compability with stdlib tokenize.py changes + +https://github.com/python/cpython/commit/c4ef4896eac86a6759901c8546e26de4695a1389 +is not yet part of any release of Python but has been backported to all +versions in Git (includeing 2.7!). It causes the tokenize.py module to +emit a synthetic NEWLINE token for files that do not in fact end with a +newline, which confuses pycodestyle's checks for blank lines at the end +of a file. Fortunately the synthetic NEWLINE tokens are easy to detect +(the token text is ""). + +Fixes #786 +--- + pycodestyle.py | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/pycodestyle.py b/pycodestyle.py +index 0d725d27..fbc3dca3 100755 +--- a/pycodestyle.py ++++ b/pycodestyle.py +@@ -258,10 +258,10 @@ def trailing_blank_lines(physical_line, lines, line_number, total_lines): + """ + if line_number == total_lines: + stripped_last_line = physical_line.rstrip() +- if not stripped_last_line: ++ if physical_line and not stripped_last_line: + return 0, "W391 blank line at end of file" + if stripped_last_line == physical_line: +- return len(physical_line), "W292 no newline at end of file" ++ return len(lines[-1]), "W292 no newline at end of file" + + + @register_check diff --git a/python-pycodestyle.changes b/python-pycodestyle.changes index dec39b5..25cb597 100644 --- a/python-pycodestyle.changes +++ b/python-pycodestyle.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Tue Oct 2 14:59:36 UTC 2018 - Matěj Cepl + +- Add comp_w_changes_tokenize.patch to make tests more stable + (gh#pycqa/pycodestyle#786) + ------------------------------------------------------------------- Wed Aug 8 12:39:45 UTC 2018 - tchvatal@suse.com diff --git a/python-pycodestyle.spec b/python-pycodestyle.spec index 501b712..2daf4c2 100644 --- a/python-pycodestyle.spec +++ b/python-pycodestyle.spec @@ -12,7 +12,7 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # @@ -26,6 +26,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 +Patch0: comp_w_changes_tokenize.patch BuildRequires: %{python_module setuptools} BuildRequires: python-rpm-macros BuildArch: noarch @@ -46,6 +47,7 @@ to reduce confusion. %prep %setup -q -n pycodestyle-%{version} +%autopatch -p1 sed -ri '1s/^#!.*//' pycodestyle.py %build