Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop support for EOL Python 2.6 #149

Merged
merged 6 commits into from
Nov 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@
---
language: python
python:
- 2.6
- 2.7
- 3.4
- 3.5
- 3.6
- nightly
install:
- pip install pyyaml flake8 flake8-import-order
- if [[ $TRAVIS_PYTHON_VERSION == 2.6 ]]; then pip install unittest2; fi
- if [[ $TRAVIS_PYTHON_VERSION != 2.6 ]]; then pip install coveralls; fi
- pip install pyyaml coveralls flake8 flake8-import-order
- if [[ $TRAVIS_PYTHON_VERSION != 2* ]]; then pip install sphinx; fi
- pip install .
script:
- if [[ $TRAVIS_PYTHON_VERSION != 2.6 ]]; then flake8 .; fi
- flake8 .
- yamllint --strict $(git ls-files '*.yaml' '*.yml')
- if [[ $TRAVIS_PYTHON_VERSION != 2.6 ]]; then
coverage run --source=yamllint setup.py test;
else
python setup.py test;
fi
- coverage run --source=yamllint setup.py test
- if [[ $TRAVIS_PYTHON_VERSION != 2* ]]; then
python setup.py build_sphinx;
fi
Expand Down
6 changes: 6 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,19 @@
license=__license__,
keywords=['yaml', 'lint', 'linter', 'syntax', 'checker'],
url='https://github.com/adrienverge/yamllint',
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Console',
'Intended Audience :: Developers',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Topic :: Software Development',
'Topic :: Software Development :: Debuggers',
'Topic :: Software Development :: Quality Assurance',
Expand Down
7 changes: 1 addition & 6 deletions tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@

import os
import tempfile
import sys
try:
assert sys.version_info >= (2, 7)
import unittest
except AssertionError:
import unittest2 as unittest
import unittest

import yaml

Expand Down
4 changes: 2 additions & 2 deletions tests/rules/test_indentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def full_stack(self, source):
.replace('Mapping', 'Map'))
if token_type in ('StreamStart', 'StreamEnd'):
continue
output += '%9s %s\n' % (token_type,
self.format_stack(context['stack']))
output += '{:>9} {}\n'.format(token_type,
self.format_stack(context['stack']))
return output

def test_simple_mapping(self):
Expand Down
6 changes: 1 addition & 5 deletions tests/rules/test_line_length.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import sys
try:
assert sys.version_info >= (2, 7)
import unittest
except AssertionError:
import unittest2 as unittest
import unittest

from tests.common import RuleTestCase

Expand Down
7 changes: 1 addition & 6 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,13 @@
import pty
import shutil
import sys
try:
assert sys.version_info >= (2, 7)
import unittest
except AssertionError:
import unittest2 as unittest
import unittest

from tests.common import build_temp_workspace

from yamllint import cli


@unittest.skipIf(sys.version_info < (2, 7), 'Python 2.6 not supported')
class CommandLineTestCase(unittest.TestCase):
@classmethod
def setUpClass(cls):
Expand Down
17 changes: 6 additions & 11 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@
import os
import shutil
import sys
try:
assert sys.version_info >= (2, 7)
import unittest
except AssertionError:
import unittest2 as unittest
import unittest

from tests.common import build_temp_workspace

Expand Down Expand Up @@ -82,7 +78,7 @@ def test_yes_no_for_booleans(self):
' spaces: 2\n'
' indent-sequences: true\n'
' check-multi-line-strings: false\n')
self.assertEqual(c.rules['indentation']['indent-sequences'], True)
self.assertTrue(c.rules['indentation']['indent-sequences'])
self.assertEqual(c.rules['indentation']['check-multi-line-strings'],
False)

Expand All @@ -91,7 +87,7 @@ def test_yes_no_for_booleans(self):
' spaces: 2\n'
' indent-sequences: yes\n'
' check-multi-line-strings: false\n')
self.assertEqual(c.rules['indentation']['indent-sequences'], True)
self.assertTrue(c.rules['indentation']['indent-sequences'])
self.assertEqual(c.rules['indentation']['check-multi-line-strings'],
False)

Expand Down Expand Up @@ -119,8 +115,8 @@ def test_validate_rule_conf(self):
class Rule(object):
ID = 'fake'

self.assertEqual(config.validate_rule_conf(Rule, False), False)
self.assertEqual(config.validate_rule_conf(Rule, 'disable'), False)
self.assertFalse(config.validate_rule_conf(Rule, False))
self.assertFalse(config.validate_rule_conf(Rule, 'disable'))

self.assertEqual(config.validate_rule_conf(Rule, {}),
{'level': 'error'})
Expand Down Expand Up @@ -198,7 +194,7 @@ def test_extend_remove_rule(self):
new.extend(old)

self.assertEqual(sorted(new.rules.keys()), ['colons', 'hyphens'])
self.assertEqual(new.rules['colons'], False)
self.assertFalse(new.rules['colons'])
self.assertEqual(new.rules['hyphens']['max-spaces-after'], 2)

