File tree Expand file tree Collapse file tree 1 file changed +12
-10
lines changed
Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -432,26 +432,28 @@ def dedent(text):
432432 lines = text .split ('\n ' )
433433
434434 # Get length of leading whitespace, inspired by ``os.path.commonprefix()``.
435- l1 = None
436- l2 = None
435+ val = False
437436 for i , line in enumerate (lines ):
438437 # Compute min + max concurrently + normalize others
439438 if line and not line .isspace ():
440- if l1 is None or line < l1 :
441- l1 = line
442- if l2 is None or line > l2 :
443- l2 = line
439+ if val :
440+ if line < l1 :
441+ l1 = line
442+ elif line > l2 :
443+ l2 = line
444+ else :
445+ val = True
446+ l1 = l2 = line
447+
444448 else :
445449 lines [i ] = ''
446450
447- if l1 is None :
448- l1 = ''
451+ if not val or not l1 :
452+ return ' \n ' . join ( lines )
449453
450454 for margin , c in enumerate (l1 ):
451455 if c != l2 [margin ] or c not in ' \t ' :
452456 break
453- else :
454- return '\n ' .join (lines )
455457
456458 return '\n ' .join ([line [margin :] for line in lines ])
457459
You can’t perform that action at this time.
0 commit comments