Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions autoflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ def filter_from_import(line: str, unused_module: Iterable[str]) -> str:
"""
(indentation, imports) = re.split(
pattern=r"\bimport\b",
string=line,
string=line.replace('\r', ''),
maxsplit=1,
)
match = re.search(
Expand Down Expand Up @@ -530,11 +530,13 @@ def break_up_import(line: str) -> str:
if not newline:
return line

(indentation, imports) = re.split(
pattern=r"\bimport\b",
string=line,
maxsplit=1,
)
parts = re.split(r"\bimport\b", line.replace('\r', ''), maxsplit=1)
if len(parts) == 2:
indentation, imports = parts
else:
indentation = ''
imports = line.replace('\r', '')


indentation += "import "
assert newline
Expand Down Expand Up @@ -575,8 +577,8 @@ def filter_code(
undefined_names: list[str] = []
if expand_star_imports and not (
# See explanations in #18.
re.search(r"\b__all__\b", source)
or re.search(r"\bdel\b", source)
re.search(r"\b__all__\b", source.replace('\r', ''))
or re.search(r"\bdel\b", source.replace('\r', ''))
):
marked_star_import_line_numbers = frozenset(
star_import_used_line_numbers(messages),
Expand Down Expand Up @@ -1607,4 +1609,4 @@ def main() -> int:


if __name__ == "__main__":
sys.exit(main())
sys.exit(main())