Hello community,
here is the log from the commit of package python-yamllint for
openSUSE:Leap:15.2 checked in at 2020-03-02 13:25:09
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Leap:15.2/python-yamllint (Old)
and /work/SRC/openSUSE:Leap:15.2/.python-yamllint.new.26092 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-yamllint"
Mon Mar 2 13:25:09 2020 rev:5 rq:777300 version:1.20.0
Changes:
--------
--- /work/SRC/openSUSE:Leap:15.2/python-yamllint/python-yamllint.changes
2020-01-15 15:54:38.867639325 +0100
+++
/work/SRC/openSUSE:Leap:15.2/.python-yamllint.new.26092/python-yamllint.changes
2020-03-02 13:25:09.330612875 +0100
@@ -1,0 +2,33 @@
+Tue Feb 4 16:00:48 UTC 2020 - Marketa Calabkova <[email protected]>
+
+- update to 1.20.0
+ * Add --no-warnings option to suppress warning messages
+ * Use 'syntax' as rule name upon syntax errors
+ * Allow disabling all checks for a file with # yamllint disable-file
+
+-------------------------------------------------------------------
+Wed Oct 30 12:21:46 UTC 2019 - Tomáš Chvátal <[email protected]>
+
+- Update to 1.18.0:
+ * Lint .yamllint config file by default
+ * Also read config from .yamllint.yml and .yamllint.yaml
+ * Improve documentation for yaml-files
+ * Update documentation for pre-commit
+ * Explicitly disable empty-values and octal-values rules
+
+-------------------------------------------------------------------
+Mon Aug 19 08:43:21 UTC 2019 - Tomáš Chvátal <[email protected]>
+
+- Update to 1.17.0:
+ * Simplify installation instructions in the README
+ * Add OpenBSD installation instructions
+ * Make YAML file extensions configurable
+
+-------------------------------------------------------------------
+Fri Jun 14 11:46:41 UTC 2019 - Marketa Calabkova <[email protected]>
+
+- Update to 1.16.0
+ * Add the allowed-values option to the truthy rule
+ * Allow configuration options to be a list of enums
+
+-------------------------------------------------------------------
Old:
----
yamllint-1.15.0.tar.gz
New:
----
yamllint-1.20.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-yamllint.spec ++++++
--- /var/tmp/diff_new_pack.mR0gY1/_old 2020-03-02 13:25:09.686613583 +0100
+++ /var/tmp/diff_new_pack.mR0gY1/_new 2020-03-02 13:25:09.686613583 +0100
@@ -1,7 +1,7 @@
#
# spec file for package python-yamllint
#
-# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2020 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -18,7 +18,7 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: python-yamllint
-Version: 1.15.0
+Version: 1.20.0
Release: 0
Summary: A linter for YAML files
License: GPL-3.0-only
@@ -34,9 +34,6 @@
# 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
%python_subpackages
@@ -58,7 +55,7 @@
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%check
-%python_exec -m nose -e test_run_auto_output_without_tty_output
+%python_exec -m unittest discover
%files %{python_files}
%doc README.rst
++++++ yamllint-1.15.0.tar.gz -> yamllint-1.20.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.15.0/PKG-INFO new/yamllint-1.20.0/PKG-INFO
--- old/yamllint-1.15.0/PKG-INFO 2019-02-11 14:22:05.000000000 +0100
+++ new/yamllint-1.20.0/PKG-INFO 2019-12-26 16:07:34.000000000 +0100
@@ -1,6 +1,6 @@
Metadata-Version: 1.2
Name: yamllint
-Version: 1.15.0
+Version: 1.20.0
Summary: A linter for YAML files.
Home-page: https://github.com/adrienverge/yamllint
Author: Adrien Vergé
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.15.0/README.rst
new/yamllint-1.20.0/README.rst
--- old/yamllint-1.15.0/README.rst 2018-05-31 11:06:31.000000000 +0200
+++ new/yamllint-1.20.0/README.rst 2019-07-07 18:14:22.000000000 +0200
@@ -38,31 +38,16 @@
Installation
^^^^^^^^^^^^
-On Fedora / CentOS (note: `EPEL <https://fedoraproject.org/wiki/EPEL>`_ is
-required on CentOS):
-
-.. code:: bash
-
- sudo dnf install yamllint
-
-On Debian 8+ / Ubuntu 16.04+:
-
-.. code:: bash
-
- sudo apt-get install yamllint
-
-On Mac OS 10.11+:
-
-.. code:: bash
-
- brew install yamllint
-
-Alternatively using pip, the Python package manager:
+Using pip, the Python package manager:
.. code:: bash
pip install --user yamllint
+yamllint is also packaged for all major operating systems, see installation
+examples (``dnf``, ``apt-get``...) `in the documentation
+<https://yamllint.readthedocs.io/en/stable/quickstart.html>`_.
+
Usage
^^^^^
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.15.0/docs/configuration.rst
new/yamllint-1.20.0/docs/configuration.rst
--- old/yamllint-1.15.0/docs/configuration.rst 2019-01-11 12:00:07.000000000
+0100
+++ new/yamllint-1.20.0/docs/configuration.rst 2019-12-12 09:13:16.000000000
+0100
@@ -14,7 +14,8 @@
If ``-c`` is not provided, yamllint will look for a configuration file in the
following locations (by order of preference):
-- ``.yamllint`` in the current working directory
+- ``.yamllint``, ``.yamllint.yaml`` or ``.yamllint.yml`` in the current working
+ directory
- ``$XDG_CONFIG_HOME/yamllint/config``
- ``~/.config/yamllint/config``
@@ -115,6 +116,25 @@
* ``1`` if one or more errors occur
* ``2`` if no errors occur, but one or more warnings occur
+If the script is invoked with the ``--no-warnings`` option, it won't output
+warning level problems, only error level ones.
+
+YAML files extensions
+---------------------
+
+To configure what yamllint should consider as YAML files, set ``yaml-files``
+configuration option. The default is:
+
+.. code-block:: yaml
+
+ yaml-files:
+ - '*.yaml'
+ - '*.yml'
+ - '.yamllint'
+
+The same rules as for ignoring paths apply (``.gitignore``-style path pattern,
+see below).
+
Ignoring paths
--------------
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.15.0/docs/disable_with_comments.rst
new/yamllint-1.20.0/docs/disable_with_comments.rst
--- old/yamllint-1.15.0/docs/disable_with_comments.rst 2019-01-11
12:00:07.000000000 +0100
+++ new/yamllint-1.20.0/docs/disable_with_comments.rst 2019-12-12
09:07:45.000000000 +0100
@@ -73,3 +73,31 @@
If you need to disable multiple rules, it is allowed to chain rules like this:
``# yamllint disable rule:hyphens rule:commas rule:indentation``.
+
+Disabling all checks for a file
+-------------------------------
+
+To prevent yamllint from reporting problems for a specific file, add the
+directive comment ``# yamllint disable-file`` as the first line of the file.
+For instance:
+
+.. code-block:: yaml
+
+ # yamllint disable-file
+ # The following mapping contains the same key twice, but I know what I'm
doing:
+ key: value 1
+ key: value 2
+
+ - This line is waaaaaaaaaay too long but yamllint will not report anything
about it.
+ This line will be checked by yamllint.
+
+or:
+
+.. code-block:: jinja
+
+ # yamllint disable-file
+ # This file is not valid YAML because it is a Jinja template
+ {% if extra_info %}
+ key1: value1
+ {% endif %}
+ key2: value2
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.15.0/docs/integration.rst
new/yamllint-1.20.0/docs/integration.rst
--- old/yamllint-1.15.0/docs/integration.rst 2017-08-17 12:08:54.000000000
+0200
+++ new/yamllint-1.20.0/docs/integration.rst 2019-10-15 16:18:58.000000000
+0200
@@ -10,8 +10,10 @@
.. code:: yaml
---
- # Update the sha variable with the release version that you want, from the
yamllint repo
+ # Update the rev variable with the release version that you want, from the
yamllint repo
+ # You can pass your custom .yamllint with args attribute.
- repo: https://github.com/adrienverge/yamllint.git
- sha: v1.8.1
+ rev: v1.17.0
hooks:
- id: yamllint
+ args: [-c=/path/to/.yamllint]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.15.0/docs/quickstart.rst
new/yamllint-1.20.0/docs/quickstart.rst
--- old/yamllint-1.15.0/docs/quickstart.rst 2019-02-11 14:16:43.000000000
+0100
+++ new/yamllint-1.20.0/docs/quickstart.rst 2019-07-12 10:21:00.000000000
+0200
@@ -4,7 +4,8 @@
Installing yamllint
-------------------
-On Fedora / CentOS:
+On Fedora / CentOS (note: `EPEL <https://fedoraproject.org/wiki/EPEL>`_ is
+required on CentOS):
.. code:: bash
@@ -22,6 +23,18 @@
brew install yamllint
+On FreeBSD:
+
+.. code:: sh
+
+ pkg install py36-yamllint
+
+On OpenBSD:
+
+.. code:: sh
+
+ doas pkg_add py3-yamllint
+
Alternatively using pip, the Python package manager:
.. code:: bash
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.15.0/setup.py new/yamllint-1.20.0/setup.py
--- old/yamllint-1.15.0/setup.py 2019-01-11 12:00:07.000000000 +0100
+++ new/yamllint-1.20.0/setup.py 2019-06-06 09:52:15.000000000 +0200
@@ -14,7 +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/>.
-from setuptools import setup, find_packages
+from setuptools import find_packages, setup
from yamllint import (__author__, __license__,
APP_NAME, APP_VERSION, APP_DESCRIPTION)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.15.0/tests/rules/test_empty_lines.py
new/yamllint-1.20.0/tests/rules/test_empty_lines.py
--- old/yamllint-1.15.0/tests/rules/test_empty_lines.py 2017-02-06
14:21:06.000000000 +0100
+++ new/yamllint-1.20.0/tests/rules/test_empty_lines.py 2019-04-09
16:48:10.000000000 +0200
@@ -78,3 +78,22 @@
'document-start: disable\n')
self.check('non empty\n', conf)
self.check('non empty\n\n', conf, problem=(2, 1))
+
+ def test_with_dos_newlines(self):
+ conf = ('empty-lines: {max: 2, max-start: 0, max-end: 0}\n'
+ 'new-lines: {type: dos}\n'
+ 'document-start: disable\n')
+ self.check('---\r\n', conf)
+ self.check('---\r\ntext\r\n\r\ntext\r\n', conf)
+ self.check('\r\n---\r\ntext\r\n\r\ntext\r\n', conf,
+ problem=(1, 1))
+ self.check('\r\n\r\n\r\n---\r\ntext\r\n\r\ntext\r\n', conf,
+ problem=(3, 1))
+ self.check('---\r\ntext\r\n\r\n\r\n\r\ntext\r\n', conf,
+ problem=(5, 1))
+ self.check('---\r\ntext\r\n\r\n\r\n\r\n\r\n\r\n\r\ntext\r\n', conf,
+ problem=(8, 1))
+ self.check('---\r\ntext\r\n\r\ntext\r\n\r\n', conf,
+ problem=(5, 1))
+ self.check('---\r\ntext\r\n\r\ntext\r\n\r\n\r\n\r\n', conf,
+ problem=(7, 1))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.15.0/tests/rules/test_line_length.py
new/yamllint-1.20.0/tests/rules/test_line_length.py
--- old/yamllint-1.15.0/tests/rules/test_line_length.py 2019-01-11
12:00:07.000000000 +0100
+++ new/yamllint-1.20.0/tests/rules/test_line_length.py 2019-04-09
16:48:10.000000000 +0200
@@ -171,3 +171,12 @@
'# 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))
+
+ def test_with_dos_newlines(self):
+ conf = ('line-length: {max: 10}\n'
+ 'new-lines: {type: dos}\n'
+ 'new-line-at-end-of-file: disable\n')
+ self.check('---\r\nABCD EFGHI', conf)
+ self.check('---\r\nABCD EFGHI\r\n', conf)
+ self.check('---\r\nABCD EFGHIJ', conf, problem=(2, 11))
+ self.check('---\r\nABCD EFGHIJ\r\n', conf, problem=(2, 11))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.15.0/tests/rules/test_new_lines.py
new/yamllint-1.20.0/tests/rules/test_new_lines.py
--- old/yamllint-1.15.0/tests/rules/test_new_lines.py 2017-02-06
14:21:06.000000000 +0100
+++ new/yamllint-1.20.0/tests/rules/test_new_lines.py 2019-04-09
16:48:10.000000000 +0200
@@ -31,16 +31,20 @@
self.check('---\r\ntext\r\n', conf)
def test_unix_type(self):
- conf = 'new-lines: {type: unix}'
+ conf = ('new-line-at-end-of-file: disable\n'
+ 'new-lines: {type: unix}\n')
self.check('', conf)
+ self.check('\r', conf)
self.check('\n', conf)
self.check('\r\n', conf, problem=(1, 1))
self.check('---\ntext\n', conf)
self.check('---\r\ntext\r\n', conf, problem=(1, 4))
def test_dos_type(self):
- conf = 'new-lines: {type: dos}\n'
+ conf = ('new-line-at-end-of-file: disable\n'
+ 'new-lines: {type: dos}\n')
self.check('', conf)
+ self.check('\r', conf)
self.check('\n', conf, problem=(1, 1))
self.check('\r\n', conf)
self.check('---\ntext\n', conf, problem=(1, 4))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.15.0/tests/rules/test_octal_values.py
new/yamllint-1.20.0/tests/rules/test_octal_values.py
--- old/yamllint-1.15.0/tests/rules/test_octal_values.py 2018-02-21
12:10:11.000000000 +0100
+++ new/yamllint-1.20.0/tests/rules/test_octal_values.py 2019-10-15
16:18:58.000000000 +0200
@@ -28,7 +28,9 @@
self.check('user-city: 0o10', conf)
def test_implicit_octal_values(self):
- conf = ('octal-values: {forbid-implicit-octal: true}\n'
+ conf = ('octal-values:\n'
+ ' forbid-implicit-octal: true\n'
+ ' forbid-explicit-octal: false\n'
'new-line-at-end-of-file: disable\n'
'document-start: disable\n')
self.check('user-city: 010', conf, problem=(1, 15))
@@ -50,7 +52,9 @@
' - 0e3\n', conf)
def test_explicit_octal_values(self):
- conf = ('octal-values: {forbid-explicit-octal: true}\n'
+ conf = ('octal-values:\n'
+ ' forbid-implicit-octal: false\n'
+ ' forbid-explicit-octal: true\n'
'new-line-at-end-of-file: disable\n'
'document-start: disable\n')
self.check('user-city: 0o10', conf, problem=(1, 16))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.15.0/tests/rules/test_truthy.py
new/yamllint-1.20.0/tests/rules/test_truthy.py
--- old/yamllint-1.15.0/tests/rules/test_truthy.py 2017-02-06
14:21:06.000000000 +0100
+++ new/yamllint-1.20.0/tests/rules/test_truthy.py 2019-06-07
09:59:31.000000000 +0200
@@ -49,6 +49,54 @@
problem3=(7, 3), problem4=(7, 7),
problem5=(8, 3), problem6=(8, 7))
+ def test_different_allowed_values(self):
+ conf = ('truthy:\n'
+ ' allowed-values: ["yes", "no"]\n')
+ self.check('---\n'
+ 'key1: foo\n'
+ 'key2: yes\n'
+ 'key3: bar\n'
+ 'key4: no\n', conf)
+ self.check('---\n'
+ 'key1: true\n'
+ 'key2: Yes\n'
+ 'key3: false\n'
+ 'key4: no\n'
+ 'key5: yes\n',
+ conf,
+ problem1=(2, 7), problem2=(3, 7),
+ problem3=(4, 7))
+
+ def test_combined_allowed_values(self):
+ conf = ('truthy:\n'
+ ' allowed-values: ["yes", "no", "true", "false"]\n')
+ self.check('---\n'
+ 'key1: foo\n'
+ 'key2: yes\n'
+ 'key3: bar\n'
+ 'key4: no\n', conf)
+ self.check('---\n'
+ 'key1: true\n'
+ 'key2: Yes\n'
+ 'key3: false\n'
+ 'key4: no\n'
+ 'key5: yes\n',
+ conf, problem1=(3, 7))
+
+ def test_no_allowed_values(self):
+ conf = ('truthy:\n'
+ ' allowed-values: []\n')
+ self.check('---\n'
+ 'key1: foo\n'
+ 'key2: bar\n', conf)
+ self.check('---\n'
+ 'key1: true\n'
+ 'key2: yes\n'
+ 'key3: false\n'
+ 'key4: no\n', conf,
+ problem1=(2, 7), problem2=(3, 7),
+ problem3=(4, 7), problem4=(5, 7))
+
def test_explicit_types(self):
conf = 'truthy: enable\n'
self.check('---\n'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.15.0/tests/test_cli.py
new/yamllint-1.20.0/tests/test_cli.py
--- old/yamllint-1.15.0/tests/test_cli.py 2019-02-11 14:10:28.000000000
+0100
+++ new/yamllint-1.20.0/tests/test_cli.py 2019-12-26 16:04:47.000000000
+0100
@@ -29,6 +29,7 @@
from tests.common import build_temp_workspace
from yamllint import cli
+from yamllint import config
class CommandLineTestCase(unittest.TestCase):
@@ -73,8 +74,9 @@
shutil.rmtree(cls.wd)
def test_find_files_recursively(self):
+ conf = config.YamlLintConfig('extends: default')
self.assertEqual(
- sorted(cli.find_files_recursively([self.wd])),
+ sorted(cli.find_files_recursively([self.wd], conf)),
[os.path.join(self.wd, 'a.yaml'),
os.path.join(self.wd, 'empty.yml'),
os.path.join(self.wd, 's/s/s/s/s/s/s/s/s/s/s/s/s/s/s/file.yaml'),
@@ -85,14 +87,14 @@
items = [os.path.join(self.wd, 'sub/ok.yaml'),
os.path.join(self.wd, 'empty-dir')]
self.assertEqual(
- sorted(cli.find_files_recursively(items)),
+ sorted(cli.find_files_recursively(items, conf)),
[os.path.join(self.wd, 'sub/ok.yaml')],
)
items = [os.path.join(self.wd, 'empty.yml'),
os.path.join(self.wd, 's')]
self.assertEqual(
- sorted(cli.find_files_recursively(items)),
+ sorted(cli.find_files_recursively(items, conf)),
[os.path.join(self.wd, 'empty.yml'),
os.path.join(self.wd, 's/s/s/s/s/s/s/s/s/s/s/s/s/s/s/file.yaml')],
)
@@ -100,11 +102,77 @@
items = [os.path.join(self.wd, 'sub'),
os.path.join(self.wd, '/etc/another/file')]
self.assertEqual(
- sorted(cli.find_files_recursively(items)),
+ sorted(cli.find_files_recursively(items, conf)),
[os.path.join(self.wd, '/etc/another/file'),
os.path.join(self.wd, 'sub/ok.yaml')],
)
+ conf = config.YamlLintConfig('extends: default\n'
+ 'yaml-files:\n'
+ ' - \'*.yaml\' \n')
+ self.assertEqual(
+ sorted(cli.find_files_recursively([self.wd], conf)),
+ [os.path.join(self.wd, 'a.yaml'),
+ os.path.join(self.wd, 's/s/s/s/s/s/s/s/s/s/s/s/s/s/s/file.yaml'),
+ os.path.join(self.wd, 'sub/ok.yaml'),
+ os.path.join(self.wd, 'warn.yaml')]
+ )
+
+ conf = config.YamlLintConfig('extends: default\n'
+ 'yaml-files:\n'
+ ' - \'*.yml\'\n')
+ self.assertEqual(
+ sorted(cli.find_files_recursively([self.wd], conf)),
+ [os.path.join(self.wd, 'empty.yml')]
+ )
+
+ conf = config.YamlLintConfig('extends: default\n'
+ 'yaml-files:\n'
+ ' - \'*.json\'\n')
+ self.assertEqual(
+ sorted(cli.find_files_recursively([self.wd], conf)),
+ [os.path.join(self.wd, 'no-yaml.json')]
+ )
+
+ conf = config.YamlLintConfig('extends: default\n'
+ 'yaml-files:\n'
+ ' - \'*\'\n')
+ self.assertEqual(
+ sorted(cli.find_files_recursively([self.wd], conf)),
+ [os.path.join(self.wd, 'a.yaml'),
+ os.path.join(self.wd, 'empty.yml'),
+ os.path.join(self.wd, 'no-yaml.json'),
+ os.path.join(self.wd, 'non-ascii/utf-8'),
+ os.path.join(self.wd, 's/s/s/s/s/s/s/s/s/s/s/s/s/s/s/file.yaml'),
+ os.path.join(self.wd, 'sub/ok.yaml'),
+ os.path.join(self.wd, 'warn.yaml')]
+ )
+
+ conf = config.YamlLintConfig('extends: default\n'
+ 'yaml-files:\n'
+ ' - \'*.yaml\'\n'
+ ' - \'*\'\n'
+ ' - \'**\'\n')
+ self.assertEqual(
+ sorted(cli.find_files_recursively([self.wd], conf)),
+ [os.path.join(self.wd, 'a.yaml'),
+ os.path.join(self.wd, 'empty.yml'),
+ os.path.join(self.wd, 'no-yaml.json'),
+ os.path.join(self.wd, 'non-ascii/utf-8'),
+ os.path.join(self.wd, 's/s/s/s/s/s/s/s/s/s/s/s/s/s/s/file.yaml'),
+ os.path.join(self.wd, 'sub/ok.yaml'),
+ os.path.join(self.wd, 'warn.yaml')]
+ )
+
+ conf = config.YamlLintConfig('extends: default\n'
+ 'yaml-files:\n'
+ ' - \'s/**\'\n'
+ ' - \'**/utf-8\'\n')
+ self.assertEqual(
+ sorted(cli.find_files_recursively([self.wd], conf)),
+ [os.path.join(self.wd, 'non-ascii/utf-8')]
+ )
+
def test_run_with_bad_arguments(self):
sys.stdout, sys.stderr = StringIO(), StringIO()
with self.assertRaises(SystemExit) as ctx:
@@ -462,5 +530,40 @@
out, err = sys.stdout.getvalue(), sys.stderr.getvalue()
self.assertEqual(out, (
'stdin:2:10: [error] syntax error: '
- 'mapping values are not allowed here\n'))
+ 'mapping values are not allowed here (syntax)\n'))
self.assertEqual(err, '')
+
+ def test_run_no_warnings(self):
+ file = os.path.join(self.wd, 'a.yaml')
+
+ sys.stdout, sys.stderr = StringIO(), StringIO()
+ with self.assertRaises(SystemExit) as ctx:
+ cli.run((file, '--no-warnings', '-f', 'auto'))
+
+ self.assertEqual(ctx.exception.code, 1)
+
+ out, err = sys.stdout.getvalue(), sys.stderr.getvalue()
+ self.assertEqual(out, (
+ '%s\n'
+ ' 2:4 error trailing spaces (trailing-spaces)\n'
+ ' 3:4 error no new line character at the end of file '
+ '(new-line-at-end-of-file)\n'
+ '\n' % file))
+ self.assertEqual(err, '')
+
+ file = os.path.join(self.wd, 'warn.yaml')
+
+ sys.stdout, sys.stderr = StringIO(), StringIO()
+ with self.assertRaises(SystemExit) as ctx:
+ cli.run((file, '--no-warnings', '-f', 'auto'))
+
+ self.assertEqual(ctx.exception.code, 0)
+
+ def test_run_no_warnings_and_strict(self):
+ file = os.path.join(self.wd, 'warn.yaml')
+
+ sys.stdout, sys.stderr = StringIO(), StringIO()
+ with self.assertRaises(SystemExit) as ctx:
+ cli.run((file, '--no-warnings', '-s'))
+
+ self.assertEqual(ctx.exception.code, 2)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.15.0/tests/test_config.py
new/yamllint-1.20.0/tests/test_config.py
--- old/yamllint-1.15.0/tests/test_config.py 2019-01-11 12:00:07.000000000
+0100
+++ new/yamllint-1.20.0/tests/test_config.py 2019-08-27 09:46:03.000000000
+0200
@@ -174,6 +174,25 @@
self.assertRaises(config.YamlLintConfigError,
config.validate_rule_conf, Rule, {'choice': 'abc'})
+ Rule.CONF = {'multiple': ['item1', 'item2', 'item3']}
+ Rule.DEFAULT = {'multiple': ['item1']}
+ config.validate_rule_conf(Rule, {'multiple': []})
+ config.validate_rule_conf(Rule, {'multiple': ['item2']})
+ config.validate_rule_conf(Rule, {'multiple': ['item2', 'item3']})
+ config.validate_rule_conf(Rule, {})
+ self.assertRaises(config.YamlLintConfigError,
+ config.validate_rule_conf, Rule,
+ {'multiple': 'item1'})
+ self.assertRaises(config.YamlLintConfigError,
+ config.validate_rule_conf, Rule,
+ {'multiple': ['']})
+ self.assertRaises(config.YamlLintConfigError,
+ config.validate_rule_conf, Rule,
+ {'multiple': ['item1', 4]})
+ self.assertRaises(config.YamlLintConfigError,
+ config.validate_rule_conf, Rule,
+ {'multiple': ['item4']})
+
class ExtendedConfigTestCase(unittest.TestCase):
def test_extend_on_object(self):
@@ -429,11 +448,13 @@
out = sys.stdout.getvalue()
out = '\n'.join(sorted(out.splitlines()))
+ docstart = '[warning] missing document start "---" (document-start)'
keydup = '[error] duplication of key "key" in mapping (key-duplicates)'
trailing = '[error] trailing spaces (trailing-spaces)'
hyphen = '[error] too many spaces after hyphen (hyphens)'
self.assertEqual(out, '\n'.join((
+ './.yamllint:1:1: ' + docstart,
'./bin/file.lint-me-anyway.yaml:3:3: ' + keydup,
'./bin/file.lint-me-anyway.yaml:4:17: ' + trailing,
'./bin/file.lint-me-anyway.yaml:5:5: ' + hyphen,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.15.0/tests/test_yamllint_directives.py
new/yamllint-1.20.0/tests/test_yamllint_directives.py
--- old/yamllint-1.15.0/tests/test_yamllint_directives.py 2017-02-06
14:21:06.000000000 +0100
+++ new/yamllint-1.20.0/tests/test_yamllint_directives.py 2019-12-12
09:07:45.000000000 +0100
@@ -302,3 +302,104 @@
' c: [x]\n',
conf,
problem=(6, 2, 'comments-indentation'))
+
+ def test_disable_file_directive(self):
+ conf = ('comments: {min-spaces-from-content: 2}\n'
+ 'comments-indentation: {}\n')
+ self.check('# yamllint disable-file\n'
+ '---\n'
+ '- a: 1 # comment too close\n'
+ ' b:\n'
+ ' # wrong indentation\n'
+ ' c: [x]\n',
+ conf)
+ self.check('# yamllint disable-file\n'
+ '---\n'
+ '- a: 1 # comment too close\n'
+ ' b:\n'
+ ' # wrong indentation\n'
+ ' c: [x]\n',
+ conf)
+ self.check('#yamllint disable-file\n'
+ '---\n'
+ '- a: 1 # comment too close\n'
+ ' b:\n'
+ ' # wrong indentation\n'
+ ' c: [x]\n',
+ conf)
+ self.check('#yamllint disable-file \n'
+ '---\n'
+ '- a: 1 # comment too close\n'
+ ' b:\n'
+ ' # wrong indentation\n'
+ ' c: [x]\n',
+ conf)
+ self.check('---\n'
+ '# yamllint disable-file\n'
+ '- a: 1 # comment too close\n'
+ ' b:\n'
+ ' # wrong indentation\n'
+ ' c: [x]\n',
+ conf,
+ problem1=(3, 8, 'comments'),
+ problem2=(5, 2, 'comments-indentation'))
+ self.check('# yamllint disable-file: rules cannot be specified\n'
+ '---\n'
+ '- a: 1 # comment too close\n'
+ ' b:\n'
+ ' # wrong indentation\n'
+ ' c: [x]\n',
+ conf,
+ problem1=(3, 8, 'comments'),
+ problem2=(5, 2, 'comments-indentation'))
+ self.check('AAAA yamllint disable-file\n'
+ '---\n'
+ '- a: 1 # comment too close\n'
+ ' b:\n'
+ ' # wrong indentation\n'
+ ' c: [x]\n',
+ conf,
+ problem1=(1, 1, 'document-start'),
+ problem2=(3, 8, 'comments'),
+ problem3=(5, 2, 'comments-indentation'))
+
+ def test_disable_file_directive_not_at_first_position(self):
+ self.check('# yamllint disable-file\n'
+ '---\n'
+ '- bad : colon and spaces \n',
+ self.conf)
+ self.check('---\n'
+ '# yamllint disable-file\n'
+ '- bad : colon and spaces \n',
+ self.conf,
+ problem1=(3, 7, 'colons'),
+ problem2=(3, 26, 'trailing-spaces'))
+
+ def test_disable_file_directive_with_syntax_error(self):
+ self.check('# This file is not valid YAML (it is a Jinja template)\n'
+ '{% if extra_info %}\n'
+ 'key1: value1\n'
+ '{% endif %}\n'
+ 'key2: value2\n',
+ self.conf,
+ problem=(2, 2, 'syntax'))
+ self.check('# yamllint disable-file\n'
+ '# This file is not valid YAML (it is a Jinja template)\n'
+ '{% if extra_info %}\n'
+ 'key1: value1\n'
+ '{% endif %}\n'
+ 'key2: value2\n',
+ self.conf)
+
+ def test_disable_file_directive_with_dos_lines(self):
+ self.check('# yamllint disable-file\r\n'
+ '---\r\n'
+ '- bad : colon and spaces \r\n',
+ self.conf)
+ self.check('# yamllint disable-file\r\n'
+ '# This file is not valid YAML (it is a Jinja template)\r\n'
+ '{% if extra_info %}\r\n'
+ 'key1: value1\r\n'
+ '{% endif %}\r\n'
+ 'key2: value2\r\n',
+ self.conf)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.15.0/yamllint/__init__.py
new/yamllint-1.20.0/yamllint/__init__.py
--- old/yamllint-1.15.0/yamllint/__init__.py 2019-02-11 14:17:02.000000000
+0100
+++ new/yamllint-1.20.0/yamllint/__init__.py 2019-12-26 16:06:16.000000000
+0100
@@ -22,7 +22,7 @@
APP_NAME = 'yamllint'
-APP_VERSION = '1.15.0'
+APP_VERSION = '1.20.0'
APP_DESCRIPTION = __doc__
__author__ = u'Adrien Vergé'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.15.0/yamllint/cli.py
new/yamllint-1.20.0/yamllint/cli.py
--- old/yamllint-1.15.0/yamllint/cli.py 2019-02-11 14:10:28.000000000 +0100
+++ new/yamllint-1.20.0/yamllint/cli.py 2019-12-12 09:13:16.000000000 +0100
@@ -16,24 +16,25 @@
from __future__ import print_function
+import argparse
import os
-import sys
import platform
-import argparse
+import sys
from yamllint import APP_DESCRIPTION, APP_NAME, APP_VERSION
+from yamllint import linter
from yamllint.config import YamlLintConfig, YamlLintConfigError
from yamllint.linter import PROBLEM_LEVELS
-from yamllint import linter
-def find_files_recursively(items):
+def find_files_recursively(items, conf):
for item in items:
if os.path.isdir(item):
for root, dirnames, filenames in os.walk(item):
- for filename in [f for f in filenames
- if f.endswith(('.yml', '.yaml'))]:
- yield os.path.join(root, filename)
+ for f in filenames:
+ filepath = os.path.join(root, f)
+ if conf.is_yaml_file(filepath):
+ yield filepath
else:
yield item
@@ -83,11 +84,14 @@
return line
-def show_problems(problems, file, args_format):
+def show_problems(problems, file, args_format, no_warn):
max_level = 0
first = True
for problem in problems:
+ max_level = max(max_level, PROBLEM_LEVELS[problem.level])
+ if no_warn and (problem.level != 'error'):
+ continue
if args_format == 'parsable':
print(Format.parsable(problem, file))
elif args_format == 'colored' or \
@@ -101,7 +105,6 @@
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('')
@@ -132,6 +135,9 @@
action='store_true',
help='return non-zero exit code on warnings '
'as well as errors')
+ parser.add_argument('--no-warnings',
+ action='store_true',
+ help='output only error level problems')
parser.add_argument('-v', '--version', action='version',
version='{} {}'.format(APP_NAME, APP_VERSION))
@@ -153,6 +159,10 @@
conf = YamlLintConfig(file=args.config_file)
elif os.path.isfile('.yamllint'):
conf = YamlLintConfig(file='.yamllint')
+ elif os.path.isfile('.yamllint.yaml'):
+ conf = YamlLintConfig(file='.yamllint.yaml')
+ elif os.path.isfile('.yamllint.yml'):
+ conf = YamlLintConfig(file='.yamllint.yml')
elif os.path.isfile(user_global_config):
conf = YamlLintConfig(file=user_global_config)
else:
@@ -163,7 +173,7 @@
max_level = 0
- for file in find_files_recursively(args.files):
+ for file in find_files_recursively(args.files, conf):
filepath = file[2:] if file.startswith('./') else file
try:
with open(file) as f:
@@ -171,7 +181,8 @@
except EnvironmentError as e:
print(e, file=sys.stderr)
sys.exit(-1)
- prob_level = show_problems(problems, file, args_format=args.format)
+ prob_level = show_problems(problems, file, args_format=args.format,
+ no_warn=args.no_warnings)
max_level = max(max_level, prob_level)
# read yaml from stdin
@@ -181,7 +192,8 @@
except EnvironmentError as e:
print(e, file=sys.stderr)
sys.exit(-1)
- prob_level = show_problems(problems, 'stdin', args_format=args.format)
+ prob_level = show_problems(problems, 'stdin', args_format=args.format,
+ no_warn=args.no_warnings)
max_level = max(max_level, prob_level)
if max_level == PROBLEM_LEVELS['error']:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.15.0/yamllint/conf/default.yaml
new/yamllint-1.20.0/yamllint/conf/default.yaml
--- old/yamllint-1.15.0/yamllint/conf/default.yaml 2019-01-11
12:00:07.000000000 +0100
+++ new/yamllint-1.20.0/yamllint/conf/default.yaml 2019-10-15
16:18:58.000000000 +0200
@@ -1,5 +1,10 @@
---
+yaml-files:
+ - '*.yaml'
+ - '*.yml'
+ - '.yamllint'
+
rules:
braces: enable
brackets: enable
@@ -13,7 +18,7 @@
document-start:
level: warning
empty-lines: enable
- empty-values: enable
+ empty-values: disable
hyphens: enable
indentation: enable
key-duplicates: enable
@@ -21,7 +26,7 @@
line-length: enable
new-line-at-end-of-file: enable
new-lines: enable
- octal-values: enable
+ octal-values: disable
quoted-strings: disable
trailing-spaces: enable
truthy:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.15.0/yamllint/config.py
new/yamllint-1.20.0/yamllint/config.py
--- old/yamllint-1.15.0/yamllint/config.py 2019-01-11 12:00:07.000000000
+0100
+++ new/yamllint-1.20.0/yamllint/config.py 2019-08-27 09:46:03.000000000
+0200
@@ -32,6 +32,9 @@
self.ignore = None
+ self.yaml_files = pathspec.PathSpec.from_lines(
+ 'gitwildmatch', ['*.yaml', '*.yml', '.yamllint'])
+
if file is not None:
with open(file) as f:
content = f.read()
@@ -42,6 +45,9 @@
def is_file_ignored(self, filepath):
return self.ignore and self.ignore.match_file(filepath)
+ def is_yaml_file(self, filepath):
+ return self.yaml_files.match_file(filepath)
+
def enabled_rules(self, filepath):
return [yamllint.rules.get(id) for id, val in self.rules.items()
if val is not False and (
@@ -96,6 +102,15 @@
self.ignore = pathspec.PathSpec.from_lines(
'gitwildmatch', conf['ignore'].splitlines())
+ if 'yaml-files' in conf:
+ if not (isinstance(conf['yaml-files'], list)
+ and all(isinstance(i, str) for i in conf['yaml-files'])):
+ raise YamlLintConfigError(
+ 'invalid config: yaml-files '
+ 'should be a list of file patterns')
+ self.yaml_files = pathspec.PathSpec.from_lines('gitwildmatch',
+ conf['yaml-files'])
+
def validate(self):
for id in self.rules:
try:
@@ -134,12 +149,26 @@
raise YamlLintConfigError(
'invalid config: unknown option "%s" for rule "%s"' %
(optkey, rule.ID))
+ # Example: CONF = {option: (bool, 'mixed')}
+ # → {option: true} → {option: mixed}
if isinstance(options[optkey], tuple):
if (conf[optkey] not in options[optkey] and
type(conf[optkey]) not in options[optkey]):
raise YamlLintConfigError(
'invalid config: option "%s" of "%s" should be in %s'
% (optkey, rule.ID, options[optkey]))
+ # Example: CONF = {option: ['flag1', 'flag2']}
+ # → {option: [flag1]} → {option: [flag1, flag2]}
+ elif isinstance(options[optkey], list):
+ if (type(conf[optkey]) is not list or
+ any(flag not in options[optkey]
+ for flag in conf[optkey])):
+ raise YamlLintConfigError(
+ ('invalid config: option "%s" of "%s" should only '
+ 'contain values in %s')
+ % (optkey, rule.ID, str(options[optkey])))
+ # Example: CONF = {option: int}
+ # → {option: 42}
else:
if not isinstance(conf[optkey], options[optkey]):
raise YamlLintConfigError(
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.15.0/yamllint/linter.py
new/yamllint-1.20.0/yamllint/linter.py
--- old/yamllint-1.15.0/yamllint/linter.py 2019-01-11 12:00:07.000000000
+0100
+++ new/yamllint-1.20.0/yamllint/linter.py 2019-12-26 16:04:47.000000000
+0100
@@ -180,7 +180,7 @@
except yaml.error.MarkedYAMLError as e:
problem = LintProblem(e.problem_mark.line + 1,
e.problem_mark.column + 1,
- 'syntax error: ' + e.problem)
+ 'syntax error: ' + e.problem + ' (syntax)')
problem.level = 'error'
return problem
@@ -189,6 +189,10 @@
assert hasattr(buffer, '__getitem__'), \
'_run() argument must be a buffer, not a stream'
+ first_line = next(parser.line_generator(buffer)).content
+ if re.match(r'^#\s*yamllint disable-file\s*$', first_line):
+ return
+
# If the document contains a syntax error, save it and yield it at the
# right line
syntax_error = get_syntax_error(buffer)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.15.0/yamllint/parser.py
new/yamllint-1.20.0/yamllint/parser.py
--- old/yamllint-1.15.0/yamllint/parser.py 2018-05-31 11:02:35.000000000
+0200
+++ new/yamllint-1.20.0/yamllint/parser.py 2019-04-09 16:48:10.000000000
+0200
@@ -77,7 +77,10 @@
cur = 0
next = buffer.find('\n')
while next != -1:
- yield Line(line_no, buffer, start=cur, end=next)
+ if next > 0 and buffer[next - 1] == '\r':
+ yield Line(line_no, buffer, start=cur, end=next - 1)
+ else:
+ yield Line(line_no, buffer, start=cur, end=next)
cur = next + 1
next = buffer.find('\n', cur)
line_no += 1
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.15.0/yamllint/rules/colons.py
new/yamllint-1.20.0/yamllint/rules/colons.py
--- old/yamllint-1.15.0/yamllint/rules/colons.py 2019-01-11
12:00:07.000000000 +0100
+++ new/yamllint-1.20.0/yamllint/rules/colons.py 2019-06-06
09:52:15.000000000 +0200
@@ -72,7 +72,7 @@
import yaml
-from yamllint.rules.common import spaces_after, spaces_before, is_explicit_key
+from yamllint.rules.common import is_explicit_key, spaces_after, spaces_before
ID = 'colons'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.15.0/yamllint/rules/empty_lines.py
new/yamllint-1.20.0/yamllint/rules/empty_lines.py
--- old/yamllint-1.15.0/yamllint/rules/empty_lines.py 2019-01-11
12:00:07.000000000 +0100
+++ new/yamllint-1.20.0/yamllint/rules/empty_lines.py 2019-04-09
16:48:10.000000000 +0200
@@ -66,27 +66,37 @@
def check(conf, line):
if line.start == line.end and line.end < len(line.buffer):
# Only alert on the last blank line of a series
- if (line.end < len(line.buffer) - 1 and
- line.buffer[line.end + 1] == '\n'):
+ if (line.end + 2 <= len(line.buffer) and
+ line.buffer[line.end:line.end + 2] == '\n\n'):
+ return
+ elif (line.end + 4 <= len(line.buffer) and
+ line.buffer[line.end:line.end + 4] == '\r\n\r\n'):
return
blank_lines = 0
- while (line.start > blank_lines and
- line.buffer[line.start - blank_lines - 1] == '\n'):
+ start = line.start
+ while start >= 2 and line.buffer[start - 2:start] == '\r\n':
+ blank_lines += 1
+ start -= 2
+ while start >= 1 and line.buffer[start - 1] == '\n':
blank_lines += 1
+ start -= 1
max = conf['max']
# Special case: start of document
- if line.start - blank_lines == 0:
+ if start == 0:
blank_lines += 1 # first line doesn't have a preceding \n
max = conf['max-start']
# Special case: end of document
# NOTE: The last line of a file is always supposed to end with a new
# line. See POSIX definition of a line at:
- if line.end == len(line.buffer) - 1 and line.buffer[line.end] == '\n':
+ if ((line.end == len(line.buffer) - 1 and
+ line.buffer[line.end] == '\n') or
+ (line.end == len(line.buffer) - 2 and
+ line.buffer[line.end:line.end + 2] == '\r\n')):
# Allow the exception of the one-byte file containing '\n'
if line.end == 0:
return
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.15.0/yamllint/rules/empty_values.py
new/yamllint-1.20.0/yamllint/rules/empty_values.py
--- old/yamllint-1.15.0/yamllint/rules/empty_values.py 2019-01-11
12:00:07.000000000 +0100
+++ new/yamllint-1.20.0/yamllint/rules/empty_values.py 2019-10-15
16:18:58.000000000 +0200
@@ -75,8 +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}
+DEFAULT = {'forbid-in-block-mappings': True,
+ 'forbid-in-flow-mappings': True}
def check(conf, token, prev, next, nextnext, context):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.15.0/yamllint/rules/indentation.py
new/yamllint-1.20.0/yamllint/rules/indentation.py
--- old/yamllint-1.15.0/yamllint/rules/indentation.py 2019-01-11
12:00:07.000000000 +0100
+++ new/yamllint-1.20.0/yamllint/rules/indentation.py 2019-06-06
09:52:15.000000000 +0200
@@ -193,7 +193,7 @@
import yaml
from yamllint.linter import LintProblem
-from yamllint.rules.common import is_explicit_key, get_real_end_line
+from yamllint.rules.common import get_real_end_line, is_explicit_key
ID = 'indentation'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.15.0/yamllint/rules/new_lines.py
new/yamllint-1.20.0/yamllint/rules/new_lines.py
--- old/yamllint-1.15.0/yamllint/rules/new_lines.py 2019-01-11
12:00:07.000000000 +0100
+++ new/yamllint-1.20.0/yamllint/rules/new_lines.py 2019-04-09
16:48:10.000000000 +0200
@@ -36,10 +36,11 @@
def check(conf, line):
if line.start == 0 and len(line.buffer) > line.end:
if conf['type'] == 'dos':
- if line.buffer[line.end - 1:line.end + 1] != '\r\n':
+ if (line.end + 2 > len(line.buffer) or
+ line.buffer[line.end:line.end + 2] != '\r\n'):
yield LintProblem(1, line.end - line.start + 1,
'wrong new line character: expected \\r\\n')
else:
- if line.end > 0 and line.buffer[line.end - 1] == '\r':
- yield LintProblem(1, line.end - line.start,
+ if line.buffer[line.end] == '\r':
+ yield LintProblem(1, line.end - line.start + 1,
'wrong new line character: expected \\n')
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.15.0/yamllint/rules/octal_values.py
new/yamllint-1.20.0/yamllint/rules/octal_values.py
--- old/yamllint-1.15.0/yamllint/rules/octal_values.py 2019-01-11
12:00:07.000000000 +0100
+++ new/yamllint-1.20.0/yamllint/rules/octal_values.py 2019-10-15
16:18:58.000000000 +0200
@@ -66,8 +66,8 @@
TYPE = 'token'
CONF = {'forbid-implicit-octal': bool,
'forbid-explicit-octal': bool}
-DEFAULT = {'forbid-implicit-octal': False,
- 'forbid-explicit-octal': False}
+DEFAULT = {'forbid-implicit-octal': True,
+ 'forbid-explicit-octal': True}
def check(conf, token, prev, next, nextnext, context):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.15.0/yamllint/rules/truthy.py
new/yamllint-1.20.0/yamllint/rules/truthy.py
--- old/yamllint-1.15.0/yamllint/rules/truthy.py 2019-01-11
12:00:07.000000000 +0100
+++ new/yamllint-1.20.0/yamllint/rules/truthy.py 2019-08-27
09:46:03.000000000 +0200
@@ -15,13 +15,22 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
-Use this rule to forbid non-explictly typed truthy values other than ``true``
-and ``false``, for example ``YES``, ``False`` and ``off``.
+Use this rule to forbid non-explictly typed truthy values other than allowed
+ones (by default: ``true`` and ``false``), for example ``YES`` or ``off``.
This can be useful to prevent surprises from YAML parsers transforming
``[yes, FALSE, Off]`` into ``[true, false, false]`` or
``{y: 1, yes: 2, on: 3, true: 4, True: 5}`` into ``{y: 1, true: 5}``.
+.. rubric:: Options
+
+* ``allowed-values`` defines the list of truthy values which will be ignored
+ during linting. The default is ``['true', 'false']``, but can be changed to
+ any list containing: ``'TRUE'``, ``'True'``, ``'true'``, ``'FALSE'``,
+ ``'False'``, ``'false'``, ``'YES'``, ``'Yes'``, ``'yes'``, ``'NO'``,
+ ``'No'``, ``'no'``, ``'ON'``, ``'On'``, ``'on'``, ``'OFF'``, ``'Off'``,
+ ``'off'``.
+
.. rubric:: Examples
#. With ``truthy: {}``
@@ -63,29 +72,55 @@
yes: 1
on: 2
True: 3
+
+#. With ``truthy: {allowed-values: ["yes", "no"]}``
+
+ the following code snippet would **PASS**:
+ ::
+
+ - yes
+ - no
+ - "true"
+ - 'false'
+ - foo
+ - bar
+
+ the following code snippet would **FAIL**:
+ ::
+
+ - true
+ - false
+ - on
+ - off
"""
import yaml
from yamllint.linter import LintProblem
-ID = 'truthy'
-TYPE = 'token'
TRUTHY = ['YES', 'Yes', 'yes',
'NO', 'No', 'no',
- 'TRUE', 'True', # 'true' is a boolean
- 'FALSE', 'False', # 'false' is a boolean
+ 'TRUE', 'True', 'true',
+ 'FALSE', 'False', 'false',
'ON', 'On', 'on',
'OFF', 'Off', 'off']
+ID = 'truthy'
+TYPE = 'token'
+CONF = {'allowed-values': list(TRUTHY)}
+DEFAULT = {'allowed-values': ['true', 'false']}
+
+
def check(conf, token, prev, next, nextnext, context):
if prev and isinstance(prev, yaml.tokens.TagToken):
return
if isinstance(token, yaml.tokens.ScalarToken):
- if token.value in TRUTHY and token.style is None:
+ if (token.value in (set(TRUTHY) - set(conf['allowed-values'])) and
+ token.style is None):
yield LintProblem(token.start_mark.line + 1,
token.start_mark.column + 1,
- "truthy value should be true or false")
+ "truthy value should be one of [" +
+ ", ".join(sorted(conf['allowed-values'])) + "]")
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yamllint-1.15.0/yamllint.egg-info/PKG-INFO
new/yamllint-1.20.0/yamllint.egg-info/PKG-INFO
--- old/yamllint-1.15.0/yamllint.egg-info/PKG-INFO 2019-02-11
14:22:05.000000000 +0100
+++ new/yamllint-1.20.0/yamllint.egg-info/PKG-INFO 2019-12-26
16:07:34.000000000 +0100
@@ -1,6 +1,6 @@
Metadata-Version: 1.2
Name: yamllint
-Version: 1.15.0
+Version: 1.20.0
Summary: A linter for YAML files.
Home-page: https://github.com/adrienverge/yamllint
Author: Adrien Vergé