Skip to content
Open
Changes from 1 commit
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
21 changes: 12 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,14 @@ 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:
# Eğer split işlemi beklenen şekilde çalışmazsa
indentation = ''
imports = line.replace('\r', '')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you have an example of when this happens?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes in issue #326

Copy link
Author

@venturero venturero Jun 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is my pull request okay to merge? Do you have any other feedback for me? If so, I can update the code again. @fsouza



indentation += "import "
assert newline
Expand Down Expand Up @@ -575,8 +578,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 +1610,4 @@ def main() -> int:


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