From ea045c41b7231e0f7096ca091fe943a67a77cecc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Verg=C3=A9?= Date: Fri, 23 Nov 2018 14:03:11 +0100 Subject: [PATCH 1/3] CI: Drop Python 3.3 support The `pkg_resources` package inside `setuptools` explicitly [disallows Python 3.3](https://github.com/pypa/setuptools/commit/7392f01ffced3acfdef25b0b2d55cefdc6ee468a#diff-81de4a30a55fcc3fb944f8387ea9ec94): if (3, 0) < sys.version_info < (3, 4): raise RuntimeError("Python 3.4 or later is required") It's time to drop support for 3.3. --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 39f7a27..94cf9c2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ language: python python: - 2.6 - 2.7 - - 3.3 - 3.4 - 3.5 - 3.6 From c8032c086b7a5057a6daa9a0648317cae5d4f413 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Verg=C3=A9?= Date: Fri, 23 Nov 2018 09:58:40 +0100 Subject: [PATCH 2/3] line-length: Add tests for lines containing unicode characters Some unicode characters span accross multiple bytes. Python 3 is OK with that, but Python 2 reports an incorrect number of characters. Related to https://github.com/adrienverge/yamllint/issues/146 --- tests/rules/test_line_length.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/rules/test_line_length.py b/tests/rules/test_line_length.py index cab3e18..d052483 100644 --- a/tests/rules/test_line_length.py +++ b/tests/rules/test_line_length.py @@ -14,6 +14,13 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +import sys +try: + assert sys.version_info >= (2, 7) + import unittest +except AssertionError: + import unittest2 as unittest + from tests.common import RuleTestCase @@ -155,3 +162,16 @@ class LineLengthTestCase(RuleTestCase): 'content: |\n' ' {% this line is' + 99 * ' really' + ' long %}\n', conf, problem=(3, 81)) + + @unittest.skipIf(sys.version_info < (3, 0), 'Python 2 not supported') + def test_unicode(self): + conf = 'line-length: {max: 53}' + self.check('---\n' + '# This is a test to check if “line-length” works nice\n' + 'with: “unicode characters” that span accross bytes! ↺\n', + conf) + conf = 'line-length: {max: 52}' + self.check('---\n' + '# This is a test to check if “line-length” works nice\n' + 'with: “unicode characters” that span accross bytes! ↺\n', + conf, problem1=(2, 53), problem2=(3, 53)) From 8bdddf6e89d9e232b0e67463a34f2926b0acfc6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Verg=C3=A9?= Date: Fri, 23 Nov 2018 14:13:04 +0100 Subject: [PATCH 3/3] docs: Warn about Python 2 and problems with line-length Closes #146. --- yamllint/rules/line_length.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/yamllint/rules/line_length.py b/yamllint/rules/line_length.py index e87972e..f7a2f2f 100644 --- a/yamllint/rules/line_length.py +++ b/yamllint/rules/line_length.py @@ -17,6 +17,10 @@ """ Use this rule to set a limit to lines length. +Note: with Python 2, the ``line-length`` rule may not work properly with +unicode characters because of the way strings are represented in bytes. We +recommend running yamllint with Python 3. + .. rubric:: Options * ``max`` defines the maximal (inclusive) length of lines.