Compare commits

..

4 Commits

Author SHA1 Message Date
Adrien Vergé
415b1c7091 [WIP] Fix for #334 (directories like 'dir.yaml' + recursive search)
Partially reverts a221898 to fix https://github.com/adrienverge/yamllint/issues/334

Linked to https://github.com/cpburnz/python-path-specification/issues/41.
2020-10-10 10:26:31 +02:00
Florian Bruhin
8eebab68ab Fix typo in changelog 2020-10-05 09:42:42 +02:00
Per Lundberg
2103bd73de README.rst: fix typo 2020-10-02 12:51:01 +02:00
Adrien Vergé
85c8631183 tests: Stop using deprecated 'python setup.py test'
Using `python setup.py test` is now deprecated [1], users are encouraged
to be explicit about the test command.

Running yamllint tests using the Python standard library (`unittest`)
can be done using:

    python -m unittest discover

Why not nose, tox or pytest? Because they would add a dependency, make
tests running more complicated and verbose for new users, and their
benefit is not worth for this simple project (only 2 runtime
dependencies: PyYAML and pathspec).

Resolves https://github.com/adrienverge/yamllint/issues/328.

[1]: https://github.com/pypa/setuptools/pull/1878
2020-09-30 09:43:31 +02:00
7 changed files with 20 additions and 7 deletions

2
.gitignore vendored
View File

@@ -5,3 +5,5 @@ __pycache__
/yamllint.egg-info
/build
/.eggs
*.yaml
!*.yaml/

View File

@@ -20,7 +20,7 @@ script:
- if [[ $TRAVIS_PYTHON_VERSION != nightly ]]; then flake8 .; fi
- if [[ $TRAVIS_PYTHON_VERSION != 2* ]]; then doc8 $(git ls-files '*.rst'); fi
- yamllint --strict $(git ls-files '*.yaml' '*.yml')
- coverage run --source=yamllint setup.py test
- coverage run --source=yamllint -m unittest discover
- if [[ $TRAVIS_PYTHON_VERSION != 2* ]]; then
python setup.py build_sphinx;
fi

View File

@@ -5,7 +5,7 @@ Changelog
-------------------
- Run tests on Travis both with and without UTF-8 locales
- Improve documentationon with default values to rules with options
- Improve documentation with default values to rules with options
- Improve documentation with a Python API usage example
- Fix documentation on ``commas`` examples
- Packaging: move setuptools' configuration from ``setup.py`` to ``setup.cfg``

View File

@@ -13,7 +13,9 @@ Pull Request Process
.. code:: bash
python setup.py test
pip install --user .
python -m unittest discover # all tests...
python -m unittest tests/rules/test_commas.py # or just some tests (faster)
3. If you add code that should be tested, add tests.

View File

@@ -22,7 +22,7 @@ indentation, etc.
Written in Python (compatible with Python 2 & 3).
⚠ Python 2 upstream support stopped on January 1, 2020. yamllint will keep
best-effort support for Python 2.7 until January 1, 2021. Passed that date,
best-effort support for Python 2.7 until January 1, 2021. Past that date,
yamllint will drop all Python 2-related code.
Documentation

View File

@@ -2,8 +2,11 @@
yaml-files:
- '*.yaml'
- '!*.yaml/'
- '*.yml'
- '!*.yml/'
- '.yamllint'
- '!.yamllint/'
rules:
braces: enable

View File

@@ -32,8 +32,14 @@ class YamlLintConfig(object):
self.ignore = None
self.yaml_files = pathspec.PathSpec.from_lines(
'gitwildmatch', ['*.yaml', '*.yml', '.yamllint'])
self.yaml_files = pathspec.PathSpec.from_lines('gitwildmatch', [
'*.yaml',
'!*.yaml/',
'*.yml',
'!*.yml/',
'.yamllint',
'!.yamllint/',
])
self.locale = None
@@ -48,7 +54,7 @@ class YamlLintConfig(object):
return self.ignore and self.ignore.match_file(filepath)
def is_yaml_file(self, filepath):
return self.yaml_files.match_file(os.path.basename(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()