Skip to content

Commit f962c00

Browse files
authored
Merge pull request #261 from asottile/dead-code
remove some unneeded calls to _partitions_to_src
2 parents 9589e0b + b368ea7 commit f962c00

File tree

1 file changed

+1
-15
lines changed

1 file changed

+1
-15
lines changed

reorder_python_imports.py

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,7 @@ def partition_source(src: str) -> list[CodePartition]:
115115
chunks.append(CodePartition(CodeType.CODE, srctext))
116116
break
117117

118-
chunks = [chunk for chunk in chunks if chunk.src]
119-
120-
# Make sure we're not removing any code
121-
assert _partitions_to_src(chunks) == src
122-
return chunks
118+
return [chunk for chunk in chunks if chunk.src]
123119

124120

125121
def combine_trailing_code_chunks(
@@ -380,16 +376,6 @@ def apply_import_sorting(
380376
if new_imports:
381377
new_imports.pop()
382378

383-
# There's the potential that we moved a bunch of whitespace onto the
384-
# beginning of the rest of the code. To fix this, we're going to combine
385-
# all of that code, and then make sure there are two linebreaks to start
386-
restsrc = _partitions_to_src(rest)
387-
restsrc = restsrc.rstrip()
388-
if restsrc:
389-
rest = [CodePartition(CodeType.CODE, restsrc + '\n')]
390-
else:
391-
rest = []
392-
393379
return pre_import_code + new_imports + rest
394380

395381

0 commit comments

Comments
 (0)