adrienverge / yamllint Goto Github PK
View Code? Open in Web Editor NEWA linter for YAML files.
License: GNU General Public License v3.0
A linter for YAML files.
License: GNU General Public License v3.0
I work with a lot of yaml files that can have extremely long lines that can't be broken but aren't passing the default profile. I want to fail on any line that is > 80 char unless explicitly ignored. Is this possible?
For instance with puppet syntax checking I would do something like:
# lint:ignore:80chars
my very long line which is longer than 80 chars
# lint:endignore
I don't see anything in the docs to indicate if something like this is possible
I get this error on some lines in files being checked on Linux system. The files pass on Windows. The error is on a line with only comment chars, ex:
#################################################
It doesn't fail all lines, like this just in some files. It may have something to do with line-endings. I'm using Jenkins to execute a CI yamllint check and it is running on Linux and pulls source using Git. I am also seeing line-endings errors on the same files.
yamllint 1.0.2 from pypi fails nose tests on python 3.5
======================================================================
ERROR: Failure: UnicodeDecodeError ('ascii' codec can't decode byte 0xc3 in position 46: ordinal not in range(128))
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python3.5/site-packages/nose/failure.py", line 39, in runTest
raise self.exc_val.with_traceback(self.tb)
File "/usr/lib/python3.5/site-packages/nose/loader.py", line 418, in loadTestsFromName
addr.filename, addr.module)
File "/usr/lib/python3.5/site-packages/nose/importer.py", line 47, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/usr/lib/python3.5/site-packages/nose/importer.py", line 94, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/usr/lib64/python3.5/imp.py", line 234, in load_module
return load_source(name, filename, file)
File "/usr/lib64/python3.5/imp.py", line 172, in load_source
module = _load(spec)
File "<frozen importlib._bootstrap>", line 693, in _load
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 662, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/builddir/build/BUILD/yamllint-1.0.2/tests/test_spec_examples.py", line 184, in <module>
_gen_test(f.read(), conf))
File "/usr/lib64/python3.5/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 46: ordinal not in range(128)
----------------------------------------------------------------------
Ran 133 tests in 4.938s
FAILED (errors=1)
This happened in a koji scratch build: http://koji.fedoraproject.org/koji/taskinfo?taskID=13121566
In order to enforce uniform key ordering in a mapping I want to have a rule for checking lexicographical sorting.
According to specs, " the content of each sibling node may be further indented independently".
In such cases, this yamllint currently outputs an error. Maybe it should be a warning?
There doesn't seem to be a way to lint all files in a directory, but exclude some, for example:
$
└── foo
├── a.yml
├── b1.yml
├── b2.yml
├── b3.yml
├── c.yml
├── d.yml
└── e.yml
Let's say that, for whatever reason, I don't care about the formatting of some of these yml files. I'd like to be able to run something along the lines of:
yamllint foo --exclude=c.yml
or
yamllint foo --exclude=b*.yml
or perhaps multiple...
yamllint foo --exclude=b*.yml,d.yml
My specific use case is a directory with a bunch of organized yml files that also includes a git submodule with some yml files that would fail linting. It's third-party code and doesn't live in our repository, so I don't need to validate it.
Alternatively, this could be configurable:
# .yamllint
files_or_dirs:
include:
- foo
- bar
- baz.yml
exclude:
- foo/b*.yml
- bar/boo.yml
Thanks for sharing this library! It was very easy to get everything going.
Afaict from searching the docs don't point out that extends
can have a value other than default
- I had to read the code to discover it can also take filepaths and names of other standard configs shipped with yamllint.
The docs for #27 already show up on http://yamllint.readthedocs.io/en/latest/configuration.html#errors-and-warnings, but that feature isn't present in the released version.
The default rule set is easy to find in the docs. I can't find the relaxed config anywhere. Can you add this to the documentation in an easy place to find?
Apparently PyYAML just crashes when loading emoji, but it's not clear why:
$ echo 💩 > test.yml
$ yamllint test.yml
Traceback (most recent call last):
File "/usr/local/bin/yamllint", line 11, in <module>
sys.exit(run())
File "/usr/local/lib/python2.7/site-packages/yamllint/cli.py", line 119, in run
for problem in linter.run(f, conf):
File "/usr/local/lib/python2.7/site-packages/yamllint/linter.py", line 184, in _run
syntax_error = get_syntax_error(buffer)
File "/usr/local/lib/python2.7/site-packages/yamllint/linter.py", line 169, in get_syntax_error
list(yaml.parse(buffer, Loader=yaml.BaseLoader))
File "/usr/local/lib/python2.7/site-packages/yaml/__init__.py", line 34, in parse
loader = Loader(stream)
File "/usr/local/lib/python2.7/site-packages/yaml/loader.py", line 14, in __init__
Reader.__init__(self, stream)
File "/usr/local/lib/python2.7/site-packages/yaml/reader.py", line 79, in __init__
self.determine_encoding()
File "/usr/local/lib/python2.7/site-packages/yaml/reader.py", line 135, in determine_encoding
self.update(1)
File "/usr/local/lib/python2.7/site-packages/yaml/reader.py", line 169, in update
self.check_printable(data)
File "/usr/local/lib/python2.7/site-packages/yaml/reader.py", line 144, in check_printable
'unicode', "special characters are not allowed")
yaml.reader.ReaderError: unacceptable character #xd83d: special characters are not allowed
in "<string>", position 0
If there's some flag inside PyYAML that can be used to allow them, I think yamllint
should activate it to allow it to lint the widest possible range of yaml files.
The new yamllint 1.3.0 release raises an exception when scanning a file with a unicode comment:
UnicodeEncodeError: 'ascii' codec can't encode character u'\u20ac' in position 2: ordinal not in range(128)
The file tested contained:
# €
Hello, I'm using yamllint to check my YAML files validity on Travis CI, however the config I use is created using the "Default configuration" section of yamllint manpage from yamllint 1.2.1 from Ubuntu 16.04, which is considered "invalid config" on Travis CI which uses yamllint installed from PyPI.
$ yamllint *.yml .*.yml
invalid config: missing option "allow-non-breakable-inline-mappings" for rule "line-length"
The command "yamllint *.yml .*.yml" failed and exited with 255 during .
Please change the behavior so that missing option is not consider as error and fallback to a reasonable default, thanks!
I want to run yamllint without any "style" rules, breaking only on syntax errors. The shortest way I've found to do that is yamllint -d "{rules:{}}" file.yaml
which took me a few tries to get right and seems overly verbose.
It would be nice if an empty config file or -d ""
would work, or even if there was a command line option to disable all rules.
The console formatting stuff in the output should be excluded when on Windows. The output looks like this:
C:\Users\waylan\Desktop>yamllint sample.yml
←[4msample.yml←[0m
←[2m1:1←[0m ←[33mwarning←[0m missing document start "---" ←[2m(document-start)←[0m
←[2m4:9←[0m ←[31merror←[0m wrong indentation: expected 10 but found 8 ←[2m(indentation)←[0m
... which is pretty hard to read.
Of course the -f parsable
format works okay as a work-around, but that shouldn't be necessary.
C:\Users\waylan\Desktop>yamllint -f parsable sample.yml
sample.yml:1:1: [warning] missing document start "---" (document-start)
sample.yml:4:9: [error] wrong indentation: expected 10 but found 8 (indentation)
I have the following sample (indentation represented by the middle-dot for demonstration purposes only) which by my eye is indented in the only sensible way:
---
items:
····- Item 1: item-1
····- Item 2:
········- Item 2.1: item-2.1
········- Item 2.2: item-2.2
····- Item 3:
····- Item 3.1: item-3.1
········- Item 3.2:
············- Item 3.2.1: item-3.2.1
············- Item 3.2.2: item-3.2.2
Yes, I get the following output which makes no sense:
sample.yml
5:9: [error] wrong indentation: expected 10 but found 8 (indentation)
8:9: [error] wrong indentation: expected 10 but found 8 (indentation)
10:13: [error] wrong indentation: expected 14 but found 12 (indentation)
I've tried changing the indentation
rules in various ways but never seem to get a reasonable result. Setting indent-sequences
to any of true
, whatever
or consistent
all result in the same output (yes, even whatever
! What's up with that?!). Setting indent-sequences
to false
gives this:
sample.yml
3:5: [error] wrong indentation: expected 0 but found 4 (indentation)
5:9: [error] wrong indentation: expected 6 but found 8 (indentation)
8:9: [error] wrong indentation: expected 6 but found 8 (indentation)
10:13: [error] wrong indentation: expected 10 but found 12 (indentation)
... which still makes no sense. Actually, with indent-sequences: false
you need to keep making changes until none of the lines are indented at all. Therefore, the above output is rather misleading.
In either case, why would the suggested indent be anything but a divisible of the spaces
value (4
in this instance, although the same behavior presents itself with other values including consistent
).
Going back to the default
, you end up with this following to pass (again with indentation represented by the middle-dot for demonstration purposes):
---
items:
····- Item 1: item-1
····- Item 2:
··········- Item 2.1: item-2.1
··········- Item 2.2: item-2.2
····- Item 3:
··········- Item 3.1: item-3.1
··········- Item 3.2:
················- Item 3.2.1: item-3.2.1
················- Item 3.2.2: item-3.2.2
The first level of indent is 4
spaces, but all subsequent levels of indent are 6
spaces. I realize the documentation acknowledges that "some people perceive the -
as part of the indentation", but I don't see how that fits here. Especially as you can't actually override it, which is the rational given in the documentation for providing the overrides.
I don't really care about the rational, I just want to enforce consistent (4 spaces for each level) in my YAML files and the current set of options don't allow that. If the current behavior was intentional, then an additional option need sot be provided. If the current behavior is a bug, I'm willing to take a crack at a fix. So is this a bug or not?
Jenkins Job Builder supports custom tags for including external files; these tags all begin !include
. yamllint
(incorrectly?) reports an indentation error for source like this:
# /tmp/foobar.yaml
---
foo:
- foobar
- barbaz
---
!foo:
- foobar
- barbaz
$ yamllint /tmp/foobar.yaml
/tmp/foobar.yaml
8:3 error wrong indentation: expected 0 but found 2 (indentation)
yamllint
should treat these keys just like any other, as the YAML spec doesn't appear to exclude exclamation marks from key names - please correct me if I'm wrong there!
Is there an option to provide a default config file in my home directory?
Similar to rubocop's ~/.rubocop.yml�
pylint's ~/.pylintrc�
etc.
This YAML:
scale: !toto &tutu
default: "Massstab"
Leads to a weird error message:
./test.yaml
2:3 error wrong indentation: expected 7 but found 2 (indentation)
Upgrading from 1.7.0 to 1.8.0 and I have no idea what changed, which means I just have to yamllint all my files again and hope 😢 Can you add changelog/history file and keep track of what changes between releases? Thanks!
Hi!
Thanks a lot for this project. This is the best YAML linter I got so far. I specially like the Eslint output style!
I was wondering if it would be possible to support some extra rules, like quote
.
e.g: http://eslint.org/docs/rules/quotes
Indeed I would like to enforce single quote when necessary. May be this requirement would make no sense tho.
Cheers!
Hi,
I am having the folowing error syntax while it shouldn't yield anything!
Thanks,
Pierre.
Hi,
First of all, great project!
I want to use this project to lint Symfony routing files. Below is an example of such a file:
# app/config/routing.yml
blog_list:
path: /blog
defaults: { _controller: AppBundle:Blog:list }
blog_show:
path: /blog/{slug}
defaults: { _controller: AppBundle:Blog:show }
However, apparently the :
in the controller name is not considered as valid syntax. The output below is from the linter with default configuration on the snippet above:
test.yml
2:1 warning missing document start "---" (document-start)
3:15 error too many spaces after colon (colons)
4:15 error too many spaces after colon (colons)
4:17 error too many spaces inside braces (braces)
4:40 error syntax error: found unexpected ':'
A solution for the linter would be to place the value in "
's, but that breaks stuff in other parts.
Do you have any suggestion on how to fix this problem? I would really like to use this linter, but as long as it generates the syntax errors it is useless for my project...
Hi,
It would be great if yamllint
could lint YAML coming from standard input.
It would be helpful when creating editors' integration etc.
Cheers.
When using yamllint with default output format in eg a build script, the default colour output results in ugly data in the plain text log:
�[4m./global.yaml�[0m
�[2m1439:52�[0m �[31merror�[0m no new line character at the end of file �[2m(new-line-at-end-of-file)�[0m
You can work around this by setting -f parsable
but the format is less human readable. It would be nice to have a way to output standard format without colour. I'm not sure if that would best be a third -f
option, or a new --colour never
option (like grep) or a new --no-colour
option.
Hope this tool can format the code automatic, just like yapf -i
for Python.
Has the package been removed from the apt-get repos?
root@185cd0d5dccb:/# cat /etc/debian_version
8.8
root@185cd0d5dccb:/# apt-get -qq update && apt-get -qq install -y yamllint
E: Unable to locate package yamllint
Trying the "old version" approach also fails:
root@185cd0d5dccb:/# apt-get -qq install -y software-properties-common
root@185cd0d5dccb:/# add-apt-repository -y ppa:adrienverge/ppa
gpg: keyring `/tmp/tmp7819p0qh/secring.gpg' created
gpg: keyring `/tmp/tmp7819p0qh/pubring.gpg' created
gpg: requesting key 7EB83022 from hkp server keyserver.ubuntu.com
gpg: /tmp/tmp7819p0qh/trustdb.gpg: trustdb created
gpg: key 7EB83022: public key "Launchpad PPA for Adrien Verg�" imported
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
self.run()
File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 153, in run
self.add_ppa_signing_key(self.ppa_path)
File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 250, in add_ppa_signing_key
tmp_export_keyring, signing_key_fingerprint, tmp_keyring_dir):
File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 202, in _verify_fingerprint
got_fingerprints = self._get_fingerprints(keyring, keyring_dir)
File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 194, in _get_fingerprints
output = subprocess.check_output(cmd, universal_newlines=True)
File "/usr/lib/python3.4/subprocess.py", line 609, in check_output
output, unused_err = process.communicate(inputdata, timeout=timeout)
File "/usr/lib/python3.4/subprocess.py", line 947, in communicate
stdout = _eintr_retry_call(self.stdout.read)
File "/usr/lib/python3.4/subprocess.py", line 491, in _eintr_retry_call
return func(*args)
File "/usr/lib/python3.4/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 100: ordinal not in range(128)
sample.yml
:
pt-BR:
emails:
verification:
body: |
:plain
Oi #{contact.first_name},
This line should give an error #{variable_name}.
Clique no link abaixo para ativar sua conta.
Expected: error indentation expected 10 got 9
Instead: no error, running yamllint v1.8.1 on default configuration
Currently, using pre-commit, it only works using the master branch, because the last released version don't contain the right .pre-commit-hooks.yaml
file.
When doing an auto-update with pre-commit:
Updating https://github.com/adrienverge/yamllint.git...An error has occurred: InvalidManifestError:
=====> /home/fdhaussy/.cache/pre-commit/repoPsMzo4/.pre-commit-hooks.yaml does not exist
And it only works by setting master in our pre-commit files. Do you know when the next release, that will include the new pre-commit, will be out ?
Thanks !
clicking any bold rule heading on this page http://yamllint.readthedocs.io/en/latest/rules.html#id1
just sends you back to the rules list. The details for each rule are no longer visible. I tried with chrome and IExplorer.
it would be nice to also have an excluded path for eg:
given this directories:
|
| - yaml_files
| | - subdir1
| | - ....
| | - subdirN
| | - wanted_excuded_subdir
normally you should iterate on all N subdirs or creating a bash script filtering out the excluded dir(s).
so strictly cannot be run simple as yamllint yaml_files
but need to be expanded in something similar as cd yaml_files && yamllint subdir1 ... subdirN
or using gnu find
it would be a lot simpler have a sort of excluded path option eg:
yamllint --exclude-path yaml_files/wanted_excluded_subdir yam_files
or in short just matching a regExp in the path
yamllint --excluded-path wanted_excluded yam_files
A great feature for this project would be the ability to exclude certain files. This way, if you are adding yamllint to a project, you can ignore every file with issues until you get around to fixing them. Right now, the only way to achieve this is through comments on every file.
A good way to accomplish this is in the rules configuration:
rules:
indentation:
indent-sequences: false
spaces: 2
exclude:
- 'configs/config_yaml.yml'
A second add-on feature would be to allow these excludes to be auto-generated. This second feature helps make it easy to integrate yamllint into an existing codebase.
Right now our project has 11400 errors, so these features would make yamllint an idea yaml linter for our project, but as it stands, there is too much noise to lint new yamls as they come.
---
- a:
map:
key: true
- b:
map: false
I expect the snippet passed. But yamllint shows failure that "Wrong indentation: expected 6 but found 8 (indentation)" at line 4.
My yamllint configuration:
---
extends: default
rules:
indentation:
spaces: consistent
indent-sequences: whatever
check-multi-line-strings: true
Is there something wrong?
yamllint fails when using the following template
{{key}}: value
Traceback (most recent call last):
File "/usr/bin/yamllint", line 9, in <module>
load_entry_point('yamllint==1.2.0', 'console_scripts', 'yamllint')()
File "/usr/lib/python3/dist-packages/yamllint/cli.py", line 110, in run
for problem in linter.run(f, conf):
File "/usr/lib/python3/dist-packages/yamllint/linter.py", line 101, in _run
for problem in get_costemic_problems(buffer, conf):
File "/usr/lib/python3/dist-packages/yamllint/linter.py", line 72, in get_costemic_problems
context[rule.ID]):
File "/usr/lib/python3/dist-packages/yamllint/rules/indentation.py", line 434, in check
assert context['stack'][-1].type == KEY
AssertionError
I would expect to see maybe an error instead, so yamllint can continue with the remaining files
We are using yamllint on files that will be used as helm charts, where syntax such as
value: {{ .Values.service.name }}{{ if eq .Values.environment "staging" }} (staging){{ end }}
is completely valid. Ideally we would be able to skip this line from running yamllint, but since it is a syntax-error, and not an issue with a given rule, the disable-line functionality # yamllint disable-line
doesn't work.
Ideally disable-line would either skip syntax-errors as well as rules, or there could be a separate rule ignore-line
for this case.
I have some jinja2 that does simple templating of an otherwise-valid yaml file, so I'd like to yamllint the file in my automation workflow. I can't ignore the jinja2 lines though. Here are the two things I've tried.
{% if transport == 'tls' %}
# yamllint enable```
```# yamllint disable-line
{% if transport == 'tls' %}
And here's the error, even with the 'disable'.
17:2 error syntax error: found character '%' that cannot start any token
Is there a way to do this? Should there be?
A nice feature was to calculate a score after linting files. Maybe something like
1 - ((Amount of problems + 0.5 * Amount of warnings) / amount of lines)
.
Then you can create badges for repositories containing many yaml files (e.g. ansible repos) and rate merge requests (like code coverage).
The exception happened in an Ansible YAML file, but I managed to reproduce it with the following simplified case.
- test:
- test: test
block:
- name: test
content: |
{% this line is really really really really really really really long %}
$ yamllint --version
yamllint 1.4.0
$ yamllint test.yml
test.yml
1:1 warning missing document start "---" (document-start)
6:81 error line too long (84 > 80 characters) (line-length)
$ yamllint -d relaxed test.yml
Traceback (most recent call last):
File "/home/danielkza/cobli/herbie/deploy/venv/bin/yamllint", line 11, in <module>
sys.exit(run())
File "/home/danielkza/cobli/herbie/deploy/venv/lib/python2.7/site-packages/yamllint/cli.py", line 130, in run
for problem in linter.run(f, conf):
File "/home/danielkza/cobli/herbie/deploy/venv/lib/python2.7/site-packages/yamllint/linter.py", line 186, in _run
for problem in get_costemic_problems(buffer, conf):
File "/home/danielkza/cobli/herbie/deploy/venv/lib/python2.7/site-packages/yamllint/linter.py", line 150, in get_costemic_problems
for problem in rule.check(rule_conf, elem):
File "/home/danielkza/cobli/herbie/deploy/venv/lib/python2.7/site-packages/yamllint/rules/line_length.py", line 132, in check
check_inline_mapping(line)):
File "/home/danielkza/cobli/herbie/deploy/venv/lib/python2.7/site-packages/yamllint/rules/line_length.py", line 105, in check_inline_mapping
while loader.peek_token():
File "/home/danielkza/cobli/herbie/deploy/venv/lib/python2.7/site-packages/yaml/scanner.py", line 128, in peek_token
self.fetch_more_tokens()
File "/home/danielkza/cobli/herbie/deploy/venv/lib/python2.7/site-packages/yaml/scanner.py", line 257, in fetch_more_tokens
% ch.encode('utf-8'), self.get_mark())
yaml.scanner.ScannerError: while scanning for the next token
found character '%' that cannot start any token
in "<string>", line 1, column 14:
{% this line is really really rea ...
Now that yamllint
requires pathspec
as of version 1.8.0, it no longer works on python 2.6.
Here's the failure from pip install yamllint
on python 2.6:
Collecting pathspec (from yamllint)
Downloading pathspec-0.5.2.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/ly/g7l5bx455cq2c_r6z1ky8j1m0000gn/T/pip-build-y3oUIf/pathspec/setup.py", line 6, in <module>
from pathspec import __author__, __email__, __license__, __project__, __version__
File "pathspec/__init__.py", line 33, in <module>
from .pathspec import PathSpec
File "pathspec/pathspec.py", line 9, in <module>
from . import util
File "pathspec/util.py", line 167
return {normalize_file(path, separators=separators): path for path in files}
^
SyntaxError: invalid syntax
YAML files such as configuration for travis have nested settings requiring indentation. yamllint currently doesn't know about any such scenarios.
Steps to reproduce
---
language: ruby
rvm:
- 2.2.5
install: gem install jekyll
script: jekyll build
env:
global:
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true
sudo: false
yamllint abc.yml
yamllint abc.yml
abc.yml
11:3 error wrong indentation: expected 0 but found 2 (indentation)
But as we can see global
is a setting for env
, and it should be indented.
we can also see that yamllint does mix up nested blocks with the indentation style with -
. As we look in the above configuration, the - xxx
items needs all indentation to pass the check.Any thoughts about this behaviour?
For more info follow coala/coala-bears#1252.
Additional Info
yamllint version 1.6.0
Hi,
lintian complains about some aspects of the manpage, see here:
https://lintian.debian.org/sources/yamllint/1.24.2-1.html
jsonlint has a feature to check against an existing schema file through the following cli options:
-V, --validate a JSON schema to use for validation
-e, --environment which specification of JSON Schema the validation file uses [json-schema-draft-03]
It would be great if yamllint also could provide such feature.
apt-cache policy yamllint
yamllint:
Installed: (none)
Candidate: 1.2.1-1
Version table:
1.2.1-1 500
500 http://archive.ubuntu.com/ubuntu xenial/universe amd64 Packages
It seems to be why ignore
option was not working for me. Please update to 1.8.1 (or provide ppa?)
Hi,
I started using yamllint recently for a project. I would like my yaml files fo follow the Symfony coding conventions. Unfortunately, it's not possible to do, as some indentations options are not available. Especially being able to allow/require this kind of indentation:
k_phoen_contact:
redirect_url: contact
sender: { address: '[email protected]' }
receiver: { address: [email protected] }
So, I'd like to ask you if you could add this feature. :)
I downloaded the source tarball found on pypi and ran nosetests on it, it failed because of a missing file.
$ nosetests
...............................................................................................................................E.....
======================================================================
ERROR: Failure: OSError ([Errno 2] No such file or directory: 'tests/yaml-1.2-spec-examples')
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/nose/loader.py", line 418, in loadTestsFromName
addr.filename, addr.module)
File "/usr/lib/python2.7/site-packages/nose/importer.py", line 47, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/usr/lib/python2.7/site-packages/nose/importer.py", line 94, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/home/admiller/rpmbuild/SOURCES/yamllint-0.7.2/tests/test_spec_examples.py", line 123, in <module>
files = os.listdir('tests/yaml-1.2-spec-examples')
OSError: [Errno 2] No such file or directory: 'tests/yaml-1.2-spec-examples'
----------------------------------------------------------------------
Ran 133 tests in 4.745s
FAILED (errors=1)
Like many other tools like pep8, flake8, tox,... this one should also be able to look for the existence of a config file and load it if no other config file is specified from the command line.
I supposed that .yamllint.yaml
should be a good name.
Hi,
I already used yamllint
on my computer and it worked just fine. Today, I tried to used it as part of the CI for a project and get stuck with this error:
$ yamllint app/ bin/ ci/ scripts/ src/ var/ web/ .gitlab-ci.yml .yamllint
Traceback (most recent call last):
File "/usr/bin/yamllint", line 9, in <module>
load_entry_point('yamllint==1.3.2', 'console_scripts', 'yamllint')()
File "/usr/lib/python3/dist-packages/yamllint/cli.py", line 119, in run
for problem in linter.run(f, conf):
File "/usr/lib/python3/dist-packages/yamllint/linter.py", line 220, in run
content = input.read()
File "/usr/lib/python3.5/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 3982: ordinal not in range(128)
ERROR: Build failed: exit code 1
See the complete build for details.
I found a similar bug here and the commit which solved it upstream.
So, I don't know if I'm missing something in my build or if yamllint
needs to be fixed, thus, I'm opening this issue hoping you'll know what's going wrong here.
Thanks. :)
Version: yamllint 1.8.1
Behavior observed: Following the examples in documentation to disable certain checks via in-line comments, however the rules are not being disabled. The target file is a Jinja2 template.
I added "# yamllint disable" and "# yamllint enable" around a block of Jinja directives, and a more specific "# yamllint disable rule:line-length" rule. However these rules appear not to be disabled, as evidenced by the following output from yamllint:
$ yamllint gluster.jinja
gluster.jinja
16:2 error syntax error: found character '%' that cannot start any token
37:81 error line too long (83 > 80 characters) (line-length)
73:81 error line too long (139 > 80 characters) (line-length)
81:81 error line too long (141 > 80 characters) (line-length)
88:81 error line too long (106 > 80 characters) (line-length)
101:81 error line too long (100 > 80 characters) (line-length)
112:81 error line too long (94 > 80 characters) (line-length)
122:81 error line too long (116 > 80 characters) (line-length)
123:81 error line too long (93 > 80 characters) (line-length)
131:81 error line too long (151 > 80 characters) (line-length)
135:81 error line too long (91 > 80 characters) (line-length)
136:81 error line too long (94 > 80 characters) (line-length)
141:81 error line too long (92 > 80 characters) (line-length)
snippets from gluster.jinja:
<...>
# yamllint disable
{% set zones = properties["zones"] %}
{% set num_nodes = properties["nodes"] %}
<...>
# yamllint enable
# yamllint disable rule:line-length
resources:
- name: {{ startup_cfg }}
type: runtimeconfig.v1beta1.config
properties:
config: {{ startup_cfg }}
description: "Runtime resources for coordination of GlusterFS cluster creation"
<...>
Hi, I'm running this as a batch process. To keep the output simple, it would be ideal if there was a flag to suppress showing the filename unless there are any warnings/errors. (This also means there would be no output if there are no errors.)
Hi,
I think I may find yamllint
useful, but I'm trying to understand which rules does it use to validate the files. Spec? I ask, since I've made myself a mini-lint version in Ruby and run it on my sample files:
wget https://raw.githubusercontent.com/wkoszek/me/master/scripts/yamllint.rb
wget https://raw.githubusercontent.com/wkoszek/me/master/source/blog/2016-06-27-what-docker-really-is.md
chmod 755 yamllint.rb
./yamllint.rb 2016-06-27-what-docker-really-is.md
So my understanding is that the static code generator files (YAML frontmatter + text) are a correct files YAML-wise: 1st document in an .md
file is 1 YAML document, and whatever is after ---
is a 2nd document. Command from above seems to work indicating the file is correct enough for YAML
module in Ruby. If you uncomment the pp
part of the script, you'll see that the front matter is loaded. Content isn't (which is OK for now), but might be loaded if I modify the script a bit: http://stackoverflow.com/questions/19325251/ruby-yaml-multiple-documents
Anyway: yamllint
is more picky however with this file:
yamllint 2016-06-27-what-docker-really-is.md
2016-06-27-what-docker-really-is.md
27:1 error syntax error: expected '<document start>', but found '<scalar>'
I'm trying to understand what's wrong with this line, since it seems valid too me and pointing somewhere in the middle of my content.
Any ideas?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.