Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
98f2281f56 | ||
|
|
15eafeb80a | ||
|
|
16eae28a50 | ||
|
|
771c3a0412 | ||
|
|
b92fc9cb31 | ||
|
|
e90e0a0eb5 | ||
|
|
6bfd6756e2 | ||
|
|
6b45be1afc |
4
.flake8
Normal file
4
.flake8
Normal file
@@ -0,0 +1,4 @@
|
||||
[flake8]
|
||||
import-order-style = pep8
|
||||
application-import-names = yamllint
|
||||
ignore = W503,W504
|
||||
15
.github/workflows/ci.yaml
vendored
15
.github/workflows/ci.yaml
vendored
@@ -21,14 +21,15 @@ jobs:
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v4
|
||||
- run:
|
||||
python -m pip install flake8 flake8-import-order sphinx
|
||||
rstcheck[sphinx] doc8
|
||||
- run: python -m pip install .
|
||||
pip install flake8 flake8-import-order sphinx rstcheck[sphinx] doc8
|
||||
- run: pip install .
|
||||
- run: flake8 .
|
||||
- run: doc8 $(git ls-files '*.rst')
|
||||
- run: rstcheck --ignore-directives automodule $(git ls-files '*.rst')
|
||||
- run: yamllint --strict $(git ls-files '*.yaml' '*.yml')
|
||||
- run: python setup.py build_sphinx
|
||||
- run: make -C docs html
|
||||
- name: Check for broken links in documentation
|
||||
run: make -C docs linkcheck
|
||||
|
||||
test:
|
||||
name: Tests
|
||||
@@ -51,8 +52,10 @@ jobs:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Append GitHub Actions system path
|
||||
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
|
||||
- run: pip install coveralls
|
||||
- run: pip install coverage
|
||||
- run: pip install .
|
||||
- run: coverage run --source=yamllint -m unittest discover
|
||||
# https://github.com/AndreMiras/coveralls-python-action/issues/18
|
||||
- run: echo -e "[run]\nrelative_files = True" > .coveragerc
|
||||
- run: coverage run -m unittest discover
|
||||
- name: Coveralls
|
||||
uses: AndreMiras/coveralls-python-action@develop
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
Changelog
|
||||
=========
|
||||
|
||||
1.31.0 (2023-04-21)
|
||||
-------------------
|
||||
|
||||
- Build: migrate from ``setup.py`` to ``pyproject.toml``
|
||||
- Docs: update some outdated URLs
|
||||
- Rule ``colons``: prevent error when space before is mandatory
|
||||
|
||||
1.30.0 (2023-03-22)
|
||||
-------------------
|
||||
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
include LICENSE
|
||||
include README.rst
|
||||
include docs/*
|
||||
include tests/*.py tests/rules/*.py tests/yaml-1.2-spec-examples/*
|
||||
@@ -8,8 +8,8 @@ repetition and cosmetic problems such as lines length, trailing spaces,
|
||||
indentation, etc.
|
||||
|
||||
.. image::
|
||||
https://travis-ci.org/adrienverge/yamllint.svg?branch=master
|
||||
:target: https://travis-ci.org/adrienverge/yamllint
|
||||
https://github.com/adrienverge/yamllint/actions/workflows/ci.yaml/badge.svg?branch=master
|
||||
:target: https://github.com/adrienverge/yamllint/actions/workflows/ci.yaml?query=branch%3Amaster
|
||||
:alt: CI tests status
|
||||
.. image::
|
||||
https://coveralls.io/repos/github/adrienverge/yamllint/badge.svg?branch=master
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#
|
||||
|
||||
# You can set these variables from the command line.
|
||||
SPHINXOPTS =
|
||||
SPHINXOPTS = -W
|
||||
SPHINXBUILD = sphinx-build
|
||||
PAPER =
|
||||
BUILDDIR = _build
|
||||
|
||||
@@ -190,8 +190,8 @@ or ignore paths only for specific rules:
|
||||
|
||||
Note that this ``.gitignore``-style path pattern allows complex path
|
||||
exclusion/inclusion, see the `pathspec README file
|
||||
<https://pypi.python.org/pypi/pathspec>`_ for more details.
|
||||
Here is a more complex example:
|
||||
<https://pypi.org/project/pathspec/>`_ for more details. Here is a more complex
|
||||
example:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ Screenshot
|
||||
|
||||
.. note::
|
||||
|
||||
The default output format is inspired by `eslint <http://eslint.org/>`_, a
|
||||
The default output format is inspired by `eslint <https://eslint.org/>`_, a
|
||||
great linting tool for Javascript.
|
||||
|
||||
Table of contents
|
||||
|
||||
@@ -4,7 +4,7 @@ Quickstart
|
||||
Installing yamllint
|
||||
-------------------
|
||||
|
||||
On Fedora / CentOS (note: `EPEL <https://fedoraproject.org/wiki/EPEL>`_ is
|
||||
On Fedora / CentOS (note: `EPEL <https://docs.fedoraproject.org/en-US/epel/>`_ is
|
||||
required on CentOS):
|
||||
|
||||
.. code:: bash
|
||||
@@ -45,7 +45,7 @@ If you prefer installing from source, you can run, from the source directory:
|
||||
|
||||
.. code:: bash
|
||||
|
||||
python setup.py sdist
|
||||
python -m build
|
||||
pip install --user dist/yamllint-*.tar.gz
|
||||
|
||||
Running yamllint
|
||||
|
||||
@@ -13,7 +13,7 @@ Assuming that the `ALE <https://github.com/dense-analysis/ale>`_ plugin is
|
||||
installed, yamllint is supported by default. It is automatically enabled when
|
||||
editing YAML files.
|
||||
|
||||
If you instead use the `syntastic <https://github.com/scrooloose/syntastic>`_
|
||||
If you instead use the `syntastic <https://github.com/vim-syntastic/syntastic>`_
|
||||
plugin, add this to your ``.vimrc``:
|
||||
|
||||
::
|
||||
@@ -23,7 +23,7 @@ plugin, add this to your ``.vimrc``:
|
||||
Neovim
|
||||
------
|
||||
|
||||
Assuming that the `neomake <https://github.com/benekastah/neomake>`_ plugin is
|
||||
Assuming that the `neomake <https://github.com/neomake/neomake>`_ plugin is
|
||||
installed, yamllint is supported by default. It is automatically enabled when
|
||||
editing YAML files.
|
||||
|
||||
|
||||
54
pyproject.toml
Normal file
54
pyproject.toml
Normal file
@@ -0,0 +1,54 @@
|
||||
[project]
|
||||
name = "yamllint"
|
||||
description = "A linter for YAML files."
|
||||
readme = {file = "README.rst", content-type = "text/x-rst"}
|
||||
requires-python = ">=3.7"
|
||||
license = {text = "GPL-3.0-only"}
|
||||
authors = [{name = "Adrien Vergé"}]
|
||||
keywords = ["yaml", "lint", "linter", "syntax", "checker"]
|
||||
classifiers = [
|
||||
"Development Status :: 5 - Production/Stable",
|
||||
"Environment :: Console",
|
||||
"Intended Audience :: Developers",
|
||||
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
|
||||
"Programming Language :: Python",
|
||||
"Topic :: Software Development",
|
||||
"Topic :: Software Development :: Debuggers",
|
||||
"Topic :: Software Development :: Quality Assurance",
|
||||
"Topic :: Software Development :: Testing",
|
||||
]
|
||||
dependencies = [
|
||||
"pathspec >= 0.5.3",
|
||||
"pyyaml",
|
||||
]
|
||||
dynamic = ["version"]
|
||||
|
||||
[project.optional-dependencies]
|
||||
dev = [
|
||||
"doc8",
|
||||
"flake8",
|
||||
"flake8-import-order",
|
||||
"rstcheck[sphinx]",
|
||||
"sphinx",
|
||||
]
|
||||
|
||||
[project.scripts]
|
||||
yamllint = "yamllint.cli:run"
|
||||
|
||||
[project.urls]
|
||||
homepage = "https://github.com/adrienverge/yamllint"
|
||||
repository = "https://github.com/adrienverge/yamllint"
|
||||
documentation = "https://yamllint.readthedocs.io"
|
||||
|
||||
[build-system]
|
||||
build-backend = "setuptools.build_meta"
|
||||
requires = ["setuptools >= 61"]
|
||||
|
||||
[tool.setuptools]
|
||||
packages = ["yamllint", "yamllint.conf", "yamllint.rules"]
|
||||
|
||||
[tool.setuptools.package-data]
|
||||
yamllint = ["conf/*.yaml"]
|
||||
|
||||
[tool.setuptools.dynamic]
|
||||
version = {attr = "yamllint.__version__"}
|
||||
69
setup.cfg
69
setup.cfg
@@ -1,69 +0,0 @@
|
||||
[flake8]
|
||||
import-order-style = pep8
|
||||
application-import-names = yamllint
|
||||
ignore = W503,W504
|
||||
|
||||
[build_sphinx]
|
||||
all-files = 1
|
||||
source-dir = docs
|
||||
build-dir = docs/_build
|
||||
warning-is-error = 1
|
||||
|
||||
[metadata]
|
||||
keywords =
|
||||
yaml
|
||||
lint
|
||||
linter
|
||||
syntax
|
||||
checker
|
||||
|
||||
url = https://github.com/adrienverge/yamllint
|
||||
classifiers =
|
||||
Development Status :: 5 - Production/Stable
|
||||
Environment :: Console
|
||||
Intended Audience :: Developers
|
||||
License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
||||
Programming Language :: Python :: 3
|
||||
Programming Language :: Python :: 3.7
|
||||
Programming Language :: Python :: 3.8
|
||||
Programming Language :: Python :: 3.9
|
||||
Programming Language :: Python :: 3.10
|
||||
Programming Language :: Python :: 3.11
|
||||
Topic :: Software Development
|
||||
Topic :: Software Development :: Debuggers
|
||||
Topic :: Software Development :: Quality Assurance
|
||||
Topic :: Software Development :: Testing
|
||||
|
||||
project_urls =
|
||||
Documentation = https://yamllint.readthedocs.io
|
||||
Download = https://pypi.org/project/yamllint/#files
|
||||
Bug Tracker = https://github.com/adrienverge/yamllint/issues
|
||||
Source Code = https://github.com/adrienverge/yamllint
|
||||
|
||||
[options]
|
||||
packages = find:
|
||||
|
||||
python_requires = >=3.7
|
||||
|
||||
include_package_data = True
|
||||
install_requires =
|
||||
pathspec >= 0.5.3
|
||||
pyyaml
|
||||
setuptools
|
||||
|
||||
test_suite = tests
|
||||
|
||||
[options.packages.find]
|
||||
exclude =
|
||||
tests
|
||||
tests.*
|
||||
|
||||
[options.package_data]
|
||||
yamllint = conf/*.yaml
|
||||
|
||||
[options.entry_points]
|
||||
console_scripts =
|
||||
yamllint = yamllint.cli:run
|
||||
|
||||
[coverage:run]
|
||||
relative_files = True
|
||||
15
setup.py
15
setup.py
@@ -15,15 +15,6 @@
|
||||
|
||||
from setuptools import setup
|
||||
|
||||
from yamllint import (__author__, __license__,
|
||||
APP_NAME, APP_VERSION, APP_DESCRIPTION)
|
||||
|
||||
|
||||
setup(
|
||||
name=APP_NAME,
|
||||
version=APP_VERSION,
|
||||
author=__author__,
|
||||
description=APP_DESCRIPTION.split('\n')[0],
|
||||
long_description=APP_DESCRIPTION,
|
||||
license=__license__,
|
||||
)
|
||||
# This is only kept for backward-compatibility with older versions that don't
|
||||
# support new packaging standards (e.g. PEP 517 or PEP 660):
|
||||
setup()
|
||||
|
||||
@@ -46,7 +46,7 @@ class AnchorsTestCase(RuleTestCase):
|
||||
' <<: *b_m\n'
|
||||
' foo: bar\n'
|
||||
'---\n'
|
||||
'{a: 1, &x b: 2, c: &y 3, *x: 4, e: *y}\n'
|
||||
'{a: 1, &x b: 2, c: &y 3, *x : 4, e: *y}\n'
|
||||
'...\n', conf)
|
||||
self.check('---\n'
|
||||
'- &i 42\n'
|
||||
@@ -74,7 +74,7 @@ class AnchorsTestCase(RuleTestCase):
|
||||
' <<: *b_m\n'
|
||||
' foo: bar\n'
|
||||
'---\n'
|
||||
'{a: 1, &x b: 2, c: &x 3, *x: 4, e: *y}\n'
|
||||
'{a: 1, &x b: 2, c: &x 3, *x : 4, e: *y}\n'
|
||||
'...\n', conf)
|
||||
|
||||
def test_forbid_undeclared_aliases(self):
|
||||
@@ -106,7 +106,7 @@ class AnchorsTestCase(RuleTestCase):
|
||||
' <<: *b_m\n'
|
||||
' foo: bar\n'
|
||||
'---\n'
|
||||
'{a: 1, &x b: 2, c: &y 3, *x: 4, e: *y}\n'
|
||||
'{a: 1, &x b: 2, c: &y 3, *x : 4, e: *y}\n'
|
||||
'...\n', conf)
|
||||
self.check('---\n'
|
||||
'- &i 42\n'
|
||||
@@ -134,7 +134,7 @@ class AnchorsTestCase(RuleTestCase):
|
||||
' <<: *b_m\n'
|
||||
' foo: bar\n'
|
||||
'---\n'
|
||||
'{a: 1, &x b: 2, c: &x 3, *x: 4, e: *y}\n'
|
||||
'{a: 1, &x b: 2, c: &x 3, *x : 4, e: *y}\n'
|
||||
'...\n', conf,
|
||||
problem1=(9, 3),
|
||||
problem2=(10, 3),
|
||||
@@ -142,7 +142,7 @@ class AnchorsTestCase(RuleTestCase):
|
||||
problem4=(12, 3),
|
||||
problem5=(13, 3),
|
||||
problem6=(24, 7),
|
||||
problem7=(27, 36))
|
||||
problem7=(27, 37))
|
||||
|
||||
def test_forbid_duplicated_anchors(self):
|
||||
conf = ('anchors:\n'
|
||||
@@ -173,7 +173,7 @@ class AnchorsTestCase(RuleTestCase):
|
||||
' <<: *b_m\n'
|
||||
' foo: bar\n'
|
||||
'---\n'
|
||||
'{a: 1, &x b: 2, c: &y 3, *x: 4, e: *y}\n'
|
||||
'{a: 1, &x b: 2, c: &y 3, *x : 4, e: *y}\n'
|
||||
'...\n', conf)
|
||||
self.check('---\n'
|
||||
'- &i 42\n'
|
||||
@@ -201,7 +201,7 @@ class AnchorsTestCase(RuleTestCase):
|
||||
' <<: *b_m\n'
|
||||
' foo: bar\n'
|
||||
'---\n'
|
||||
'{a: 1, &x b: 2, c: &x 3, *x: 4, e: *y}\n'
|
||||
'{a: 1, &x b: 2, c: &x 3, *x : 4, e: *y}\n'
|
||||
'...\n', conf,
|
||||
problem1=(5, 3),
|
||||
problem2=(6, 3),
|
||||
|
||||
@@ -256,3 +256,19 @@ class ColonTestCase(RuleTestCase):
|
||||
' property: {a: 1, b: 2, c : 3}\n', conf,
|
||||
problem1=(3, 11), problem2=(4, 4),
|
||||
problem3=(8, 23), problem4=(8, 28))
|
||||
|
||||
# Although accepted by PyYAML, `{*x: 4}` is not valid YAML: it should be
|
||||
# noted `{*x : 4}`. The reason is that a colon can be part of an anchor
|
||||
# name. See commit message for more details.
|
||||
def test_with_alias_as_key(self):
|
||||
conf = 'colons: {max-spaces-before: 0, max-spaces-after: 1}'
|
||||
self.check('---\n'
|
||||
'- anchor: &a key\n'
|
||||
'- *a: 42\n'
|
||||
'- {*a: 42}\n'
|
||||
'- *a : 42\n'
|
||||
'- {*a : 42}\n'
|
||||
'- *a : 42\n'
|
||||
'- {*a : 42}\n',
|
||||
conf,
|
||||
problem1=(7, 6), problem2=(8, 7))
|
||||
|
||||
@@ -21,7 +21,7 @@ indentation, etc."""
|
||||
|
||||
|
||||
APP_NAME = 'yamllint'
|
||||
APP_VERSION = '1.30.0'
|
||||
APP_VERSION = '1.31.0'
|
||||
APP_DESCRIPTION = __doc__
|
||||
|
||||
__author__ = 'Adrien Vergé'
|
||||
|
||||
@@ -92,7 +92,9 @@ DEFAULT = {'max-spaces-before': 0,
|
||||
|
||||
|
||||
def check(conf, token, prev, next, nextnext, context):
|
||||
if isinstance(token, yaml.ValueToken):
|
||||
if isinstance(token, yaml.ValueToken) and not (
|
||||
isinstance(prev, yaml.AliasToken) and
|
||||
token.start_mark.pointer - prev.end_mark.pointer == 1):
|
||||
problem = spaces_before(token, prev, next,
|
||||
max=conf['max-spaces-before'],
|
||||
max_desc='too many spaces before colon')
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
Use this rule to require a new line character (``\\n``) at the end of files.
|
||||
|
||||
The POSIX standard `requires the last line to end with a new line character
|
||||
<http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206>`_.
|
||||
<https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206>`_.
|
||||
All UNIX tools expect a new line at the end of files. Most text editors use
|
||||
this convention too.
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user