Skip to content

Commit

Permalink
Merge pull request #261 from asottile/dead-code
Browse files Browse the repository at this point in the history
remove some unneeded calls to _partitions_to_src
  • Loading branch information
asottile authored Jul 3, 2022
2 parents 9589e0b + b368ea7 commit f962c00
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions reorder_python_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,7 @@ def partition_source(src: str) -> list[CodePartition]:
chunks.append(CodePartition(CodeType.CODE, srctext))
break

chunks = [chunk for chunk in chunks if chunk.src]

# Make sure we're not removing any code
assert _partitions_to_src(chunks) == src
return chunks
return [chunk for chunk in chunks if chunk.src]


def combine_trailing_code_chunks(
Expand Down Expand Up @@ -380,16 +376,6 @@ def apply_import_sorting(
if new_imports:
new_imports.pop()

# There's the potential that we moved a bunch of whitespace onto the
# beginning of the rest of the code. To fix this, we're going to combine
# all of that code, and then make sure there are two linebreaks to start
restsrc = _partitions_to_src(rest)
restsrc = restsrc.rstrip()
if restsrc:
rest = [CodePartition(CodeType.CODE, restsrc + '\n')]
else:
rest = []

return pre_import_code + new_imports + rest


Expand Down

0 comments on commit f962c00

Please sign in to comment.