self.assertEqual(len(new.enabled_rules(None)), 1)
Expand Down Expand Up @@ -338,7 +334,6 @@ def tearDownClass(cls):

shutil.rmtree(cls.wd)

@unittest.skipIf(sys.version_info < (2, 7), 'Python 2.6 not supported')
def test_run_with_ignored_path(self):
sys.stdout = StringIO()
with self.assertRaises(SystemExit):
Expand Down
7 changes: 1 addition & 6 deletions tests/test_linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import io
import sys
try:
assert sys.version_info >= (2, 7)
import unittest
except AssertionError:
import unittest2 as unittest
import unittest

from yamllint.config import YamlLintConfig
from yamllint import linter
Expand Down
7 changes: 1 addition & 6 deletions tests/test_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,12 @@
import subprocess
import tempfile
import sys
try:
assert sys.version_info >= (2, 7)
import unittest
except AssertionError:
import unittest2 as unittest
import unittest


PYTHON = sys.executable or 'python'


@unittest.skipIf(sys.version_info < (2, 7), 'Python 2.6 not supported')
class ModuleTestCase(unittest.TestCase):
def setUp(self):
self.wd = tempfile.mkdtemp(prefix='yamllint-tests-')
Expand Down
11 changes: 3 additions & 8 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@
# 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 sys
try:
assert sys.version_info >= (2, 7)
import unittest
except AssertionError:
import unittest2 as unittest
import unittest

import yaml

Expand Down Expand Up @@ -70,12 +65,12 @@ def test_line_generator(self):
def test_token_or_comment_generator(self):
e = list(token_or_comment_generator(''))
self.assertEqual(len(e), 2)
self.assertEqual(e[0].prev, None)
self.assertIsNone(e[0].prev)
self.assertIsInstance(e[0].curr, yaml.Token)
self.assertIsInstance(e[0].next, yaml.Token)
self.assertEqual(e[1].prev, e[0].curr)
self.assertEqual(e[1].curr, e[0].next)
self.assertEqual(e[1].next, None)
self.assertIsNone(e[1].next)

