Skip to content

Commit

Permalink
care indent in case e721
Browse files Browse the repository at this point in the history
  • Loading branch information
hhatto committed Jan 13, 2025
1 parent 5b9a953 commit 361ba26
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion autopep8.py
Original file line number Diff line number Diff line change
Expand Up @@ -1320,6 +1320,10 @@ def fix_e721(self, result):
isinstance_stmt = " not isinstance"

_type_comp = f"{_target_obj}, {target[:start]}"
indent_match = re.match(r'^\s+', target)
indent_str = ""
if indent_match:
indent_str = indent_match.group()

_prefix_tmp = target[:start].split()
if len(_prefix_tmp) >= 1:
Expand All @@ -1340,7 +1344,7 @@ def fix_e721(self, result):
cmp_b = _suffix_type_match.groups()[0]
_type_comp = f"{_target_obj}, {cmp_b}"

fix_line = f"{_prefix}{isinstance_stmt}({_type_comp}){_suffix}"
fix_line = f"{indent_str}{_prefix}{isinstance_stmt}({_type_comp}){_suffix}"
self.source[line_index] = fix_line

def fix_e722(self, result):
Expand Down

0 comments on commit 361ba26

Please sign in to comment.