Commit Graph

483 Commits (master)
 

Author SHA1 Message Date
Adrien Vergé 1b378ed5b9 quoted-strings: Fix explicit octal recognition
PyYAML implements YAML spec version 1.1, not 1.2. Hence, values starting
with `0o` are not considered as numbers: they are just strings, so they
need quotes when `quoted-strings: {required: true}`.

>>> import yaml
>>> yaml.resolver.Resolver().resolve(yaml.nodes.ScalarNode, '100', (True, False))
'tag:yaml.org,2002:int'
>>> yaml.resolver.Resolver().resolve(yaml.nodes.ScalarNode, '0100', (True, False))
'tag:yaml.org,2002:int'
>>> yaml.resolver.Resolver().resolve(yaml.nodes.ScalarNode, '0o100', (True, False))
'tag:yaml.org,2002:str'

Let's try to prevent that.

Fixes https://github.com/adrienverge/yamllint/issues/351.
4 years ago
Adrien Vergé a3fc64d134 End support for Python 2
As planned and advertized, yamllint drops support for Python 2 on 2021.
4 years ago
Rusty Geldmacher ee4d163ff8
Allow only non-empty brackets/braces
We'd like to disallow brackets and braces in our YAML, but there's a
catch: the only way to describe an empty array or hash in YAML is to
supply an empty one (`[]` or `{}`). Otherwise, the value will be null.

This commit adds a `non-empty` option to `forbid` for brackets and
braces. When it is set, all flow and sequence mappings will cause errors
_except_ for empty ones.
4 years ago
Jason Mobarak 22335b294d Add support for Python 3.9, drop Python 3.4
Add support for Python 3.9 since it was officially released in October
and drop support for Python 3.4 since it is end-of-life (EOL).
4 years ago
Rex Ledesma 0f9dffde23
docs: Add configuration for integration with Arcanist 4 years ago
Mathieu Couette cef0b48993 tests: Add unittest aliases to Python 2.7 4 years ago
Mathieu Couette 11b1f1c14e tests: Fix indentation issues 4 years ago
Mathieu Couette 9ee8c27ac9 tests: Replace deprecated aliases
https://docs.python.org/3/library/unittest.html#deprecated-aliases
4 years ago
Florian Bruhin 8eebab68ab Fix typo in changelog 4 years ago
Per Lundberg 2103bd73de README.rst: fix typo 4 years ago
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
4 years ago
Adrien Vergé 16e0f9d7b2 yamllint version 1.25.0 4 years ago
Mathieu Couette 1a4f9fe00f
gitignore: Add /.eggs
Quick PR to ignore the `/.eggs` folder, which appears to be generated every
time the `python setup.py test` command is run.

The content of the `./.eggs/README.txt` file:

> This directory contains eggs that were downloaded by setuptools to build,
> test, and run plug-ins.
> 
> This directory caches those eggs to prevent repeated downloads.
> 
> However, it is safe to delete this directory.
4 years ago
Mathieu Couette 027d1b0a9a
directives: Fix DOS lines messing with rule IDs
Fixes #325

The linter allows a directive to contain trailing whitespace characters like
\r, but does not trim them before iterating on the rules. As a result, the last
rule in the list contains the trailing whitespace characters and never matches
any existing rule.

I added the necessary trimming, as well as a test with 2 checks to go along
with it.
4 years ago
Andrew Imeson 67cb4eb24d Auto-change output format if GitHub Actions detected 4 years ago
Andrew Imeson 50c7453824 Add support for GitHub Annotations output format
Support the format used by GitHub Actions to annotate pull
requests with linter failures
4 years ago
Satoru SATOH 549b136a04 fix: add runtime dependency to setuptools
yamllint depends on pkg_resources.load_entry_point from setuptools to
make its command working, so this runtime dependency to setuptools is
necessary to be listed.
4 years ago
Satoru SATOH 333ae52c78 Add 'forbid' configurations to the braces and brackets rules
Add 'forbid' configuration parameters to the braces and brackets rules
to allow users to forbid the use of flow style collections, flow
mappings and flow sequences.
4 years ago
Julien Falque 0a88c55194
quoted-strings: Fix detecting strings with hashtag as requiring quotes 4 years ago
Julien Falque ac19d1e427
octal-values: Prevent detection of 8 and 9 as octal values 4 years ago
Adrien Vergé 597e88bb7b docs: Make 'yaml-file' config documentation clearer
Related to https://github.com/adrienverge/yamllint/issues/311.
4 years ago
Satoru SATOH 29d2b50d50 enhancement: add some metadata to provide extra info in its PyPI page
Add some metadata (project_urls) to provide extra info in its PyPI page.

Signed-off-by: Satoru SATOH <satoru.satoh@gmail.com>
4 years ago
Satoru SATOH 4171cdafc9 Move setuptools' packaging configuration from setup.py to setup.cfg
Move setuptools' packaging configuration from setup.py to setup.cfg to
simplify setup.py and make its packaging more dedeclarative.

