Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

Drop support for Python 2.6. #217

Merged
merged 3 commits into from
Oct 14, 2016
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
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ install: pip install tox
script: tox
matrix:
include:
- python: 2.6
env: TOXENV=py26
- python: 2.7
env: TOXENV=py27
- python: 3.3
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ docstring conventions.
`PEP 257 <http://www.python.org/dev/peps/pep-0257/>`_ out of the box, but it
should not be considered a reference implementation.

**pydocstyle** supports Python 2.6, 2.7, 3.3, 3.4, 3.5, pypy and pypy3.
**pydocstyle** supports Python 2.7, 3.3, 3.4, 3.5, pypy and pypy3.

Quick Start
-----------
Expand Down
4 changes: 2 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
pydocstyle's documentation
==========================

(formerly pep257)

**pydocstyle** is a static analysis tool for checking compliance with Python
docstring conventions.

**pydocstyle** supports most of
`PEP 257 <http://www.python.org/dev/peps/pep-0257/>`_ out of the box, but it
should not be considered a reference implementation.

**pydocstyle** supports Python 2.7, 3.3, 3.4, 3.5, pypy and pypy3.


.. include:: quickstart.rst

Expand Down
7 changes: 7 additions & 0 deletions docs/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ Release Notes
**pydocstyle** version numbers follow the
`Semantic Versioning <http://semver.org/>`_ specification.

Current Development Version
---------------------------

Major Updates

* Support for Python 2.6 has been dropped (#206, #217).

1.1.1 - October 4th, 2016
-------------------------

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.1.2rc
current_version = 2.0.0rc
commit = True
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)((?P<release>.*))?
serialize =
Expand Down
16 changes: 8 additions & 8 deletions src/pydocstyle/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def _read_configuration_file(self, path):
continue

if opt.replace('_', '-') not in self.CONFIG_FILE_OPTIONS:
log.warning("Unknown option '{0}' ignored".format(opt))
log.warning("Unknown option '{}' ignored".format(opt))
continue

normalized_opt = opt.replace('-', '_')
Expand All @@ -279,7 +279,7 @@ def _read_configuration_file(self, path):

if options is not None:
if not self._validate_options(options):
raise IllegalConfiguration('in file: {0}'.format(path))
raise IllegalConfiguration('in file: {}'.format(path))

return options, should_inherit

