diff options
author | Brett Cannon <brett@python.org> | 2014-08-29 15:48:24 -0400 |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2014-08-29 15:48:24 -0400 |
commit | 8e23aa2b179274c9c1b128a8b3daf8d2e24cfd75 (patch) | |
tree | c234e08aa390be9bca941e66e508071e5e44a801 /checkers/format.py | |
parent | 001469c8272a235b4f62b9b5c3ee248635168ad4 (diff) | |
parent | c2cc31874880d7f0d5bd444c6a3b17fa817e2509 (diff) | |
download | pylint-python_6.tar.gz |
Merge with defaultpython_6
Diffstat (limited to 'checkers/format.py')
-rw-r--r-- | checkers/format.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/checkers/format.py b/checkers/format.py index 34da653..134999e 100644 --- a/checkers/format.py +++ b/checkers/format.py @@ -24,6 +24,9 @@ Some parts of the process_token method is based from The Tab Nanny std module. import keyword import sys import tokenize +from functools import reduce +import six +from six.moves import zip if not hasattr(tokenize, 'NL'): raise ValueError("tokenize.NL doesn't exist -- tokenize module too old") @@ -342,7 +345,8 @@ class ContinuedLineState(object): # current indent level paren_align = self._cont_stack[-1].valid_outdent_offsets next_align = self._cont_stack[-1].valid_continuation_offsets.copy() - next_align[next_align.keys()[0] + self._continuation_size] = True + next_align_keys = list(next_align.keys()) + next_align[next_align_keys[0] + self._continuation_size] = True # Note that the continuation of # d = { # 'a': 'b' @@ -506,7 +510,7 @@ class FormatChecker(BaseTokenChecker): keyword_token = tokens[start][1] line_num = tokens[start][2][0] - for i in xrange(start, len(tokens) - 1): + for i in range(start, len(tokens) - 1): token = tokens[i] # If we hit a newline, then assume any parens were for continuation. @@ -812,7 +816,7 @@ class FormatChecker(BaseTokenChecker): for indent_pos, state, offsets in self._current_line.retained_warnings: block_type = offsets[tokens.start_col(indent_pos)] - hints = dict((k, v) for k, v in offsets.iteritems() + hints = dict((k, v) for k, v in six.iteritems(offsets) if v != block_type) if single_line_block_stmt and block_type == WITH_BODY: self._add_continuation_message(state, hints, tokens, indent_pos) @@ -886,7 +890,7 @@ class FormatChecker(BaseTokenChecker): tolineno = node.tolineno assert tolineno, node lines = [] - for line in xrange(line, tolineno + 1): + for line in range(line, tolineno + 1): self._visited_lines[line] = 1 try: lines.append(self._lines[line].rstrip()) |