Skip to content

Commit

Permalink
fix: skip if fixed-method result to another result
Browse files Browse the repository at this point in the history
  • Loading branch information
hhatto committed May 28, 2024
1 parent 75557c0 commit 91b15c5
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions autopep8.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ def __init__(self, filename,
self.source = sio.readlines()
self.options = options
self.indent_word = _get_indentword(''.join(self.source))
self.original_source = copy.copy(self.source)

# collect imports line
self.imports = {}
Expand Down Expand Up @@ -540,6 +541,14 @@ def _fix_source(self, results):
if result['line'] in completed_lines:
continue

# NOTE: Skip if the correction by the fixed-method affects
# the number of lines of another remark.
_line_index = result['line'] - 1
_target = self.source[_line_index]
_original_target = self.original_source[_line_index]
if _target != _original_target:
continue

fixed_methodname = 'fix_' + result['id'].lower()
if hasattr(self, fixed_methodname):
fix = getattr(self, fixed_methodname)
Expand Down

0 comments on commit 91b15c5

Please sign in to comment.