Signed-off-by: Satoru SATOH <satoru.satoh@gmail.com>
4 years ago
Sorin Sbarnea d274543b72
docs: Add Python API usage example
Fixes: #297
4 years ago
Kirill Deyko 8da98f2122
commas: Fix example in documentation
Error in the example snippet, it would NOT pass otherwise actually:
```
$ cat test.yml
strange var:
  [10, 20,30, {x: 1, y: 2}]

$ yamllint -d "{extends: default, rules: {commas: {min-spaces-after: 1, max-spaces-after: 1}}}" test.yml
test.yml
  1:1       warning  missing document start "---"  (document-start)
  2:11      error    too few spaces after comma  (commas)
```
4 years ago
Benjamin Wuethrich b65769c9d2
docs: Add default values to rules with options 5 years ago
Wolfgang Walther b80997eba6
CI: Add build environment without UTF-8 locales to travis-ci
Preventing regressions like #285
5 years ago
Adrien Vergé 8b758d4e7e yamllint version 1.24.2 5 years ago
Wolfgang Walther b5b436a3a4
Add global "locale" config option and make key-ordering rule locale-aware
Support sorting by locale with strcoll(). Properly handle case and accents.

Note: this is a second implementation, for context see:
https://github.com/adrienverge/yamllint/pull/280
https://github.com/adrienverge/yamllint/issues/285
https://github.com/adrienverge/yamllint/pull/288
5 years ago
Adrien Vergé 0fceca2354 yamllint version 1.24.1 5 years ago
Adrien Vergé 9403f1f3ec Revert "Add global "locale" config option"
This reverts commit 9e90c77, because it caused a bug that affected
different people just after being released:
https://github.com/adrienverge/yamllint/issues/285
https://github.com/adrienverge/yamllint/issues/286
5 years ago
Adrien Vergé 0016390e78 yamllint version 1.24.0 5 years ago
Wolfgang Walther 9e90c777cb
Add global "locale" config option and make key-ordering rule locale-aware
Support sorting by locale with strcoll(). Properly handle case and accents.
5 years ago
Jonathan Sokolowski a2218988ee
config: Do no match directories that look like YAML files
Fixes #279
5 years ago
Adrien Vergé 954fdd5e8f style: Fix 'noqa' for flake8 3.8.0
There was a change in behavior of E402, see:
https://gitlab.com/pycqa/flake8/-/issues/638#note_345108633
5 years ago
Sorin Sbarnea bbcad943b6
style: Ignore flake8 warnings W503 and W504
Avoid W503/W504 with current code as the current code not compliant
and they are contradictory.
5 years ago
Adrien Vergé 30c90dbf70 Add contribution instructions in CONTRIBUTING.rst
Closes https://github.com/adrienverge/yamllint/issues/263.
5 years ago
Brad Solomon 512fe17047
Fix bug with CRLF in new-lines and require-starting-space
Pound-signs followed by a lone CRLF should not
raise if require-starting-space is specified.

If require-starting-space is true, *and* either:
- new-lines: disbale, or
- newlines: type: dos
is specified, a line with `#\r` or `#\r\n` should
not raise a false positive.

This commit also uses a Set for O(1) membership testing
and uses the correct escape sequence for the nul byte.

If we find a CRLF when looking for Unix newlines, yamllint
should always raise, regardless of logic with
require-starting-space.

Closes: Issue #171.
5 years ago
Will Badart 278a79f093 Mention YAMLLINT_CONFIG_FILE in the documentation 5 years ago
Brad Solomon e98aacf62c Add Python 3.8 to PyPI/trove classifier data
3.8 is now formally supported in .travis.yml
as of this commit.
5 years ago
Will Badart 94c0416f6b
Specify config with environment variable YAMLLINT_CONFIG_FILE
Add option to specify config file with environment variable.
Add test case.
5 years ago
Adrien Vergé a54cbce1b6 yamllint version 1.23.0 5 years ago
Adrien Vergé b711fd993e quoted-strings: Add options extra-required and extra-allowed
Add ability to:
- require strings to be quoted if they match a pattern (PCRE regex)
- allow quoted strings if they match a pattern, while `require:
  only-when-needed` is enforced.

Co-Authored-By: Leo Feyer (https://github.com/adrienverge/yamllint/pull/246)
5 years ago
Adrien Vergé d68022b846 config: Allow generic types inside lists
For example it's possible to define a conf like:

    rule:
      foo: [str],
      bar: [int, bool, 'magic'],
5 years ago
Adrien Vergé 851d34b9fd config: Allow rules to validate their configuration 5 years ago
Adrien Vergé 483a8d89a5 yamllint version 1.22.1 5 years ago
Adrien Vergé fa87913566 quoted-strings: Fix only-when-needed on corner cases
Change implementation of `required: only-when-needed`, because
maintaining a list of `START_TOKENS` and just looking at the first
character of string values has proven to be partially broken.

Cf. discussion at
https://github.com/adrienverge/yamllint/pull/246#issuecomment-612354097.

Fixes https://github.com/adrienverge/yamllint/issues/242 and
https://github.com/adrienverge/yamllint/pull/244.
5 years ago
Adrien Vergé 961c496b4f yamllint version 1.22.0 5 years ago
Adrien Vergé ce7d3fcc7b quoted-strings: Remove test_quotes_required()
It is exactly the same tests as `test_quote_type_any()`.
5 years ago
Adrien Vergé 0bffba1e13 quoted-strings: Remove test_single_quotes_required()
It is exactly the same tests as `test_quote_type_single()`.
5 years ago