Hello community,
here is the log from the commit of package python-yamllint for openSUSE:Factory
checked in at 2019-02-25 17:51:21
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-yamllint (Old)
and /work/SRC/openSUSE:Factory/.python-yamllint.new.28833 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-yamllint"
Mon Feb 25 17:51:21 2019 rev:4 rq:676266 version:1.15.0
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-yamllint/python-yamllint.changes
2018-12-31 09:47:51.310144399 +0100
+++
/work/SRC/openSUSE:Factory/.python-yamllint.new.28833/python-yamllint.changes
2019-02-25 17:51:21.962752838 +0100
@@ -1,0 +2,17 @@
+Thu Feb 14 08:05:24 UTC 2019 - John Vandenberg <[email protected]>
+
+- Update to 1.15.0
+ * Add command line option - to read from standard input
+- Disable a flaky test caused by PyYAML
+
+-------------------------------------------------------------------
+Mon Feb 11 06:02:42 UTC 2019 - John Vandenberg <[email protected]>
+
+- Update to 1.14.0
+ * Fix documentation code snippets
+ * Drop Python 2.6 and 3.3 support, add Python 3.7 support
+ * Update documentation and tests for ``line-length`` + Unicode + Python 2
+ * Allow rule configurations to lack options
+ * Add a new ``ignore-shebangs`` option for the ``comments`` rule
+
+-------------------------------------------------------------------
Old:
----
yamllint-1.13.0.tar.gz
New:
----
yamllint-1.15.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-yamllint.spec ++++++
--- /var/tmp/diff_new_pack.EEjC7P/_old 2019-02-25 17:51:23.310752105 +0100
+++ /var/tmp/diff_new_pack.EEjC7P/_new 2019-02-25 17:51:23.310752105 +0100
@@ -1,7 +1,7 @@
#
# spec file for package python-yamllint
#
-# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -18,24 +18,26 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: python-yamllint
-Version: 1.13.0
+Version: 1.15.0
Release: 0
Summary: A linter for YAML files
License: GPL-3.0-only
Group: Development/Languages/Python
-Url: https://github.com/adrienverge/yamllint
+URL: https://github.com/adrienverge/yamllint
Source:
https://files.pythonhosted.org/packages/source/y/yamllint/yamllint-%{version}.tar.gz
BuildRequires: %{python_module setuptools}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
+Requires: python-PyYAML
+Requires: python-pathspec >= 0.5.3
+BuildArch: noarch
# SECTION test requirements
BuildRequires: %{python_module PyYAML}
BuildRequires: %{python_module pathspec >= 0.5.3}
+# nose is optional, used only to exclude a failing test caused by PyYAML
+# deprecation warnings.
+BuildRequires: %{python_module nose}
# /SECTION
-Requires: python-PyYAML
-Requires: python-pathspec >= 0.5.3
-BuildArch: noarch
-
%python_subpackages
%description
@@ -56,7 +58,7 @@
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%check
-%python_exec setup.py test
+%python_exec -m nose -e test_run_auto_output_without_tty_output
%files %{python_files}
%doc README.rst
++++++ yamllint-1.13.0.tar.gz -> yamllint-1.15.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.13.0/PKG-INFO new/yamllint-1.15.0/PKG-INFO
--- old/yamllint-1.13.0/PKG-INFO 2018-11-14 19:10:45.000000000 +0100
+++ new/yamllint-1.15.0/PKG-INFO 2019-02-11 14:22:05.000000000 +0100
@@ -1,10 +1,9 @@
-Metadata-Version: 1.1
+Metadata-Version: 1.2
Name: yamllint
-Version: 1.13.0
+Version: 1.15.0
Summary: A linter for YAML files.
Home-page: https://github.com/adrienverge/yamllint
Author: Adrien Vergé
-Author-email: UNKNOWN
License: GPLv3
Description: A linter for YAML files.
@@ -18,8 +17,14 @@
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
+Classifier: Programming Language :: Python :: 3.7
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Debuggers
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Topic :: Software Development :: Testing
+Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.13.0/docs/conf.py
new/yamllint-1.15.0/docs/conf.py
--- old/yamllint-1.13.0/docs/conf.py 2018-11-14 19:10:16.000000000 +0100
+++ new/yamllint-1.15.0/docs/conf.py 2019-02-11 14:10:28.000000000 +0100
@@ -48,7 +48,7 @@
class Mock(MagicMock):
@classmethod
def __getattr__(cls, name):
- return MagicMock()
+ return MagicMock()
MOCK_MODULES = ['pathspec', 'yaml']
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.13.0/docs/configuration.rst
new/yamllint-1.15.0/docs/configuration.rst
--- old/yamllint-1.13.0/docs/configuration.rst 2018-11-14 19:10:16.000000000
+0100
+++ new/yamllint-1.15.0/docs/configuration.rst 2019-01-11 12:00:07.000000000
+0100
@@ -45,9 +45,9 @@
Extending the default configuration
-----------------------------------
-When writing a custom configuration file, you don't need to redefine every
rule.
-Just extend the ``default`` configuration (or any already-existing
configuration
-file).
+When writing a custom configuration file, you don't need to redefine every
+rule. Just extend the ``default`` configuration (or any already-existing
+configuration file).
For instance, if you just want to disable the ``comments-indentation`` rule,
your file could look like this:
@@ -105,8 +105,8 @@
The CLI will output them (with different colors when using the ``colored``
output format, or ``auto`` when run from a terminal).
-By default the script will exit with a return code ``1`` *only when* there is
one or
-more error(s).
+By default the script will exit with a return code ``1`` *only when* there is
+one or more error(s).
However if strict mode is enabled with the ``-s`` (or ``--strict``) option, the
return code will be:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.13.0/docs/disable_with_comments.rst
new/yamllint-1.15.0/docs/disable_with_comments.rst
--- old/yamllint-1.13.0/docs/disable_with_comments.rst 2018-11-14
19:10:16.000000000 +0100
+++ new/yamllint-1.15.0/docs/disable_with_comments.rst 2019-01-11
12:00:07.000000000 +0100
@@ -4,9 +4,9 @@
Disabling checks for a specific line
------------------------------------
-To prevent yamllint from reporting problems for a specific line, add a
directive
-comment (``# yamllint disable-line ...``) on that line, or on the line above.
-For instance:
+To prevent yamllint from reporting problems for a specific line, add a
+directive comment (``# yamllint disable-line ...``) on that line, or on the
+line above. For instance:
.. code-block:: yaml
@@ -46,9 +46,9 @@
Disabling checks for all (or part of) the file
----------------------------------------------
-To prevent yamllint from reporting problems for the whole file, or for a block
of
-lines within the file, use ``# yamllint disable ...`` and ``# yamllint enable
-...`` directive comments. For instance:
+To prevent yamllint from reporting problems for the whole file, or for a block
+of lines within the file, use ``# yamllint disable ...`` and ``# yamllint
+enable ...`` directive comments. For instance:
.. code-block:: yaml
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.13.0/docs/quickstart.rst
new/yamllint-1.15.0/docs/quickstart.rst
--- old/yamllint-1.13.0/docs/quickstart.rst 2018-11-14 19:10:16.000000000
+0100
+++ new/yamllint-1.15.0/docs/quickstart.rst 2019-02-11 14:16:43.000000000
+0100
@@ -50,6 +50,12 @@
yamllint .
+Or lint a YAML stream from standard input:
+
+.. code:: bash
+
+ echo -e 'this: is\nvalid: YAML' | yamllint -
+
The output will look like (colors are not displayed here):
::
@@ -68,9 +74,9 @@
10:1 error too many blank lines (4 > 2) (empty-lines)
11:4 error too many spaces inside braces (braces)
-By default, the output of yamllint is colored when run from a terminal, and
pure
-text in other cases. Add the ``-f standard`` arguments to force non-colored
output.
-Use the ``-f colored`` arguments to force colored output.
+By default, the output of yamllint is colored when run from a terminal, and
+pure text in other cases. Add the ``-f standard`` arguments to force
+non-colored output. Use the ``-f colored`` arguments to force colored output.
Add the ``-f parsable`` arguments if you need an output format parsable by a
machine (for instance for :doc:`syntax highlighting in text editors
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.13.0/setup.py new/yamllint-1.15.0/setup.py
--- old/yamllint-1.13.0/setup.py 2018-11-14 19:10:16.000000000 +0100
+++ new/yamllint-1.15.0/setup.py 2019-01-11 12:00:07.000000000 +0100
@@ -29,13 +29,19 @@
license=__license__,
keywords=['yaml', 'lint', 'linter', 'syntax', 'checker'],
url='https://github.com/adrienverge/yamllint',
+ python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Console',
'Intended Audience :: Developers',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Programming Language :: Python :: 2',
+ 'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
+ 'Programming Language :: Python :: 3.4',
+ 'Programming Language :: Python :: 3.5',
+ 'Programming Language :: Python :: 3.6',
+ 'Programming Language :: Python :: 3.7',
'Topic :: Software Development',
'Topic :: Software Development :: Debuggers',
'Topic :: Software Development :: Quality Assurance',
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.13.0/tests/common.py
new/yamllint-1.15.0/tests/common.py
--- old/yamllint-1.13.0/tests/common.py 2018-11-14 19:10:16.000000000 +0100
+++ new/yamllint-1.15.0/tests/common.py 2019-01-11 12:00:07.000000000 +0100
@@ -16,12 +16,7 @@
import os
import tempfile
-import sys
-try:
- assert sys.version_info >= (2, 7)
- import unittest
-except AssertionError:
- import unittest2 as unittest
+import unittest
import yaml
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.13.0/tests/rules/test_comments.py
new/yamllint-1.15.0/tests/rules/test_comments.py
--- old/yamllint-1.13.0/tests/rules/test_comments.py 2018-11-14
19:10:16.000000000 +0100
+++ new/yamllint-1.15.0/tests/rules/test_comments.py 2019-02-11
13:54:06.000000000 +0100
@@ -80,6 +80,48 @@
problem3=(9, 2), problem4=(10, 4),
problem5=(15, 3))
+ def test_shebang(self):
+ conf = ('comments:\n'
+ ' require-starting-space: true\n'
+ ' ignore-shebangs: false\n'
+ 'comments-indentation: disable\n'
+ 'document-start: disable\n')
+ self.check('#!/bin/env my-interpreter\n',
+ conf, problem1=(1, 2))
+ self.check('# comment\n'
+ '#!/bin/env my-interpreter\n', conf,
+ problem1=(2, 2))
+ self.check('#!/bin/env my-interpreter\n'
+ '---\n'
+ '#comment\n'
+ '#!/bin/env my-interpreter\n'
+ '', conf,
+ problem1=(1, 2), problem2=(3, 2), problem3=(4, 2))
+ self.check('#! not a shebang\n',
+ conf, problem1=(1, 2))
+ self.check('key: #!/not/a/shebang\n',
+ conf, problem1=(1, 8))
+
+ def test_ignore_shebang(self):
+ conf = ('comments:\n'
+ ' require-starting-space: true\n'
+ ' ignore-shebangs: true\n'
+ 'comments-indentation: disable\n'
+ 'document-start: disable\n')
+ self.check('#!/bin/env my-interpreter\n', conf)
+ self.check('# comment\n'
+ '#!/bin/env my-interpreter\n', conf,
+ problem1=(2, 2))
+ self.check('#!/bin/env my-interpreter\n'
+ '---\n'
+ '#comment\n'
+ '#!/bin/env my-interpreter\n', conf,
+ problem2=(3, 2), problem3=(4, 2))
+ self.check('#! not a shebang\n',
+ conf, problem1=(1, 2))
+ self.check('key: #!/not/a/shebang\n',
+ conf, problem1=(1, 8))
+
def test_spaces_from_content(self):
conf = ('comments:\n'
' require-starting-space: false\n'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.13.0/tests/rules/test_indentation.py
new/yamllint-1.15.0/tests/rules/test_indentation.py
--- old/yamllint-1.13.0/tests/rules/test_indentation.py 2018-11-14
19:10:16.000000000 +0100
+++ new/yamllint-1.15.0/tests/rules/test_indentation.py 2019-01-11
12:00:07.000000000 +0100
@@ -51,8 +51,8 @@
.replace('Mapping', 'Map'))
if token_type in ('StreamStart', 'StreamEnd'):
continue
- output += '%9s %s\n' % (token_type,
- self.format_stack(context['stack']))
+ output += '{:>9} {}\n'.format(token_type,
+ self.format_stack(context['stack']))
return output
def test_simple_mapping(self):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.13.0/tests/rules/test_line_length.py
new/yamllint-1.15.0/tests/rules/test_line_length.py
--- old/yamllint-1.13.0/tests/rules/test_line_length.py 2018-11-14
19:10:16.000000000 +0100
+++ new/yamllint-1.15.0/tests/rules/test_line_length.py 2019-01-11
12:00:07.000000000 +0100
@@ -14,6 +14,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+import sys
+import unittest
+
from tests.common import RuleTestCase
@@ -155,3 +158,16 @@
'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))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.13.0/tests/test_cli.py
new/yamllint-1.15.0/tests/test_cli.py
--- old/yamllint-1.13.0/tests/test_cli.py 2018-11-14 19:10:16.000000000
+0100
+++ new/yamllint-1.15.0/tests/test_cli.py 2019-02-11 14:10:28.000000000
+0100
@@ -24,18 +24,13 @@
import pty
import shutil
import sys
-try:
- assert sys.version_info >= (2, 7)
- import unittest
-except AssertionError:
- import unittest2 as unittest
+import unittest
from tests.common import build_temp_workspace
from yamllint import cli
[email protected](sys.version_info < (2, 7), 'Python 2.6 not supported')
class CommandLineTestCase(unittest.TestCase):
@classmethod
def setUpClass(cls):
@@ -145,6 +140,17 @@
r'not allowed with argument -c\/--config-file$'
)
+ # checks if reading from stdin and files are mutually exclusive
+ sys.stdout, sys.stderr = StringIO(), StringIO()
+ with self.assertRaises(SystemExit) as ctx:
+ cli.run(('-', 'file'))
+
+ self.assertNotEqual(ctx.exception.code, 0)
+
+ out, err = sys.stdout.getvalue(), sys.stderr.getvalue()
+ self.assertEqual(out, '')
+ self.assertRegexpMatches(err, r'^usage')
+
def test_run_with_bad_config(self):
sys.stdout, sys.stderr = StringIO(), StringIO()
with self.assertRaises(SystemExit) as ctx:
@@ -439,3 +445,22 @@
'\033[2m(new-line-at-end-of-file)\033[0m\n'
'\n' % file))
self.assertEqual(err, '')
+
+ def test_run_read_from_stdin(self):
+ # prepares stdin with an invalid yaml string so that we can check
+ # for its specific error, and be assured that stdin was read
+ sys.stdout, sys.stderr = StringIO(), StringIO()
+ sys.stdin = StringIO(
+ 'I am a string\n'
+ 'therefore: I am an error\n')
+
+ with self.assertRaises(SystemExit) as ctx:
+ cli.run(('-', '-f', 'parsable'))
+
+ self.assertNotEqual(ctx.exception.code, 0)
+
+ out, err = sys.stdout.getvalue(), sys.stderr.getvalue()
+ self.assertEqual(out, (
+ 'stdin:2:10: [error] syntax error: '
+ 'mapping values are not allowed here\n'))
+ self.assertEqual(err, '')
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.13.0/tests/test_config.py
new/yamllint-1.15.0/tests/test_config.py
--- old/yamllint-1.13.0/tests/test_config.py 2018-11-14 19:10:16.000000000
+0100
+++ new/yamllint-1.15.0/tests/test_config.py 2019-01-11 12:00:07.000000000
+0100
@@ -21,11 +21,8 @@
import os
import shutil
import sys
-try:
- assert sys.version_info >= (2, 7)
- import unittest
-except AssertionError:
- import unittest2 as unittest
+import tempfile
+import unittest
from tests.common import build_temp_workspace
@@ -58,13 +55,16 @@
' this-one-does-not-exist: enable\n')
def test_missing_option(self):
- with self.assertRaisesRegexp(
- config.YamlLintConfigError,
- 'invalid config: missing option "max-spaces-before" '
- 'for rule "colons"'):
- config.YamlLintConfig('rules:\n'
+ c = config.YamlLintConfig('rules:\n'
+ ' colons: enable\n')
+ self.assertEqual(c.rules['colons']['max-spaces-before'], 0)
+ self.assertEqual(c.rules['colons']['max-spaces-after'], 1)
+
+ c = config.YamlLintConfig('rules:\n'
' colons:\n'
- ' max-spaces-after: 1\n')
+ ' max-spaces-before: 9\n')
+ self.assertEqual(c.rules['colons']['max-spaces-before'], 9)
+ self.assertEqual(c.rules['colons']['max-spaces-after'], 1)
def test_unknown_option(self):
with self.assertRaisesRegexp(
@@ -82,7 +82,7 @@
' spaces: 2\n'
' indent-sequences: true\n'
' check-multi-line-strings: false\n')
- self.assertEqual(c.rules['indentation']['indent-sequences'], True)
+ self.assertTrue(c.rules['indentation']['indent-sequences'])
self.assertEqual(c.rules['indentation']['check-multi-line-strings'],
False)
@@ -91,7 +91,7 @@
' spaces: 2\n'
' indent-sequences: yes\n'
' check-multi-line-strings: false\n')
- self.assertEqual(c.rules['indentation']['indent-sequences'], True)
+ self.assertTrue(c.rules['indentation']['indent-sequences'])
self.assertEqual(c.rules['indentation']['check-multi-line-strings'],
False)
@@ -115,17 +115,22 @@
' indent-sequences: YES!\n'
' check-multi-line-strings: false\n')
+ def test_enable_disable_keywords(self):
+ c = config.YamlLintConfig('rules:\n'
+ ' colons: enable\n'
+ ' hyphens: disable\n')
+ self.assertEqual(c.rules['colons'], {'level': 'error',
+ 'max-spaces-after': 1,
+ 'max-spaces-before': 0})
+ self.assertEqual(c.rules['hyphens'], False)
+
def test_validate_rule_conf(self):
class Rule(object):
ID = 'fake'
- self.assertEqual(config.validate_rule_conf(Rule, False), False)
- self.assertEqual(config.validate_rule_conf(Rule, 'disable'), False)
-
+ self.assertFalse(config.validate_rule_conf(Rule, False))
self.assertEqual(config.validate_rule_conf(Rule, {}),
{'level': 'error'})
- self.assertEqual(config.validate_rule_conf(Rule, 'enable'),
- {'level': 'error'})
config.validate_rule_conf(Rule, {'level': 'error'})
config.validate_rule_conf(Rule, {'level': 'warning'})
@@ -133,22 +138,22 @@
config.validate_rule_conf, Rule, {'level': 'warn'})
Rule.CONF = {'length': int}
+ Rule.DEFAULT = {'length': 80}
config.validate_rule_conf(Rule, {'length': 8})
- self.assertRaises(config.YamlLintConfigError,
- config.validate_rule_conf, Rule, {})
+ config.validate_rule_conf(Rule, {})
self.assertRaises(config.YamlLintConfigError,
config.validate_rule_conf, Rule, {'height': 8})
Rule.CONF = {'a': bool, 'b': int}
+ Rule.DEFAULT = {'a': True, 'b': -42}
config.validate_rule_conf(Rule, {'a': True, 'b': 0})
- self.assertRaises(config.YamlLintConfigError,
- config.validate_rule_conf, Rule, {'a': True})
- self.assertRaises(config.YamlLintConfigError,
- config.validate_rule_conf, Rule, {'b': 0})
+ config.validate_rule_conf(Rule, {'a': True})
+ config.validate_rule_conf(Rule, {'b': 0})
self.assertRaises(config.YamlLintConfigError,
config.validate_rule_conf, Rule, {'a': 1, 'b': 0})
Rule.CONF = {'choice': (True, 88, 'str')}
+ Rule.DEFAULT = {'choice': 88}
config.validate_rule_conf(Rule, {'choice': True})
config.validate_rule_conf(Rule, {'choice': 88})
config.validate_rule_conf(Rule, {'choice': 'str'})
@@ -160,8 +165,10 @@
config.validate_rule_conf, Rule, {'choice': 'abc'})
Rule.CONF = {'choice': (int, 'hardcoded')}
+ Rule.DEFAULT = {'choice': 1337}
config.validate_rule_conf(Rule, {'choice': 42})
config.validate_rule_conf(Rule, {'choice': 'hardcoded'})
+ config.validate_rule_conf(Rule, {})
self.assertRaises(config.YamlLintConfigError,
config.validate_rule_conf, Rule, {'choice': False})
self.assertRaises(config.YamlLintConfigError,
@@ -169,7 +176,7 @@
class ExtendedConfigTestCase(unittest.TestCase):
- def test_extend_add_rule(self):
+ def test_extend_on_object(self):
old = config.YamlLintConfig('rules:\n'
' colons:\n'
' max-spaces-before: 0\n'
@@ -186,60 +193,130 @@
self.assertEqual(len(new.enabled_rules(None)), 2)
- def test_extend_remove_rule(self):
- old = config.YamlLintConfig('rules:\n'
- ' colons:\n'
- ' max-spaces-before: 0\n'
- ' max-spaces-after: 1\n'
- ' hyphens:\n'
- ' max-spaces-after: 2\n')
- new = config.YamlLintConfig('rules:\n'
- ' colons: disable\n')
- new.extend(old)
+ def test_extend_on_file(self):
+ with tempfile.NamedTemporaryFile('w') as f:
+ f.write('rules:\n'
+ ' colons:\n'
+ ' max-spaces-before: 0\n'
+ ' max-spaces-after: 1\n')
+ f.flush()
+ c = config.YamlLintConfig('extends: ' + f.name + '\n'
+ 'rules:\n'
+ ' hyphens:\n'
+ ' max-spaces-after: 2\n')
+
+ self.assertEqual(sorted(c.rules.keys()), ['colons', 'hyphens'])
+ self.assertEqual(c.rules['colons']['max-spaces-before'], 0)
+ self.assertEqual(c.rules['colons']['max-spaces-after'], 1)
+ self.assertEqual(c.rules['hyphens']['max-spaces-after'], 2)
- self.assertEqual(sorted(new.rules.keys()), ['colons', 'hyphens'])
- self.assertEqual(new.rules['colons'], False)
- self.assertEqual(new.rules['hyphens']['max-spaces-after'], 2)
+ self.assertEqual(len(c.enabled_rules(None)), 2)
- self.assertEqual(len(new.enabled_rules(None)), 1)
+ def test_extend_remove_rule(self):
+ with tempfile.NamedTemporaryFile('w') as f:
+ f.write('rules:\n'
+ ' colons:\n'
+ ' max-spaces-before: 0\n'
+ ' max-spaces-after: 1\n'
+ ' hyphens:\n'
+ ' max-spaces-after: 2\n')
+ f.flush()
+ c = config.YamlLintConfig('extends: ' + f.name + '\n'
+ 'rules:\n'
+ ' colons: disable\n')
+
+ self.assertEqual(sorted(c.rules.keys()), ['colons', 'hyphens'])
+ self.assertFalse(c.rules['colons'])
+ self.assertEqual(c.rules['hyphens']['max-spaces-after'], 2)
- def test_extend_edit_rule(self):
- old = config.YamlLintConfig('rules:\n'
- ' colons:\n'
- ' max-spaces-before: 0\n'
- ' max-spaces-after: 1\n'
- ' hyphens:\n'
- ' max-spaces-after: 2\n')
- new = config.YamlLintConfig('rules:\n'
- ' colons:\n'
- ' max-spaces-before: 3\n'
- ' max-spaces-after: 4\n')
- new.extend(old)
+ self.assertEqual(len(c.enabled_rules(None)), 1)
- self.assertEqual(sorted(new.rules.keys()), ['colons', 'hyphens'])
- self.assertEqual(new.rules['colons']['max-spaces-before'], 3)
- self.assertEqual(new.rules['colons']['max-spaces-after'], 4)
- self.assertEqual(new.rules['hyphens']['max-spaces-after'], 2)
+ def test_extend_edit_rule(self):
+ with tempfile.NamedTemporaryFile('w') as f:
+ f.write('rules:\n'
+ ' colons:\n'
+ ' max-spaces-before: 0\n'
+ ' max-spaces-after: 1\n'
+ ' hyphens:\n'
+ ' max-spaces-after: 2\n')
+ f.flush()
+ c = config.YamlLintConfig('extends: ' + f.name + '\n'
+ 'rules:\n'
+ ' colons:\n'
+ ' max-spaces-before: 3\n'
+ ' max-spaces-after: 4\n')
+
+ self.assertEqual(sorted(c.rules.keys()), ['colons', 'hyphens'])
+ self.assertEqual(c.rules['colons']['max-spaces-before'], 3)
+ self.assertEqual(c.rules['colons']['max-spaces-after'], 4)
+ self.assertEqual(c.rules['hyphens']['max-spaces-after'], 2)
- self.assertEqual(len(new.enabled_rules(None)), 2)
+ self.assertEqual(len(c.enabled_rules(None)), 2)
def test_extend_reenable_rule(self):
- old = config.YamlLintConfig('rules:\n'
- ' colons:\n'
- ' max-spaces-before: 0\n'
- ' max-spaces-after: 1\n'
- ' hyphens: disable\n')
- new = config.YamlLintConfig('rules:\n'
- ' hyphens:\n'
- ' max-spaces-after: 2\n')
- new.extend(old)
+ with tempfile.NamedTemporaryFile('w') as f:
+ f.write('rules:\n'
+ ' colons:\n'
+ ' max-spaces-before: 0\n'
+ ' max-spaces-after: 1\n'
+ ' hyphens: disable\n')
+ f.flush()
+ c = config.YamlLintConfig('extends: ' + f.name + '\n'
+ 'rules:\n'
+ ' hyphens:\n'
+ ' max-spaces-after: 2\n')
+
+ self.assertEqual(sorted(c.rules.keys()), ['colons', 'hyphens'])
+ self.assertEqual(c.rules['colons']['max-spaces-before'], 0)
+ self.assertEqual(c.rules['colons']['max-spaces-after'], 1)
+ self.assertEqual(c.rules['hyphens']['max-spaces-after'], 2)
+
+ self.assertEqual(len(c.enabled_rules(None)), 2)
+
+ def test_extend_recursive_default_values(self):
+ with tempfile.NamedTemporaryFile('w') as f:
+ f.write('rules:\n'
+ ' braces:\n'
+ ' max-spaces-inside: 1248\n')
+ f.flush()
+ c = config.YamlLintConfig('extends: ' + f.name + '\n'
+ 'rules:\n'
+ ' braces:\n'
+ ' min-spaces-inside-empty: 2357\n')
+
+ self.assertEqual(c.rules['braces']['min-spaces-inside'], 0)
+ self.assertEqual(c.rules['braces']['max-spaces-inside'], 1248)
+ self.assertEqual(c.rules['braces']['min-spaces-inside-empty'], 2357)
+ self.assertEqual(c.rules['braces']['max-spaces-inside-empty'], -1)
+
+ with tempfile.NamedTemporaryFile('w') as f:
+ f.write('rules:\n'
+ ' colons:\n'
+ ' max-spaces-before: 1337\n')
+ f.flush()
+ c = config.YamlLintConfig('extends: ' + f.name + '\n'
+ 'rules:\n'
+ ' colons: enable\n')
+
+ self.assertEqual(c.rules['colons']['max-spaces-before'], 1337)
+ self.assertEqual(c.rules['colons']['max-spaces-after'], 1)
+
+ with tempfile.NamedTemporaryFile('w') as f1, \
+ tempfile.NamedTemporaryFile('w') as f2:
+ f1.write('rules:\n'
+ ' colons:\n'
+ ' max-spaces-before: 1337\n')
+ f1.flush()
+ f2.write('extends: ' + f1.name + '\n'
+ 'rules:\n'
+ ' colons: disable\n')
+ f2.flush()
+ c = config.YamlLintConfig('extends: ' + f2.name + '\n'
+ 'rules:\n'
+ ' colons: enable\n')
- self.assertEqual(sorted(new.rules.keys()), ['colons', 'hyphens'])
- self.assertEqual(new.rules['colons']['max-spaces-before'], 0)
- self.assertEqual(new.rules['colons']['max-spaces-after'], 1)
- self.assertEqual(new.rules['hyphens']['max-spaces-after'], 2)
-
- self.assertEqual(len(new.enabled_rules(None)), 2)
+ self.assertEqual(c.rules['colons']['max-spaces-before'], 0)
+ self.assertEqual(c.rules['colons']['max-spaces-after'], 1)
class ExtendedLibraryConfigTestCase(unittest.TestCase):
@@ -271,6 +348,9 @@
self.assertEqual(sorted(new.rules.keys()), sorted(old.rules.keys()))
for rule in new.rules:
self.assertEqual(new.rules[rule], old.rules[rule])
+ self.assertEqual(new.rules['empty-lines']['max'], 42)
+ self.assertEqual(new.rules['empty-lines']['max-start'], 43)
+ self.assertEqual(new.rules['empty-lines']['max-end'], 44)
def test_extend_config_override_rule_partly(self):
old = config.YamlLintConfig('extends: default')
@@ -284,6 +364,9 @@
self.assertEqual(sorted(new.rules.keys()), sorted(old.rules.keys()))
for rule in new.rules:
self.assertEqual(new.rules[rule], old.rules[rule])
+ self.assertEqual(new.rules['empty-lines']['max'], 2)
+ self.assertEqual(new.rules['empty-lines']['max-start'], 42)
+ self.assertEqual(new.rules['empty-lines']['max-end'], 0)
class IgnorePathConfigTestCase(unittest.TestCase):
@@ -338,7 +421,6 @@
shutil.rmtree(cls.wd)
- @unittest.skipIf(sys.version_info < (2, 7), 'Python 2.6 not supported')
def test_run_with_ignored_path(self):
sys.stdout = StringIO()
with self.assertRaises(SystemExit):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.13.0/tests/test_linter.py
new/yamllint-1.15.0/tests/test_linter.py
--- old/yamllint-1.13.0/tests/test_linter.py 2018-11-14 19:10:16.000000000
+0100
+++ new/yamllint-1.15.0/tests/test_linter.py 2019-01-11 12:00:07.000000000
+0100
@@ -15,12 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import io
-import sys
-try:
- assert sys.version_info >= (2, 7)
- import unittest
-except AssertionError:
- import unittest2 as unittest
+import unittest
from yamllint.config import YamlLintConfig
from yamllint import linter
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.13.0/tests/test_module.py
new/yamllint-1.15.0/tests/test_module.py
--- old/yamllint-1.13.0/tests/test_module.py 2018-11-14 19:10:16.000000000
+0100
+++ new/yamllint-1.15.0/tests/test_module.py 2019-01-11 12:00:07.000000000
+0100
@@ -19,17 +19,12 @@
import subprocess
import tempfile
import sys
-try:
- assert sys.version_info >= (2, 7)
- import unittest
-except AssertionError:
- import unittest2 as unittest
+import unittest
PYTHON = sys.executable or 'python'
[email protected](sys.version_info < (2, 7), 'Python 2.6 not supported')
class ModuleTestCase(unittest.TestCase):
def setUp(self):
self.wd = tempfile.mkdtemp(prefix='yamllint-tests-')
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.13.0/tests/test_parser.py
new/yamllint-1.15.0/tests/test_parser.py
--- old/yamllint-1.13.0/tests/test_parser.py 2018-11-14 19:10:16.000000000
+0100
+++ new/yamllint-1.15.0/tests/test_parser.py 2019-01-11 12:00:07.000000000
+0100
@@ -14,12 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-import sys
-try:
- assert sys.version_info >= (2, 7)
- import unittest
-except AssertionError:
- import unittest2 as unittest
+import unittest
import yaml
@@ -70,12 +65,12 @@
def test_token_or_comment_generator(self):
e = list(token_or_comment_generator(''))
self.assertEqual(len(e), 2)
- self.assertEqual(e[0].prev, None)
+ self.assertIsNone(e[0].prev)
self.assertIsInstance(e[0].curr, yaml.Token)
self.assertIsInstance(e[0].next, yaml.Token)
self.assertEqual(e[1].prev, e[0].curr)
self.assertEqual(e[1].curr, e[0].next)
- self.assertEqual(e[1].next, None)
+ self.assertIsNone(e[1].next)
e = list(token_or_comment_generator('---\n'
'k: v\n'))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.13.0/tests/test_spec_examples.py
new/yamllint-1.15.0/tests/test_spec_examples.py
--- old/yamllint-1.13.0/tests/test_spec_examples.py 2018-11-14
19:10:16.000000000 +0100
+++ new/yamllint-1.15.0/tests/test_spec_examples.py 2019-01-11
12:00:07.000000000 +0100
@@ -54,8 +54,8 @@
'braces: {min-spaces-inside: 1, max-spaces-inside: 1}\n'
'brackets: {min-spaces-inside: 1, max-spaces-inside: 1}\n')
conf_overrides = {
- 'example-2.2': ('colons: {max-spaces-after: 2}\n'),
- 'example-2.4': ('colons: {max-spaces-after: 3}\n'),
+ 'example-2.2': 'colons: {max-spaces-after: 2}\n',
+ 'example-2.4': 'colons: {max-spaces-after: 3}\n',
'example-2.5': ('empty-lines: {max-end: 2}\n'
'brackets: {min-spaces-inside: 0, max-spaces-inside: 2}\n'
'commas: {max-spaces-before: -1}\n'),
@@ -63,65 +63,65 @@
'indentation: disable\n'),
'example-2.12': ('empty-lines: {max-end: 1}\n'
'colons: {max-spaces-before: -1}\n'),
- 'example-2.16': ('empty-lines: {max-end: 1}\n'),
- 'example-2.18': ('empty-lines: {max-end: 1}\n'),
- 'example-2.19': ('empty-lines: {max-end: 1}\n'),
- 'example-2.28': ('empty-lines: {max-end: 3}\n'),
+ 'example-2.16': 'empty-lines: {max-end: 1}\n',
+ 'example-2.18': 'empty-lines: {max-end: 1}\n',
+ 'example-2.19': 'empty-lines: {max-end: 1}\n',
+ 'example-2.28': 'empty-lines: {max-end: 3}\n',
'example-5.3': ('indentation: {indent-sequences: false}\n'
'colons: {max-spaces-before: 1}\n'),
- 'example-6.4': ('trailing-spaces: disable\n'),
- 'example-6.5': ('trailing-spaces: disable\n'),
- 'example-6.6': ('trailing-spaces: disable\n'),
- 'example-6.7': ('trailing-spaces: disable\n'),
- 'example-6.8': ('trailing-spaces: disable\n'),
+ 'example-6.4': 'trailing-spaces: disable\n',
+ 'example-6.5': 'trailing-spaces: disable\n',
+ 'example-6.6': 'trailing-spaces: disable\n',
+ 'example-6.7': 'trailing-spaces: disable\n',
+ 'example-6.8': 'trailing-spaces: disable\n',
'example-6.10': ('empty-lines: {max-end: 2}\n'
'trailing-spaces: disable\n'
'comments-indentation: disable\n'),
'example-6.11': ('empty-lines: {max-end: 1}\n'
'comments-indentation: disable\n'),
- 'example-6.13': ('comments-indentation: disable\n'),
- 'example-6.14': ('comments-indentation: disable\n'),
- 'example-6.23': ('colons: {max-spaces-before: 1}\n'),
+ 'example-6.13': 'comments-indentation: disable\n',
+ 'example-6.14': 'comments-indentation: disable\n',
+ 'example-6.23': 'colons: {max-spaces-before: 1}\n',
'example-7.4': ('colons: {max-spaces-before: 1}\n'
'indentation: disable\n'),
- 'example-7.5': ('trailing-spaces: disable\n'),
- 'example-7.6': ('trailing-spaces: disable\n'),
- 'example-7.7': ('indentation: disable\n'),
+ 'example-7.5': 'trailing-spaces: disable\n',
+ 'example-7.6': 'trailing-spaces: disable\n',
+ 'example-7.7': 'indentation: disable\n',
'example-7.8': ('colons: {max-spaces-before: 1}\n'
'indentation: disable\n'),
- 'example-7.9': ('trailing-spaces: disable\n'),
+ 'example-7.9': 'trailing-spaces: disable\n',
'example-7.11': ('colons: {max-spaces-before: 1}\n'
'indentation: disable\n'),
'example-7.13': ('brackets: {min-spaces-inside: 0, max-spaces-inside: 1}\n'
'commas: {max-spaces-before: 1, min-spaces-after: 0}\n'),
- 'example-7.14': ('indentation: disable\n'),
+ 'example-7.14': 'indentation: disable\n',
'example-7.15': ('braces: {min-spaces-inside: 0, max-spaces-inside: 1}\n'
'commas: {max-spaces-before: 1, min-spaces-after: 0}\n'
'colons: {max-spaces-before: 1}\n'),
- 'example-7.16': ('indentation: disable\n'),
- 'example-7.17': ('indentation: disable\n'),
- 'example-7.18': ('indentation: disable\n'),
- 'example-7.19': ('indentation: disable\n'),
+ 'example-7.16': 'indentation: disable\n',
+ 'example-7.17': 'indentation: disable\n',
+ 'example-7.18': 'indentation: disable\n',
+ 'example-7.19': 'indentation: disable\n',
'example-7.20': ('colons: {max-spaces-before: 1}\n'
'indentation: disable\n'),
- 'example-8.1': ('empty-lines: {max-end: 1}\n'),
- 'example-8.2': ('trailing-spaces: disable\n'),
+ 'example-8.1': 'empty-lines: {max-end: 1}\n',
+ 'example-8.2': 'trailing-spaces: disable\n',
'example-8.5': ('comments-indentation: disable\n'
'trailing-spaces: disable\n'),
- 'example-8.6': ('empty-lines: {max-end: 1}\n'),
- 'example-8.7': ('empty-lines: {max-end: 1}\n'),
- 'example-8.8': ('trailing-spaces: disable\n'),
- 'example-8.9': ('empty-lines: {max-end: 1}\n'),
- 'example-8.14': ('colons: {max-spaces-before: 1}\n'),
- 'example-8.16': ('indentation: {spaces: 1}\n'),
- 'example-8.17': ('indentation: disable\n'),
+ 'example-8.6': 'empty-lines: {max-end: 1}\n',
+ 'example-8.7': 'empty-lines: {max-end: 1}\n',
+ 'example-8.8': 'trailing-spaces: disable\n',
+ 'example-8.9': 'empty-lines: {max-end: 1}\n',
+ 'example-8.14': 'colons: {max-spaces-before: 1}\n',
+ 'example-8.16': 'indentation: {spaces: 1}\n',
+ 'example-8.17': 'indentation: disable\n',
'example-8.20': ('indentation: {indent-sequences: false}\n'
'colons: {max-spaces-before: 1}\n'),
- 'example-8.22': ('indentation: disable\n'),
- 'example-10.1': ('colons: {max-spaces-before: 2}\n'),
- 'example-10.2': ('indentation: {indent-sequences: false}\n'),
- 'example-10.8': ('truthy: disable\n'),
- 'example-10.9': ('truthy: disable\n'),
+ 'example-8.22': 'indentation: disable\n',
+ 'example-10.1': 'colons: {max-spaces-before: 2}\n',
+ 'example-10.2': 'indentation: {indent-sequences: false}\n',
+ 'example-10.8': 'truthy: disable\n',
+ 'example-10.9': 'truthy: disable\n',
}
files = os.listdir(os.path.join(os.path.dirname(os.path.realpath(__file__)),
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.13.0/yamllint/__init__.py
new/yamllint-1.15.0/yamllint/__init__.py
--- old/yamllint-1.13.0/yamllint/__init__.py 2018-11-14 19:10:16.000000000
+0100
+++ new/yamllint-1.15.0/yamllint/__init__.py 2019-02-11 14:17:02.000000000
+0100
@@ -22,7 +22,7 @@
APP_NAME = 'yamllint'
-APP_VERSION = '1.13.0'
+APP_VERSION = '1.15.0'
APP_DESCRIPTION = __doc__
__author__ = u'Adrien Vergé'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.13.0/yamllint/cli.py
new/yamllint-1.15.0/yamllint/cli.py
--- old/yamllint-1.13.0/yamllint/cli.py 2018-11-14 19:10:16.000000000 +0100
+++ new/yamllint-1.15.0/yamllint/cli.py 2019-02-11 14:10:28.000000000 +0100
@@ -83,11 +83,41 @@
return line
+def show_problems(problems, file, args_format):
+ max_level = 0
+ first = True
+
+ for problem in problems:
+ if args_format == 'parsable':
+ print(Format.parsable(problem, file))
+ elif args_format == 'colored' or \
+ (args_format == 'auto' and supports_color()):
+ if first:
+ print('\033[4m%s\033[0m' % file)
+ first = False
+ print(Format.standard_color(problem, file))
+ else:
+ if first:
+ print(file)
+ first = False
+ print(Format.standard(problem, file))
+ max_level = max(max_level, PROBLEM_LEVELS[problem.level])
+
+ if not first and args_format != 'parsable':
+ print('')
+
+ return max_level
+
+
def run(argv=None):
parser = argparse.ArgumentParser(prog=APP_NAME,
description=APP_DESCRIPTION)
- parser.add_argument('files', metavar='FILE_OR_DIR', nargs='+',
- help='files to check')
+ files_group = parser.add_mutually_exclusive_group(required=True)
+ files_group.add_argument('files', metavar='FILE_OR_DIR', nargs='*',
+ default=(),
+ help='files to check')
+ files_group.add_argument('-', action='store_true', dest='stdin',
+ help='read from standard input')
config_group = parser.add_mutually_exclusive_group()
config_group.add_argument('-c', '--config-file', dest='config_file',
action='store',
@@ -103,9 +133,7 @@
help='return non-zero exit code on warnings '
'as well as errors')
parser.add_argument('-v', '--version', action='version',
- version='%s %s' % (APP_NAME, APP_VERSION))
-
- # TODO: read from stdin when no filename?
+ version='{} {}'.format(APP_NAME, APP_VERSION))
args = parser.parse_args(argv)
@@ -138,32 +166,23 @@
for file in find_files_recursively(args.files):
filepath = file[2:] if file.startswith('./') else file
try:
- first = True
with open(file) as f:
- for problem in linter.run(f, conf, filepath):
- if args.format == 'parsable':
- print(Format.parsable(problem, file))
- elif args.format == 'colored' or \
- (args.format == 'auto' and supports_color()):
- if first:
- print('\033[4m%s\033[0m' % file)
- first = False
-
- print(Format.standard_color(problem, file))
- else:
- if first:
- print(file)
- first = False
-
- print(Format.standard(problem, file))
-
- max_level = max(max_level, PROBLEM_LEVELS[problem.level])
+ problems = linter.run(f, conf, filepath)
+ except EnvironmentError as e:
+ print(e, file=sys.stderr)
+ sys.exit(-1)
+ prob_level = show_problems(problems, file, args_format=args.format)
+ max_level = max(max_level, prob_level)
- if not first and args.format != 'parsable':
- print('')
+ # read yaml from stdin
+ if args.stdin:
+ try:
+ problems = linter.run(sys.stdin, conf, '')
except EnvironmentError as e:
print(e, file=sys.stderr)
sys.exit(-1)
+ prob_level = show_problems(problems, 'stdin', args_format=args.format)
+ max_level = max(max_level, prob_level)
if max_level == PROBLEM_LEVELS['error']:
return_code = 1
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.13.0/yamllint/conf/default.yaml
new/yamllint-1.15.0/yamllint/conf/default.yaml
--- old/yamllint-1.13.0/yamllint/conf/default.yaml 2018-11-14
19:10:16.000000000 +0100
+++ new/yamllint-1.15.0/yamllint/conf/default.yaml 2019-01-11
12:00:07.000000000 +0100
@@ -1,59 +1,28 @@
---
rules:
- braces:
- min-spaces-inside: 0
- max-spaces-inside: 0
- min-spaces-inside-empty: -1
- max-spaces-inside-empty: -1
- brackets:
- min-spaces-inside: 0
- max-spaces-inside: 0
- min-spaces-inside-empty: -1
- max-spaces-inside-empty: -1
- colons:
- max-spaces-before: 0
- max-spaces-after: 1
- commas:
- max-spaces-before: 0
- min-spaces-after: 1
- max-spaces-after: 1
+ braces: enable
+ brackets: enable
+ colons: enable
+ commas: enable
comments:
level: warning
- require-starting-space: true
- min-spaces-from-content: 2
comments-indentation:
level: warning
document-end: disable
document-start:
level: warning
- present: true
- empty-lines:
- max: 2
- max-start: 0
- max-end: 0
- quoted-strings: disable
- empty-values:
- forbid-in-block-mappings: false
- forbid-in-flow-mappings: false
- hyphens:
- max-spaces-after: 1
- indentation:
- spaces: consistent
- indent-sequences: true
- check-multi-line-strings: false
+ empty-lines: enable
+ empty-values: enable
+ hyphens: enable
+ indentation: enable
key-duplicates: enable
key-ordering: disable
- line-length:
- max: 80
- allow-non-breakable-words: true
- allow-non-breakable-inline-mappings: false
+ line-length: enable
new-line-at-end-of-file: enable
- new-lines:
- type: unix
- octal-values:
- forbid-implicit-octal: false
- forbid-explicit-octal: false
+ new-lines: enable
+ octal-values: enable
+ quoted-strings: disable
trailing-spaces: enable
truthy:
level: warning
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.13.0/yamllint/config.py
new/yamllint-1.15.0/yamllint/config.py
--- old/yamllint-1.13.0/yamllint/config.py 2018-11-14 19:10:16.000000000
+0100
+++ new/yamllint-1.15.0/yamllint/config.py 2019-01-11 12:00:07.000000000
+0100
@@ -74,6 +74,11 @@
raise YamlLintConfigError('invalid config: not a dict')
self.rules = conf.get('rules', {})
+ for rule in self.rules:
+ if self.rules[rule] == 'enable':
+ self.rules[rule] = {}
+ elif self.rules[rule] == 'disable':
+ self.rules[rule] = False
# Does this conf override another conf that we need to load?
if 'extends' in conf:
@@ -102,10 +107,8 @@
def validate_rule_conf(rule, conf):
- if conf is False or conf == 'disable':
+ if conf is False: # disable
return False
- elif conf == 'enable':
- conf = {}
if isinstance(conf, dict):
if ('ignore' in conf and
@@ -123,6 +126,7 @@
'invalid config: level should be "error" or "warning"')
options = getattr(rule, 'CONF', {})
+ options_default = getattr(rule, 'DEFAULT', {})
for optkey in conf:
if optkey in ('ignore', 'level'):
continue
@@ -143,9 +147,7 @@
% (optkey, rule.ID, options[optkey].__name__))
for optkey in options:
if optkey not in conf:
- raise YamlLintConfigError(
- 'invalid config: missing option "%s" for rule "%s"' %
- (optkey, rule.ID))
+ conf[optkey] = options_default[optkey]
else:
raise YamlLintConfigError(('invalid config: rule "%s": should be '
'either "enable", "disable" or a dict')
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.13.0/yamllint/linter.py
new/yamllint-1.15.0/yamllint/linter.py
--- old/yamllint-1.13.0/yamllint/linter.py 2018-11-14 19:10:16.000000000
+0100
+++ new/yamllint-1.15.0/yamllint/linter.py 2019-01-11 12:00:07.000000000
+0100
@@ -47,7 +47,7 @@
@property
def message(self):
if self.rule is not None:
- return '%s (%s)' % (self.desc, self.rule)
+ return '{} ({})'.format(self.desc, self.rule)
return self.desc
def __eq__(self, other):
@@ -75,10 +75,10 @@
for rule in token_rules:
context[rule.ID] = {}
- class DisableDirective():
+ class DisableDirective:
def __init__(self):
self.rules = set()
- self.all_rules = set([r.ID for r in rules])
+ self.all_rules = {r.ID for r in rules}
def process_comment(self, comment):
try:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.13.0/yamllint/rules/braces.py
new/yamllint-1.15.0/yamllint/rules/braces.py
--- old/yamllint-1.13.0/yamllint/rules/braces.py 2018-11-14
19:10:16.000000000 +0100
+++ new/yamllint-1.15.0/yamllint/rules/braces.py 2019-01-11
12:00:07.000000000 +0100
@@ -101,6 +101,10 @@
'max-spaces-inside': int,
'min-spaces-inside-empty': int,
'max-spaces-inside-empty': int}
+DEFAULT = {'min-spaces-inside': 0,
+ 'max-spaces-inside': 0,
+ 'min-spaces-inside-empty': -1,
+ 'max-spaces-inside-empty': -1}
def check(conf, token, prev, next, nextnext, context):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.13.0/yamllint/rules/brackets.py
new/yamllint-1.15.0/yamllint/rules/brackets.py
--- old/yamllint-1.13.0/yamllint/rules/brackets.py 2018-11-14
19:10:16.000000000 +0100
+++ new/yamllint-1.15.0/yamllint/rules/brackets.py 2019-01-11
12:00:07.000000000 +0100
@@ -102,6 +102,10 @@
'max-spaces-inside': int,
'min-spaces-inside-empty': int,
'max-spaces-inside-empty': int}
+DEFAULT = {'min-spaces-inside': 0,
+ 'max-spaces-inside': 0,
+ 'min-spaces-inside-empty': -1,
+ 'max-spaces-inside-empty': -1}
def check(conf, token, prev, next, nextnext, context):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.13.0/yamllint/rules/colons.py
new/yamllint-1.15.0/yamllint/rules/colons.py
--- old/yamllint-1.13.0/yamllint/rules/colons.py 2018-11-14
19:10:16.000000000 +0100
+++ new/yamllint-1.15.0/yamllint/rules/colons.py 2019-01-11
12:00:07.000000000 +0100
@@ -79,6 +79,8 @@
TYPE = 'token'
CONF = {'max-spaces-before': int,
'max-spaces-after': int}
+DEFAULT = {'max-spaces-before': 0,
+ 'max-spaces-after': 1}
def check(conf, token, prev, next, nextnext, context):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.13.0/yamllint/rules/commas.py
new/yamllint-1.15.0/yamllint/rules/commas.py
--- old/yamllint-1.13.0/yamllint/rules/commas.py 2018-11-14
19:10:16.000000000 +0100
+++ new/yamllint-1.15.0/yamllint/rules/commas.py 2019-01-11
12:00:07.000000000 +0100
@@ -103,6 +103,9 @@
CONF = {'max-spaces-before': int,
'min-spaces-after': int,
'max-spaces-after': int}
+DEFAULT = {'max-spaces-before': 0,
+ 'min-spaces-after': 1,
+ 'max-spaces-after': 1}
def check(conf, token, prev, next, nextnext, context):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.13.0/yamllint/rules/comments.py
new/yamllint-1.15.0/yamllint/rules/comments.py
--- old/yamllint-1.13.0/yamllint/rules/comments.py 2018-11-14
19:10:16.000000000 +0100
+++ new/yamllint-1.15.0/yamllint/rules/comments.py 2019-02-11
13:54:06.000000000 +0100
@@ -21,6 +21,9 @@
* Use ``require-starting-space`` to require a space character right after the
``#``. Set to ``true`` to enable, ``false`` to disable.
+* Use ``ignore-shebangs`` to ignore a
+ `shebang <https://en.wikipedia.org/wiki/Shebang_(Unix)>`_ at the beginning of
+ the file when ``require-starting-space`` is set.
* ``min-spaces-from-content`` is used to visually separate inline comments from
content. It defines the minimal required number of spaces between a comment
and its preceding content.
@@ -61,13 +64,19 @@
"""
+import re
+
from yamllint.linter import LintProblem
ID = 'comments'
TYPE = 'comment'
CONF = {'require-starting-space': bool,
+ 'ignore-shebangs': bool,
'min-spaces-from-content': int}
+DEFAULT = {'require-starting-space': True,
+ 'ignore-shebangs': True,
+ 'min-spaces-from-content': 2}
def check(conf, comment):
@@ -82,8 +91,14 @@
while (comment.buffer[text_start] == '#' and
text_start < len(comment.buffer)):
text_start += 1
- if (text_start < len(comment.buffer) and
- comment.buffer[text_start] not in (' ', '\n', '\0')):
- yield LintProblem(comment.line_no,
- comment.column_no + text_start - comment.pointer,
- 'missing starting space in comment')
+ if text_start < len(comment.buffer):
+ if (conf['ignore-shebangs'] and
+ comment.line_no == 1 and
+ comment.column_no == 1 and
+ re.match(r'^!\S', comment.buffer[text_start:])):
+ return
+ elif comment.buffer[text_start] not in (' ', '\n', '\0'):
+ column = comment.column_no + text_start - comment.pointer
+ yield LintProblem(comment.line_no,
+ column,
+ 'missing starting space in comment')
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.13.0/yamllint/rules/document_end.py
new/yamllint-1.15.0/yamllint/rules/document_end.py
--- old/yamllint-1.13.0/yamllint/rules/document_end.py 2018-11-14
19:10:16.000000000 +0100
+++ new/yamllint-1.15.0/yamllint/rules/document_end.py 2019-01-11
12:00:07.000000000 +0100
@@ -82,6 +82,7 @@
ID = 'document-end'
TYPE = 'token'
CONF = {'present': bool}
+DEFAULT = {'present': True}
def check(conf, token, prev, next, nextnext, context):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.13.0/yamllint/rules/document_start.py
new/yamllint-1.15.0/yamllint/rules/document_start.py
--- old/yamllint-1.13.0/yamllint/rules/document_start.py 2018-11-14
19:10:16.000000000 +0100
+++ new/yamllint-1.15.0/yamllint/rules/document_start.py 2019-01-11
12:00:07.000000000 +0100
@@ -72,6 +72,7 @@
ID = 'document-start'
TYPE = 'token'
CONF = {'present': bool}
+DEFAULT = {'present': True}
def check(conf, token, prev, next, nextnext, context):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.13.0/yamllint/rules/empty_lines.py
new/yamllint-1.15.0/yamllint/rules/empty_lines.py
--- old/yamllint-1.13.0/yamllint/rules/empty_lines.py 2018-11-14
19:10:16.000000000 +0100
+++ new/yamllint-1.15.0/yamllint/rules/empty_lines.py 2019-01-11
12:00:07.000000000 +0100
@@ -58,6 +58,9 @@
CONF = {'max': int,
'max-start': int,
'max-end': int}
+DEFAULT = {'max': 2,
+ 'max-start': 0,
+ 'max-end': 0}
def check(conf, line):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.13.0/yamllint/rules/empty_values.py
new/yamllint-1.15.0/yamllint/rules/empty_values.py
--- old/yamllint-1.13.0/yamllint/rules/empty_values.py 2018-11-14
19:10:16.000000000 +0100
+++ new/yamllint-1.15.0/yamllint/rules/empty_values.py 2019-01-11
12:00:07.000000000 +0100
@@ -75,6 +75,8 @@
TYPE = 'token'
CONF = {'forbid-in-block-mappings': bool,
'forbid-in-flow-mappings': bool}
+DEFAULT = {'forbid-in-block-mappings': False,
+ 'forbid-in-flow-mappings': False}
def check(conf, token, prev, next, nextnext, context):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.13.0/yamllint/rules/hyphens.py
new/yamllint-1.15.0/yamllint/rules/hyphens.py
--- old/yamllint-1.13.0/yamllint/rules/hyphens.py 2018-11-14
19:10:16.000000000 +0100
+++ new/yamllint-1.15.0/yamllint/rules/hyphens.py 2019-01-11
12:00:07.000000000 +0100
@@ -76,6 +76,7 @@
ID = 'hyphens'
TYPE = 'token'
CONF = {'max-spaces-after': int}
+DEFAULT = {'max-spaces-after': 1}
def check(conf, token, prev, next, nextnext, context):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.13.0/yamllint/rules/indentation.py
new/yamllint-1.15.0/yamllint/rules/indentation.py
--- old/yamllint-1.13.0/yamllint/rules/indentation.py 2018-11-14
19:10:16.000000000 +0100
+++ new/yamllint-1.15.0/yamllint/rules/indentation.py 2019-01-11
12:00:07.000000000 +0100
@@ -201,6 +201,9 @@
CONF = {'spaces': (int, 'consistent'),
'indent-sequences': (bool, 'whatever', 'consistent'),
'check-multi-line-strings': bool}
+DEFAULT = {'spaces': 'consistent',
+ 'indent-sequences': True,
+ 'check-multi-line-strings': False}
ROOT, B_MAP, F_MAP, B_SEQ, F_SEQ, B_ENT, KEY, VAL = range(8)
labels = ('ROOT', 'B_MAP', 'F_MAP', 'B_SEQ', 'F_SEQ', 'B_ENT', 'KEY', 'VAL')
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.13.0/yamllint/rules/key_duplicates.py
new/yamllint-1.15.0/yamllint/rules/key_duplicates.py
--- old/yamllint-1.13.0/yamllint/rules/key_duplicates.py 2018-11-14
19:10:16.000000000 +0100
+++ new/yamllint-1.15.0/yamllint/rules/key_duplicates.py 2019-01-11
12:00:07.000000000 +0100
@@ -61,7 +61,6 @@
ID = 'key-duplicates'
TYPE = 'token'
-CONF = {}
MAP, SEQ = range(2)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.13.0/yamllint/rules/key_ordering.py
new/yamllint-1.15.0/yamllint/rules/key_ordering.py
--- old/yamllint-1.13.0/yamllint/rules/key_ordering.py 2018-11-14
19:10:16.000000000 +0100
+++ new/yamllint-1.15.0/yamllint/rules/key_ordering.py 2019-01-11
12:00:07.000000000 +0100
@@ -72,7 +72,6 @@
ID = 'key-ordering'
TYPE = 'token'
-CONF = {}
MAP, SEQ = range(2)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.13.0/yamllint/rules/line_length.py
new/yamllint-1.15.0/yamllint/rules/line_length.py
--- old/yamllint-1.13.0/yamllint/rules/line_length.py 2018-11-14
19:10:16.000000000 +0100
+++ new/yamllint-1.15.0/yamllint/rules/line_length.py 2019-01-11
12:00:07.000000000 +0100
@@ -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.
@@ -98,6 +102,9 @@
CONF = {'max': int,
'allow-non-breakable-words': bool,
'allow-non-breakable-inline-mappings': bool}
+DEFAULT = {'max': 80,
+ 'allow-non-breakable-words': True,
+ 'allow-non-breakable-inline-mappings': False}
def check_inline_mapping(line):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.13.0/yamllint/rules/new_lines.py
new/yamllint-1.15.0/yamllint/rules/new_lines.py
--- old/yamllint-1.13.0/yamllint/rules/new_lines.py 2018-11-14
19:10:16.000000000 +0100
+++ new/yamllint-1.15.0/yamllint/rules/new_lines.py 2019-01-11
12:00:07.000000000 +0100
@@ -30,6 +30,7 @@
ID = 'new-lines'
TYPE = 'line'
CONF = {'type': ('unix', 'dos')}
+DEFAULT = {'type': 'unix'}
def check(conf, line):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.13.0/yamllint/rules/octal_values.py
new/yamllint-1.15.0/yamllint/rules/octal_values.py
--- old/yamllint-1.13.0/yamllint/rules/octal_values.py 2018-11-14
19:10:16.000000000 +0100
+++ new/yamllint-1.15.0/yamllint/rules/octal_values.py 2019-01-11
12:00:07.000000000 +0100
@@ -66,6 +66,8 @@
TYPE = 'token'
CONF = {'forbid-implicit-octal': bool,
'forbid-explicit-octal': bool}
+DEFAULT = {'forbid-implicit-octal': False,
+ 'forbid-explicit-octal': False}
def check(conf, token, prev, next, nextnext, context):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.13.0/yamllint/rules/quoted_strings.py
new/yamllint-1.15.0/yamllint/rules/quoted_strings.py
--- old/yamllint-1.13.0/yamllint/rules/quoted_strings.py 2018-11-14
19:10:16.000000000 +0100
+++ new/yamllint-1.15.0/yamllint/rules/quoted_strings.py 2019-01-11
12:00:07.000000000 +0100
@@ -46,6 +46,7 @@
ID = 'quoted-strings'
TYPE = 'token'
CONF = {'quote-type': ('any', 'single', 'double')}
+DEFAULT = {'quote-type': 'any'}
def check(conf, token, prev, next, nextnext, context):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.13.0/yamllint/rules/truthy.py
new/yamllint-1.15.0/yamllint/rules/truthy.py
--- old/yamllint-1.13.0/yamllint/rules/truthy.py 2018-11-14
19:10:16.000000000 +0100
+++ new/yamllint-1.15.0/yamllint/rules/truthy.py 2019-01-11
12:00:07.000000000 +0100
@@ -71,7 +71,6 @@
ID = 'truthy'
TYPE = 'token'
-CONF = {}
TRUTHY = ['YES', 'Yes', 'yes',
'NO', 'No', 'no',
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.13.0/yamllint.egg-info/PKG-INFO
new/yamllint-1.15.0/yamllint.egg-info/PKG-INFO
--- old/yamllint-1.13.0/yamllint.egg-info/PKG-INFO 2018-11-14
19:10:45.000000000 +0100
+++ new/yamllint-1.15.0/yamllint.egg-info/PKG-INFO 2019-02-11
14:22:05.000000000 +0100
@@ -1,10 +1,9 @@
-Metadata-Version: 1.1
+Metadata-Version: 1.2
Name: yamllint
-Version: 1.13.0
+Version: 1.15.0
Summary: A linter for YAML files.
Home-page: https://github.com/adrienverge/yamllint
Author: Adrien Vergé
-Author-email: UNKNOWN
License: GPLv3
Description: A linter for YAML files.
@@ -18,8 +17,14 @@
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
+Classifier: Programming Language :: Python :: 3.7
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Debuggers
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Topic :: Software Development :: Testing
+Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*