Expand Down Expand Up @@ -413,12 +413,12 @@ def _validate_options(cls, options):
for opt1, opt2 in \
itertools.permutations(cls.BASE_ERROR_SELECTION_OPTIONS, 2):
if getattr(options, opt1) and getattr(options, opt2):
log.error('Cannot pass both {0} and {1}. They are '
log.error('Cannot pass both {} and {}. They are '
'mutually exclusive.'.format(opt1, opt2))
return False

if options.convention and options.convention not in conventions:
log.error("Illegal convention '{0}'. Possible conventions: {1}"
log.error("Illegal convention '{}'. Possible conventions: {}"
.format(options.convention,
', '.join(conventions.keys())))
return False
Expand All @@ -442,7 +442,7 @@ def _get_set(value_str):
Removes any occurrences of '' in the set.

"""
return set(value_str.split(',')) - set([''])
return set(value_str.split(',')) - {''}

for opt in optional_set_options:
value = getattr(options, opt)
Expand Down Expand Up @@ -497,7 +497,7 @@ def _create_option_parser(cls):
'for example: --ignore=D101,D202')
option('--convention', metavar='<name>', default=None,
help='choose the basic list of checked errors by specifying an '
'existing convention. Possible conventions: {0}'
'existing convention. Possible conventions: {}'
.format(', '.join(conventions)))
option('--add-select', metavar='<codes>', default=None,
help='amend the list of errors to check for by specifying '
Expand All @@ -509,12 +509,12 @@ def _create_option_parser(cls):
# Match clauses
option('--match', metavar='<pattern>', default=None,
help=("check only files that exactly match <pattern> regular "
"expression; default is --match='{0}' which matches "
"expression; default is --match='{}' which matches "
"files that don't start with 'test_' but end with "
"'.py'").format(cls.DEFAULT_MATCH_RE))
option('--match-dir', metavar='<pattern>', default=None,
help=("search only dirs that exactly match <pattern> regular "
"expression; default is --match-dir='{0}', which "
"expression; default is --match-dir='{}', which "
"matches all dirs that don't start with "
"a dot").format(cls.DEFAULT_MATCH_DIR_RE))

Expand Down
21 changes: 10 additions & 11 deletions src/pydocstyle/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Value(object):

def __init__(self, *args):
if len(self._fields) != len(args):
raise ValueError('got {0} arguments for {1} fields for {2}: {3}'
raise ValueError('got {} arguments for {} fields for {}: {}'
.format(len(args), len(self._fields),
self.__class__.__name__, self._fields))
vars(self).update(zip(self._fields, args))
Expand All @@ -54,9 +54,9 @@ def __eq__(self, other):
return other and vars(self) == vars(other)

def __repr__(self):
kwargs = ', '.join('{0}={1!r}'.format(field, getattr(self, field))
kwargs = ', '.join('{}={!r}'.format(field, getattr(self, field))
for field in self._fields)
return '{0}({1})'.format(self.__class__.__name__, kwargs)
return '{}({})'.format(self.__class__.__name__, kwargs)


class Definition(Value):
Expand Down Expand Up @@ -91,10 +91,9 @@ def is_empty_or_comment(line):
return ''.join(reversed(list(filtered_src)))

def __str__(self):
out = 'in {0} {1} `{2}`'.format(self._publicity, self._human,
self.name)
out = 'in {} {} `{}`'.format(self._publicity, self._human, self.name)
if self.skipped_error_codes:
out += ' (skipping {0})'.format(self.skipped_error_codes)
out += ' (skipping {})'.format(self.skipped_error_codes)
return out


Expand Down Expand Up @@ -154,7 +153,7 @@ def is_public(self):
# Check if we are a setter/deleter method, and mark as private if so.
for decorator in self.decorators:
# Given 'foo', match 'foo.bar' but not 'foobar' or 'sfoo'
if re(r"^{0}\.".format(self.name)).match(decorator.name):
if re(r"^{}\.".format(self.name)).match(decorator.name):
return False
name_is_public = (not self.name.startswith('_') or
self.name in VARIADIC_MAGIC_METHODS or
Expand Down Expand Up @@ -229,7 +228,7 @@ def __iter__(self):

class TokenKind(int):
def __repr__(self):
return "tk.{0}".format(tk.tok_name[self])
return "tk.{}".format(tk.tok_name[self])


class Token(Value):
Expand Down Expand Up @@ -374,7 +373,7 @@ def parse_all(self):
raise AllError('Could not evaluate contents of __all__. ')
if self.current.value == '[':
sys.stderr.write(
"{0} WARNING: __all__ is defined as a list, this means "
"{} WARNING: __all__ is defined as a list, this means "
"pydocstyle cannot reliably detect contents of the __all__ "
"variable, because it can be mutated. Change __all__ to be "
"an (immutable) tuple, to remove this warning. Note, "
Expand All @@ -395,7 +394,7 @@ def parse_all(self):
self.current.value == ','):
all_content += self.current.value
else:
raise AllError('Unexpected token kind in __all__: {0!r}. '
raise AllError('Unexpected token kind in __all__: {!r}. '
.format(self.current.kind))
self.stream.move()
self.consume(tk.OP)
Expand All @@ -404,7 +403,7 @@ def parse_all(self):
self.all = eval(all_content, {})
except BaseException as e:
raise AllError('Could not evaluate contents of __all__.'
'\bThe value was {0}. The exception was:\n{1}'
'\bThe value was {}. The exception was:\n{}'
.format(all_content, e))

def parse_module(self):
Expand Down
2 changes: 1 addition & 1 deletion src/pydocstyle/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging


__version__ = '1.1.2rc'
__version__ = '2.0.0rc'
log = logging.getLogger(__name__)


Expand Down
12 changes: 5 additions & 7 deletions src/pydocstyle/violations.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def set_context(self, definition, explanation):
@property
def message(self):
"""Return the message to print to the user."""
ret = '{0}: {1}'.format(self.code, self.short_desc)
ret = '{}: {}'.format(self.code, self.short_desc)
if self.context is not None:
ret += ' (' + self.context.format(*self.parameters) + ')'
return ret
Expand All @@ -59,7 +59,7 @@ def lines(self):
numbers_width = len(str(numbers_width))
numbers_width = 6
for n, line in enumerate(lines_stripped):
source += '{{0}}{0}: {{1}}'.format(numbers_width).format(
source += '{{}}{}: {{}}'.format(numbers_width).format(
n + offset, line)
source += '%*d: %s' % (numbers_width, n + offset, line)
if n > 5:
Expand Down Expand Up @@ -143,7 +143,7 @@ def to_rst(cls):
for group in cls.groups:
table += sep_line
table += blank_line
table += '|' + '**{0}**'.format(group.name).center(78) + '|\n'
table += '|' + '**{}**'.format(group.name).center(78) + '|\n'
table += blank_line
for error in group.errors:
table += sep_line
Expand Down Expand Up @@ -212,10 +212,8 @@ class AttrDict(dict):
def __getattr__(self, item):
return self[item]

all_errors = set(ErrorRegistry.get_error_codes())

conventions = AttrDict({
'pep257': set(ErrorRegistry.get_error_codes()) - set(['D203',
'D212',
'D213',
'D404'])
'pep257': all_errors - {'D203', 'D212', 'D213', 'D404'}
})
2 changes: 1 addition & 1 deletion src/tests/test_cases/expected.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class Expectation(object):
"""Hold expectation for pep257 violations in tests."""

def __init__(self):
self.expected = set([])
self.expected = set()

def expect(self, *args):
"""Decorator that expects a certain PEP 257 violation."""
Expand Down
14 changes: 7 additions & 7 deletions src/tests/test_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,9 @@ def test_import_parser():
source_unicode_literals5,
source_unicode_literals6,
), 1):
module = parse(StringIO(source_ucl), 'file_ucl{0}.py'.format(i))
module = parse(StringIO(source_ucl), 'file_ucl{}.py'.format(i))

assert Module('file_ucl{0}.py'.format(i), _, 1,
assert Module('file_ucl{}.py'.format(i), _, 1,
_, _, None, _, _,
_, {'unicode_literals': True}, '') == module
assert module.future_imports['unicode_literals']
Expand All @@ -205,8 +205,8 @@ def test_import_parser():
source_multiple_future_imports6,
source_multiple_future_imports7,
), 1):
module = parse(StringIO(source_mfi), 'file_mfi{0}.py'.format(i))
assert Module('file_mfi{0}.py'.format(i), _, 1,
module = parse(StringIO(source_mfi), 'file_mfi{}.py'.format(i))
assert Module('file_mfi{}.py'.format(i), _, 1,
_, _, None, _, _,
_, {'unicode_literals': True, 'nested_scopes': True},
'') == module
Expand All @@ -223,9 +223,9 @@ def test_import_parser():
source_future_import_invalid7,
source_future_import_invalid8,
), 1):
module = parse(StringIO(source_ucl), 'file_invalid{0}.py'.format(i))
module = parse(StringIO(source_ucl), 'file_invalid{}.py'.format(i))

assert Module('file_invalid{0}.py'.format(i), _, 1,
assert Module('file_invalid{}.py'.format(i), _, 1,
_, _, None, _, _,
_, _, '') == module

Expand Down Expand Up @@ -268,7 +268,7 @@ def test_token_stream():
])
def test_pep257(test_case):
"""Run domain-specific tests from test.py file."""
case_module = __import__('test_cases.{0}'.format(test_case),
case_module = __import__('test_cases.{}'.format(test_case),
globals=globals(),
locals=locals(),
fromlist=['expectation'],
Expand Down
32 changes: 16 additions & 16 deletions src/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ def write_config(self, prefix='', **kwargs):
self.makedirs(base)

with open(os.path.join(base, 'tox.ini'), 'wt') as conf:
conf.write("[{0}]\n".format(self.script_name))
conf.write("[{}]\n".format(self.script_name))
for k, v in kwargs.items():
conf.write("{0} = {1}\n".format(k.replace('_', '-'), v))
conf.write("{} = {}\n".format(k.replace('_', '-'), v))

def open(self, path, *args, **kwargs):
"""Open a file in the environment.
Expand All @@ -76,7 +76,7 @@ def invoke(self, args="", target=None):
run_target = self.tempdir if target is None else \
os.path.join(self.tempdir, target)

cmd = shlex.split("{0} {1} {2}"
cmd = shlex.split("{} {} {}"
.format(self.script_name, run_target, args),
posix=False)
p = subprocess.Popen(cmd,
Expand Down Expand Up @@ -146,7 +146,7 @@ def test_pep257_conformance():
for src_dir in src_dirs:
src_files.extend(str(path) for path in src_dir.glob('*.py'))

ignored = set(['D104', 'D105'])
ignored = {'D104', 'D105'}
select = violations.conventions.pep257 - ignored
errors = list(checker.check(src_files, select=select))
assert errors == [], errors
Expand All @@ -159,23 +159,23 @@ def function_with_bad_docstring(foo):
no blank line after one-liner is bad. Also this - """
return foo
''')
expected_error_codes = set(('D100', 'D400', 'D401', 'D205', 'D209',
'D210', 'D403'))
expected_error_codes = {'D100', 'D400', 'D401', 'D205', 'D209', 'D210',
'D403'}
mock_open = mock.mock_open(read_data=function_to_check)
from pydocstyle import checker
with mock.patch.object(
checker, 'tokenize_open', mock_open, create=True):
errors = tuple(checker.check(['filepath']))
error_codes = set(error.code for error in errors)
error_codes = {error.code for error in errors}
assert error_codes == expected_error_codes

# We need to recreate the mock, otherwise the read file is empty
mock_open = mock.mock_open(read_data=function_to_check)
with mock.patch.object(
checker, 'tokenize_open', mock_open, create=True):
ignored = set(('D100', 'D202', 'D213'))
ignored = {'D100', 'D202', 'D213'}
errors = tuple(checker.check(['filepath'], ignore=ignored))
error_codes = set(error.code for error in errors)
error_codes = {error.code for error in errors}
assert error_codes == expected_error_codes - ignored


Expand Down Expand Up @@ -572,8 +572,8 @@ def foo():
assert code == 1
assert 'base.py' in err, err
assert 'a.py' in err, err
assert err['base.py'] == set(['D100']), err
assert err['a.py'] == set(['D100', 'D103']), err
assert err['base.py'] == {'D100'}, err
assert err['a.py'] == {'D100', 'D103'}, err


def test_config_file_convention_overrides_select(env):
Expand Down Expand Up @@ -771,8 +771,8 @@ def bar():
assert code == 1
assert 'base.py' in err, err
assert 'a.py' in err, err
assert err['base.py'] == set(['D100']), err
assert err['a.py'] == set(['D100', 'D101']), err
assert err['base.py'] == {'D100'}, err
assert err['a.py'] == {'D100', 'D101'}, err


def test_config_file_nearest_to_checked_file(env):
Expand Down Expand Up @@ -828,9 +828,9 @@ def bar():
assert 'base.py' in err, err
assert 'a.py' in err, err
assert 'b.py' in err, err
assert err['base.py'] == set(['D101', 'D102']), err
assert err['a.py'] == set(['D101', 'D102']), err
assert err['b.py'] == set(['D102']), err
assert err['base.py'] == {'D101', 'D102'}, err
assert err['a.py'] == {'D101', 'D102'}, err
assert err['b.py'] == {'D102'}, err


def test_config_file_nearest_match_re(env):
Expand Down
Loading