e = list(token_or_comment_generator('---\n'
'k: v\n'))
Expand Down
74 changes: 37 additions & 37 deletions tests/test_spec_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,74 +54,74 @@ class SpecificationTestCase(RuleTestCase):
'braces: {min-spaces-inside: 1, max-spaces-inside: 1}\n'
'brackets: {min-spaces-inside: 1, max-spaces-inside: 1}\n')
conf_overrides = {
'example-2.2': ('colons: {max-spaces-after: 2}\n'),
'example-2.4': ('colons: {max-spaces-after: 3}\n'),
'example-2.2': 'colons: {max-spaces-after: 2}\n',
'example-2.4': 'colons: {max-spaces-after: 3}\n',
'example-2.5': ('empty-lines: {max-end: 2}\n'
'brackets: {min-spaces-inside: 0, max-spaces-inside: 2}\n'
'commas: {max-spaces-before: -1}\n'),
'example-2.6': ('braces: {min-spaces-inside: 0, max-spaces-inside: 0}\n'
'indentation: disable\n'),
'example-2.12': ('empty-lines: {max-end: 1}\n'
'colons: {max-spaces-before: -1}\n'),
'example-2.16': ('empty-lines: {max-end: 1}\n'),
'example-2.18': ('empty-lines: {max-end: 1}\n'),
'example-2.19': ('empty-lines: {max-end: 1}\n'),
'example-2.28': ('empty-lines: {max-end: 3}\n'),
'example-2.16': 'empty-lines: {max-end: 1}\n',
'example-2.18': 'empty-lines: {max-end: 1}\n',
'example-2.19': 'empty-lines: {max-end: 1}\n',
'example-2.28': 'empty-lines: {max-end: 3}\n',
'example-5.3': ('indentation: {indent-sequences: false}\n'
'colons: {max-spaces-before: 1}\n'),
'example-6.4': ('trailing-spaces: disable\n'),
'example-6.5': ('trailing-spaces: disable\n'),
'example-6.6': ('trailing-spaces: disable\n'),
'example-6.7': ('trailing-spaces: disable\n'),
'example-6.8': ('trailing-spaces: disable\n'),
'example-6.4': 'trailing-spaces: disable\n',
'example-6.5': 'trailing-spaces: disable\n',
'example-6.6': 'trailing-spaces: disable\n',
'example-6.7': 'trailing-spaces: disable\n',
'example-6.8': 'trailing-spaces: disable\n',
'example-6.10': ('empty-lines: {max-end: 2}\n'
'trailing-spaces: disable\n'
'comments-indentation: disable\n'),
'example-6.11': ('empty-lines: {max-end: 1}\n'
'comments-indentation: disable\n'),
'example-6.13': ('comments-indentation: disable\n'),
'example-6.14': ('comments-indentation: disable\n'),
'example-6.23': ('colons: {max-spaces-before: 1}\n'),
'example-6.13': 'comments-indentation: disable\n',
'example-6.14': 'comments-indentation: disable\n',
'example-6.23': 'colons: {max-spaces-before: 1}\n',
'example-7.4': ('colons: {max-spaces-before: 1}\n'
'indentation: disable\n'),
'example-7.5': ('trailing-spaces: disable\n'),
'example-7.6': ('trailing-spaces: disable\n'),
'example-7.7': ('indentation: disable\n'),
'example-7.5': 'trailing-spaces: disable\n',
'example-7.6': 'trailing-spaces: disable\n',
'example-7.7': 'indentation: disable\n',
'example-7.8': ('colons: {max-spaces-before: 1}\n'
'indentation: disable\n'),
'example-7.9': ('trailing-spaces: disable\n'),
'example-7.9': 'trailing-spaces: disable\n',
'example-7.11': ('colons: {max-spaces-before: 1}\n'
'indentation: disable\n'),
'example-7.13': ('brackets: {min-spaces-inside: 0, max-spaces-inside: 1}\n'
'commas: {max-spaces-before: 1, min-spaces-after: 0}\n'),
'example-7.14': ('indentation: disable\n'),
'example-7.14': 'indentation: disable\n',
'example-7.15': ('braces: {min-spaces-inside: 0, max-spaces-inside: 1}\n'
'commas: {max-spaces-before: 1, min-spaces-after: 0}\n'
'colons: {max-spaces-before: 1}\n'),
'example-7.16': ('indentation: disable\n'),
'example-7.17': ('indentation: disable\n'),
'example-7.18': ('indentation: disable\n'),
'example-7.19': ('indentation: disable\n'),
'example-7.16': 'indentation: disable\n',
'example-7.17': 'indentation: disable\n',
'example-7.18': 'indentation: disable\n',
'example-7.19': 'indentation: disable\n',
'example-7.20': ('colons: {max-spaces-before: 1}\n'
'indentation: disable\n'),
'example-8.1': ('empty-lines: {max-end: 1}\n'),
'example-8.2': ('trailing-spaces: disable\n'),
'example-8.1': 'empty-lines: {max-end: 1}\n',
'example-8.2': 'trailing-spaces: disable\n',
'example-8.5': ('comments-indentation: disable\n'
'trailing-spaces: disable\n'),
'example-8.6': ('empty-lines: {max-end: 1}\n'),
'example-8.7': ('empty-lines: {max-end: 1}\n'),
'example-8.8': ('trailing-spaces: disable\n'),
'example-8.9': ('empty-lines: {max-end: 1}\n'),
'example-8.14': ('colons: {max-spaces-before: 1}\n'),
'example-8.16': ('indentation: {spaces: 1}\n'),
'example-8.17': ('indentation: disable\n'),
'example-8.6': 'empty-lines: {max-end: 1}\n',
'example-8.7': 'empty-lines: {max-end: 1}\n',
'example-8.8': 'trailing-spaces: disable\n',
'example-8.9': 'empty-lines: {max-end: 1}\n',
'example-8.14': 'colons: {max-spaces-before: 1}\n',
'example-8.16': 'indentation: {spaces: 1}\n',
'example-8.17': 'indentation: disable\n',
'example-8.20': ('indentation: {indent-sequences: false}\n'
'colons: {max-spaces-before: 1}\n'),
'example-8.22': ('indentation: disable\n'),
'example-10.1': ('colons: {max-spaces-before: 2}\n'),
'example-10.2': ('indentation: {indent-sequences: false}\n'),
'example-10.8': ('truthy: disable\n'),
'example-10.9': ('truthy: disable\n'),
'example-8.22': 'indentation: disable\n',
'example-10.1': 'colons: {max-spaces-before: 2}\n',
'example-10.2': 'indentation: {indent-sequences: false}\n',
'example-10.8': 'truthy: disable\n',
'example-10.9': 'truthy: disable\n',
}

files = os.listdir(os.path.join(os.path.dirname(os.path.realpath(__file__)),
Expand Down
2 changes: 1 addition & 1 deletion yamllint/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def run(argv=None):
help='return non-zero exit code on warnings '
'as well as errors')
parser.add_argument('-v', '--version', action='version',
version='%s %s' % (APP_NAME, APP_VERSION))
version='{} {}'.format(APP_NAME, APP_VERSION))

# TODO: read from stdin when no filename?

Expand Down
6 changes: 3 additions & 3 deletions yamllint/linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(self, line, column, desc='<no description>', rule=None):
@property
def message(self):
if self.rule is not None:
return '%s (%s)' % (self.desc, self.rule)
return '{} ({})'.format(self.desc, self.rule)
return self.desc

def __eq__(self, other):
Expand Down Expand Up @@ -75,10 +75,10 @@ def get_cosmetic_problems(buffer, conf, filepath):
for rule in token_rules:
context[rule.ID] = {}

class DisableDirective():
class DisableDirective:
def __init__(self):
self.rules = set()
self.all_rules = set([r.ID for r in rules])
self.all_rules = {r.ID for r in rules}

def process_comment(self, comment):
try:
Expand Down