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

Commit 1241057

Browse files
committed
Drop support for Python 2.6.
1 parent d20c1e7 commit 1241057

File tree

8 files changed

+48
-53
lines changed

8 files changed

+48
-53
lines changed

.travis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ install: pip install tox
99
script: tox
1010
matrix:
1111
include:
12-
- python: 2.6
13-
env: TOXENV=py26
1412
- python: 2.7
1513
env: TOXENV=py27
1614
- python: 3.3

src/pydocstyle/config.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ def _read_configuration_file(self, path):
260260
continue
261261

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

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

280280
if options is not None:
281281
if not self._validate_options(options):
282-
raise IllegalConfiguration('in file: {0}'.format(path))
282+
raise IllegalConfiguration('in file: {}'.format(path))
283283

284284
return options, should_inherit
285285

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

420420
if options.convention and options.convention not in conventions:
421-
log.error("Illegal convention '{0}'. Possible conventions: {1}"
421+
log.error("Illegal convention '{}'. Possible conventions: {}"
422422
.format(options.convention,
423423
', '.join(conventions.keys())))
424424
return False
@@ -442,7 +442,7 @@ def _get_set(value_str):
442442
Removes any occurrences of '' in the set.
443443
444444
"""
445-
return set(value_str.split(',')) - set([''])
445+
return set(value_str.split(',')) - {''}
446446

447447
for opt in optional_set_options:
448448
value = getattr(options, opt)
@@ -497,7 +497,7 @@ def _create_option_parser(cls):
497497
'for example: --ignore=D101,D202')
498498
option('--convention', metavar='<name>', default=None,
499499
help='choose the basic list of checked errors by specifying an '
500-
'existing convention. Possible conventions: {0}'
500+
'existing convention. Possible conventions: {}'
501501
.format(', '.join(conventions)))
502502
option('--add-select', metavar='<codes>', default=None,
503503
help='amend the list of errors to check for by specifying '
@@ -509,12 +509,12 @@ def _create_option_parser(cls):
509509
# Match clauses
510510
option('--match', metavar='<pattern>', default=None,
511511
help=("check only files that exactly match <pattern> regular "
512-
"expression; default is --match='{0}' which matches "
512+
"expression; default is --match='{}' which matches "
513513
"files that don't start with 'test_' but end with "
514514
"'.py'").format(cls.DEFAULT_MATCH_RE))
515515
option('--match-dir', metavar='<pattern>', default=None,
516516
help=("search only dirs that exactly match <pattern> regular "
517-
"expression; default is --match-dir='{0}', which "
517+
"expression; default is --match-dir='{}', which "
518518
"matches all dirs that don't start with "
519519
"a dot").format(cls.DEFAULT_MATCH_DIR_RE))
520520

src/pydocstyle/parser.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class Value(object):
4242

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

5656
def __repr__(self):
57-
kwargs = ', '.join('{0}={1!r}'.format(field, getattr(self, field))
57+
kwargs = ', '.join('{}={!r}'.format(field, getattr(self, field))
5858
for field in self._fields)
59-
return '{0}({1})'.format(self.__class__.__name__, kwargs)
59+
return '{}({})'.format(self.__class__.__name__, kwargs)
6060

6161

6262
class Definition(Value):
@@ -91,10 +91,9 @@ def is_empty_or_comment(line):
9191
return ''.join(reversed(list(filtered_src)))
9292

9393
def __str__(self):
94-
out = 'in {0} {1} `{2}`'.format(self._publicity, self._human,
95-
self.name)
94+
out = 'in {} {} `{}`'.format(self._publicity, self._human, self.name)
9695
if self.skipped_error_codes:
97-
out += ' (skipping {0})'.format(self.skipped_error_codes)
96+
out += ' (skipping {})'.format(self.skipped_error_codes)
9897
return out
9998

10099

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

230229
class TokenKind(int):
231230
def __repr__(self):
232-
return "tk.{0}".format(tk.tok_name[self])
231+
return "tk.{}".format(tk.tok_name[self])
233232

234233

235234
class Token(Value):
@@ -374,7 +373,7 @@ def parse_all(self):
374373
raise AllError('Could not evaluate contents of __all__. ')
375374
if self.current.value == '[':
376375
sys.stderr.write(
377-
"{0} WARNING: __all__ is defined as a list, this means "
376+
"{} WARNING: __all__ is defined as a list, this means "
378377
"pydocstyle cannot reliably detect contents of the __all__ "
379378
"variable, because it can be mutated. Change __all__ to be "
380379
"an (immutable) tuple, to remove this warning. Note, "
@@ -395,7 +394,7 @@ def parse_all(self):
395394
self.current.value == ','):
396395
all_content += self.current.value
397396
else:
398-
raise AllError('Unexpected token kind in __all__: {0!r}. '
397+
raise AllError('Unexpected token kind in __all__: {!r}. '
399398
.format(self.current.kind))
400399
self.stream.move()
401400
self.consume(tk.OP)
@@ -404,7 +403,7 @@ def parse_all(self):
404403
self.all = eval(all_content, {})
405404
except BaseException as e:
406405
raise AllError('Could not evaluate contents of __all__.'
407-
'\bThe value was {0}. The exception was:\n{1}'
406+
'\bThe value was {}. The exception was:\n{}'
408407
.format(all_content, e))
409408

410409
def parse_module(self):

src/pydocstyle/violations.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def set_context(self, definition, explanation):
4040
@property
4141
def message(self):
4242
"""Return the message to print to the user."""
43-
ret = '{0}: {1}'.format(self.code, self.short_desc)
43+
ret = '{}: {}'.format(self.code, self.short_desc)
4444
if self.context is not None:
4545
ret += ' (' + self.context.format(*self.parameters) + ')'
4646
return ret
@@ -59,7 +59,7 @@ def lines(self):
5959
numbers_width = len(str(numbers_width))
6060
numbers_width = 6
6161
for n, line in enumerate(lines_stripped):
62-
source += '{{0}}{0}: {{1}}'.format(numbers_width).format(
62+
source += '{{}}{}: {{}}'.format(numbers_width).format(
6363
n + offset, line)
6464
source += '%*d: %s' % (numbers_width, n + offset, line)
6565
if n > 5:
@@ -143,7 +143,7 @@ def to_rst(cls):
143143
for group in cls.groups:
144144
table += sep_line
145145
table += blank_line
146-
table += '|' + '**{0}**'.format(group.name).center(78) + '|\n'
146+
table += '|' + '**{}**'.format(group.name).center(78) + '|\n'
147147
table += blank_line
148148
for error in group.errors:
149149
table += sep_line
@@ -212,10 +212,8 @@ class AttrDict(dict):
212212
def __getattr__(self, item):
213213
return self[item]
214214

215+
all_errors = set(ErrorRegistry.get_error_codes())
215216

216217
conventions = AttrDict({
217-
'pep257': set(ErrorRegistry.get_error_codes()) - set(['D203',
218-
'D212',
219-
'D213',
220-
'D404'])
218+
'pep257': all_errors - {'D203', 'D212', 'D213', 'D404'}
221219
})

src/tests/test_cases/expected.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ class Expectation(object):
22
"""Hold expectation for pep257 violations in tests."""
33

44
def __init__(self):
5-
self.expected = set([])
5+
self.expected = set()
66

77
def expect(self, *args):
88
"""Decorator that expects a certain PEP 257 violation."""

src/tests/test_definitions.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,9 @@ def test_import_parser():
189189
source_unicode_literals5,
190190
source_unicode_literals6,
191191
), 1):
192-
module = parse(StringIO(source_ucl), 'file_ucl{0}.py'.format(i))
192+
module = parse(StringIO(source_ucl), 'file_ucl{}.py'.format(i))
193193

194-
assert Module('file_ucl{0}.py'.format(i), _, 1,
194+
assert Module('file_ucl{}.py'.format(i), _, 1,
195195
_, _, None, _, _,
196196
_, {'unicode_literals': True}, '') == module
197197
assert module.future_imports['unicode_literals']
@@ -205,8 +205,8 @@ def test_import_parser():
205205
source_multiple_future_imports6,
206206
source_multiple_future_imports7,
207207
), 1):
208-
module = parse(StringIO(source_mfi), 'file_mfi{0}.py'.format(i))
209-
assert Module('file_mfi{0}.py'.format(i), _, 1,
208+
module = parse(StringIO(source_mfi), 'file_mfi{}.py'.format(i))
209+
assert Module('file_mfi{}.py'.format(i), _, 1,
210210
_, _, None, _, _,
211211
_, {'unicode_literals': True, 'nested_scopes': True},
212212
'') == module
@@ -223,9 +223,9 @@ def test_import_parser():
223223
source_future_import_invalid7,
224224
source_future_import_invalid8,
225225
), 1):
226-
module = parse(StringIO(source_ucl), 'file_invalid{0}.py'.format(i))
226+
module = parse(StringIO(source_ucl), 'file_invalid{}.py'.format(i))
227227

228-
assert Module('file_invalid{0}.py'.format(i), _, 1,
228+
assert Module('file_invalid{}.py'.format(i), _, 1,
229229
_, _, None, _, _,
230230
_, _, '') == module
231231

@@ -268,7 +268,7 @@ def test_token_stream():
268268
])
269269
def test_pep257(test_case):
270270
"""Run domain-specific tests from test.py file."""
271-
case_module = __import__('test_cases.{0}'.format(test_case),
271+
case_module = __import__('test_cases.{}'.format(test_case),
272272
globals=globals(),
273273
locals=locals(),
274274
fromlist=['expectation'],

src/tests/test_integration.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ def write_config(self, prefix='', **kwargs):
5050
self.makedirs(base)
5151

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

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

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

149-
ignored = set(['D104', 'D105'])
149+
ignored = {'D104', 'D105'}
150150
select = violations.conventions.pep257 - ignored
151151
errors = list(checker.check(src_files, select=select))
152152
assert errors == [], errors
@@ -159,23 +159,23 @@ def function_with_bad_docstring(foo):
159159
no blank line after one-liner is bad. Also this - """
160160
return foo
161161
''')
162-
expected_error_codes = set(('D100', 'D400', 'D401', 'D205', 'D209',
163-
'D210', 'D403'))
162+
expected_error_codes = {'D100', 'D400', 'D401', 'D205', 'D209', 'D210',
163+
'D403'}
164164
mock_open = mock.mock_open(read_data=function_to_check)
165165
from pydocstyle import checker
166166
with mock.patch.object(
167167
checker, 'tokenize_open', mock_open, create=True):
168168
errors = tuple(checker.check(['filepath']))
169-
error_codes = set(error.code for error in errors)
169+
error_codes = {error.code for error in errors}
170170
assert error_codes == expected_error_codes
171171

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

181181

@@ -572,8 +572,8 @@ def foo():
572572
assert code == 1
573573
assert 'base.py' in err, err
574574
assert 'a.py' in err, err
575-
assert err['base.py'] == set(['D100']), err
576-
assert err['a.py'] == set(['D100', 'D103']), err
575+
assert err['base.py'] == {'D100'}, err
576+
assert err['a.py'] == {'D100', 'D103'}, err
577577

578578

579579
def test_config_file_convention_overrides_select(env):
@@ -771,8 +771,8 @@ def bar():
771771
assert code == 1
772772
assert 'base.py' in err, err
773773
assert 'a.py' in err, err
774-
assert err['base.py'] == set(['D100']), err
775-
assert err['a.py'] == set(['D100', 'D101']), err
774+
assert err['base.py'] == {'D100'}, err
775+
assert err['a.py'] == {'D100', 'D101'}, err
776776

777777

778778
def test_config_file_nearest_to_checked_file(env):
@@ -828,9 +828,9 @@ def bar():
828828
assert 'base.py' in err, err
829829
assert 'a.py' in err, err
830830
assert 'b.py' in err, err
831-
assert err['base.py'] == set(['D101', 'D102']), err
832-
assert err['a.py'] == set(['D101', 'D102']), err
833-
assert err['b.py'] == set(['D102']), err
831+
assert err['base.py'] == {'D101', 'D102'}, err
832+
assert err['a.py'] == {'D101', 'D102'}, err
833+
assert err['b.py'] == {'D102'}, err
834834

835835

836836
def test_config_file_nearest_match_re(env):

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# install tox" and then run "tox" from this directory.
55

66
[tox]
7-
envlist = py26, py27, py33, py34, py35, pypy, pypy3, docs
7+
envlist = py27, py33, py34, py35, pypy, pypy3, docs
88

99
[testenv]
1010
# Make sure reading the UTF-8 from test.py works regardless of the locale used.

0 commit comments

Comments
 (0)