Skip to content

Commit 361ba26

Browse files
committed
care indent in case e721
1 parent 5b9a953 commit 361ba26

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

autopep8.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1320,6 +1320,10 @@ def fix_e721(self, result):
13201320
isinstance_stmt = " not isinstance"
13211321

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

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

1343-
fix_line = f"{_prefix}{isinstance_stmt}({_type_comp}){_suffix}"
1347+
fix_line = f"{indent_str}{_prefix}{isinstance_stmt}({_type_comp}){_suffix}"
13441348
self.source[line_index] = fix_line
13451349

13461350
def fix_e722(self, result):

0 commit comments

Comments
 (0)