def run_autoflake(filename): parser = argparse.ArgumentParser() parser.add_argument('--in-place', action='store_true') parser.add_argument('--remove-all-unused-imports', action='store_true') cmd_args = ['--in-place', '--remove-all-unused-imports'] args = parser.parse_args(cmd_args) args.imports = None args.expand_star_imports = None args.remove_duplicate_keys = None args.remove_unused_variables = None autoflake.fix_file(filename, args=args, standard_out=sys.stdout)
def perform_autoflake(f): args = argparse.Namespace() args.remove_all_unused_imports = True args.ignore_init_module_imports = True args.remove_duplicate_keys = True args.imports = "" args.expand_star_imports = True args.remove_unused_variables = True args.check = False args.in_place = True autoflake.fix_file(f, args, sys.stdout)
def _remove_unused_imports(output_file_name): fix_file( output_file_name, args=AutoflakeArgs( remove_all_unused_imports=True, ignore_init_module_imports=False, imports=None, expand_star_imports=False, remove_duplicate_keys=False, remove_unused_variables=True, in_place=True, check=False, ), standard_out=sys.stdout, )
def process(self, file_path: Path): fix_file(file_path, args=self._args, standard_out=sys.stdout)