From c07a90bd22c9a0698ef969066504a5933a9404fa Mon Sep 17 00:00:00 2001 From: Steven Myint Date: Fri, 16 Jun 2017 06:55:32 -0700 Subject: [PATCH] Workaround Pyflakes bugs The Pyflakes bugs were mentioned in #18. --- autoflake.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/autoflake.py b/autoflake.py index f0a83ca..0c726dd 100755 --- a/autoflake.py +++ b/autoflake.py @@ -303,7 +303,10 @@ def filter_code(source, additional_imports=None, for line_number, module_name in unused_import_module_name(messages): marked_unused_module[line_number].append(module_name) - if expand_star_import: + if expand_star_import and not ( + re.search(r'\b__all__\b', source) or + re.search(r'\bdel\b', source) + ): marked_star_import_line_numbers = frozenset( star_import_used_line_numbers(messages)) if len(marked_star_import_line_numbers) > 1: