Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
adefe38a0d | ||
|
|
7e11082353 | ||
|
|
29c1c60143 | ||
|
|
b879e9a98f | ||
|
|
5956b20545 | ||
|
|
10ad302e2f | ||
|
|
73d9322813 | ||
|
|
ca0ebe4583 | ||
|
|
e6dc67fd0a | ||
|
|
611a560082 | ||
|
|
83384fa4cf | ||
|
|
3ab3784a75 | ||
|
|
2f75e92a66 | ||
|
|
64caa95b6a | ||
|
|
fff09fa2df |
3
MANIFEST.in
Normal file
3
MANIFEST.in
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
include LICENSE
|
||||||
|
include README.rst
|
||||||
|
include docs/*
|
||||||
16
README.rst
16
README.rst
@@ -64,3 +64,19 @@ Usage
|
|||||||
|
|
||||||
# Output a parsable format (for syntax checking in editors like Vim, emacs...)
|
# Output a parsable format (for syntax checking in editors like Vim, emacs...)
|
||||||
yamllint -f parsable file.yml
|
yamllint -f parsable file.yml
|
||||||
|
|
||||||
|
Configuration example
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
.. code:: yaml
|
||||||
|
|
||||||
|
extends: default
|
||||||
|
|
||||||
|
rules:
|
||||||
|
# 80 chars should be enough, but don't fail if a line is longer
|
||||||
|
line-length:
|
||||||
|
max: 80
|
||||||
|
level: warning
|
||||||
|
|
||||||
|
# don't bother me with this rule
|
||||||
|
indentation: disable
|
||||||
|
|||||||
@@ -38,6 +38,5 @@ htmlhelp_basename = 'yamllintdoc'
|
|||||||
# One entry per manual page. List of tuples
|
# One entry per manual page. List of tuples
|
||||||
# (source start file, name, description, authors, manual section).
|
# (source start file, name, description, authors, manual section).
|
||||||
man_pages = [
|
man_pages = [
|
||||||
('index', 'yamllint', u'yamllint Documentation',
|
('index', 'yamllint', '', [u'Adrien Vergé'], 1)
|
||||||
[u'Adrien Vergé'], 1)
|
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ strict on block sequences indentation:
|
|||||||
extends: default
|
extends: default
|
||||||
|
|
||||||
rules:
|
rules:
|
||||||
# 80 should be enough, but don't fail if a line is longer
|
# 80 chars should be enough, but don't fail if a line is longer
|
||||||
line-length:
|
line-length:
|
||||||
max: 80
|
max: 80
|
||||||
level: warning
|
level: warning
|
||||||
|
|||||||
5
setup.py
5
setup.py
@@ -30,7 +30,7 @@ setup(
|
|||||||
keywords=['yaml', 'lint', 'linter', 'syntax', 'checker'],
|
keywords=['yaml', 'lint', 'linter', 'syntax', 'checker'],
|
||||||
url='https://github.com/adrienverge/yamllint',
|
url='https://github.com/adrienverge/yamllint',
|
||||||
classifiers=[
|
classifiers=[
|
||||||
'Development Status :: 4 - Beta',
|
'Development Status :: 5 - Production/Stable',
|
||||||
'Environment :: Console',
|
'Environment :: Console',
|
||||||
'Intended Audience :: Developers',
|
'Intended Audience :: Developers',
|
||||||
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
|
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
|
||||||
@@ -44,7 +44,8 @@ setup(
|
|||||||
|
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
entry_points={'console_scripts': ['yamllint=yamllint.cli:run']},
|
entry_points={'console_scripts': ['yamllint=yamllint.cli:run']},
|
||||||
package_data={'yamllint': ['conf/*.yml']},
|
package_data={'yamllint': ['conf/*.yml'],
|
||||||
|
'tests': ['yaml-1.2-spec-examples/*']},
|
||||||
install_requires=['pyyaml'],
|
install_requires=['pyyaml'],
|
||||||
tests_require=['nose'],
|
tests_require=['nose'],
|
||||||
test_suite='nose.collector',
|
test_suite='nose.collector',
|
||||||
|
|||||||
46
tests/test_linter.py
Normal file
46
tests/test_linter.py
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (C) 2016 Adrien Vergé
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import io
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from yamllint.config import YamlLintConfig
|
||||||
|
from yamllint import linter
|
||||||
|
|
||||||
|
|
||||||
|
class LinterTestCase(unittest.TestCase):
|
||||||
|
def fake_config(self):
|
||||||
|
return YamlLintConfig('extends: default')
|
||||||
|
|
||||||
|
def test_run_on_string(self):
|
||||||
|
linter.run('test: document', self.fake_config())
|
||||||
|
|
||||||
|
def test_run_on_bytes(self):
|
||||||
|
linter.run(b'test: document', self.fake_config())
|
||||||
|
|
||||||
|
def test_run_on_unicode(self):
|
||||||
|
linter.run(u'test: document', self.fake_config())
|
||||||
|
|
||||||
|
def test_run_on_stream(self):
|
||||||
|
linter.run(io.StringIO(u'hello'), self.fake_config())
|
||||||
|
|
||||||
|
def test_run_on_int(self):
|
||||||
|
self.assertRaises(TypeError, linter.run, 42, self.fake_config())
|
||||||
|
|
||||||
|
def test_run_on_list(self):
|
||||||
|
self.assertRaises(TypeError, linter.run,
|
||||||
|
['h', 'e', 'l', 'l', 'o'], self.fake_config())
|
||||||
@@ -14,6 +14,7 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from io import open
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from tests.common import RuleTestCase
|
from tests.common import RuleTestCase
|
||||||
@@ -120,7 +121,8 @@ conf_overrides = {
|
|||||||
'example-10.2': ('indentation: {indent-sequences: no}\n'),
|
'example-10.2': ('indentation: {indent-sequences: no}\n'),
|
||||||
}
|
}
|
||||||
|
|
||||||
files = os.listdir('tests/yaml-1.2-spec-examples')
|
files = os.listdir(os.path.join(os.path.dirname(os.path.realpath(__file__)),
|
||||||
|
'yaml-1.2-spec-examples'))
|
||||||
assert len(files) == 132
|
assert len(files) == 132
|
||||||
|
|
||||||
|
|
||||||
@@ -178,7 +180,7 @@ for file in files:
|
|||||||
if file in pyyaml_blacklist:
|
if file in pyyaml_blacklist:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
with open('tests/yaml-1.2-spec-examples/' + file) as f:
|
with open('tests/yaml-1.2-spec-examples/' + file, encoding='utf-8') as f:
|
||||||
conf = conf_general + conf_overrides.get(file, '')
|
conf = conf_general + conf_overrides.get(file, '')
|
||||||
setattr(SpecificationTestCase, 'test_' + file,
|
setattr(SpecificationTestCase, 'test_' + file,
|
||||||
_gen_test(f.read(), conf))
|
_gen_test(f.read(), conf))
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ indentation, etc."""
|
|||||||
|
|
||||||
|
|
||||||
APP_NAME = 'yamllint'
|
APP_NAME = 'yamllint'
|
||||||
APP_VERSION = '0.7.2'
|
APP_VERSION = '1.0.4'
|
||||||
APP_DESCRIPTION = __doc__
|
APP_DESCRIPTION = __doc__
|
||||||
|
|
||||||
__author__ = u'Adrien Vergé'
|
__author__ = u'Adrien Vergé'
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (C) 2016 Adrien Vergé
|
# Copyright (C) 2016 Adrien Vergé
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ def run(input, conf):
|
|||||||
:param input: buffer, string or stream to read from
|
:param input: buffer, string or stream to read from
|
||||||
:param conf: yamllint configuration object
|
:param conf: yamllint configuration object
|
||||||
"""
|
"""
|
||||||
if type(input) == str:
|
if type(input) in (type(b''), type(u'')): # compat with Python 2 & 3
|
||||||
return _run(input, conf)
|
return _run(input, conf)
|
||||||
elif hasattr(input, 'read'): # Python 2's file or Python 3's io.IOBase
|
elif hasattr(input, 'read'): # Python 2's file or Python 3's io.IOBase
|
||||||
# We need to have everything in memory to parse correctly
|
# We need to have everything in memory to parse correctly
|
||||||
|
|||||||
Reference in New Issue
Block a user