From 2cb6e6ec603a58ef614bc6e056d6259a02d202bc Mon Sep 17 00:00:00 2001 From: semiventurero Date: Sun, 1 Jun 2025 17:37:00 +0300 Subject: [PATCH 1/2] Fixing carriage return error. Issue #326 --- autoflake.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/autoflake.py b/autoflake.py index 9c0eb86..6bc903a 100755 --- a/autoflake.py +++ b/autoflake.py @@ -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( @@ -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', '') + indentation += "import " assert newline @@ -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), @@ -1607,4 +1610,4 @@ def main() -> int: if __name__ == "__main__": - sys.exit(main()) + sys.exit(main()) \ No newline at end of file From ce2d4933347160bb6dab884fb6836964db16f1ef Mon Sep 17 00:00:00 2001 From: semiventurero Date: Mon, 2 Jun 2025 15:49:26 +0300 Subject: [PATCH 2/2] Autoflake.py is added without turkish comments. --- autoflake.py | 1 - 1 file changed, 1 deletion(-) diff --git a/autoflake.py b/autoflake.py index 6bc903a..353b5c2 100755 --- a/autoflake.py +++ b/autoflake.py @@ -534,7 +534,6 @@ def break_up_import(line: str) -> str: if len(parts) == 2: indentation, imports = parts else: - # Eğer split işlemi beklenen şekilde çalışmazsa indentation = '' imports = line.replace('\r', '')