autoflake icon indicating copy to clipboard operation
autoflake copied to clipboard

Unused pass not being removed in certain cases

Open brupelo opened this issue 4 years ago • 0 comments

Introduction

Hi, I've been using autoflake for quite a while and I must to admit is a really awesome tool... so first of all, thanks for creating it :)

Here's the thing, I've always been scared of using --remove-unused-variables but today I've decided to give it a shot and test it for a bit... overall behaves fairly well but I've found some corner cases producing unoptimal code, the

Requirements

Version: 1.3.1
OS: win7
python: Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 22:45:29) [MSC v.1916 32 bit (Intel)] on win32

Problem

Running autoflake --remove-all-unused-imports --remove-unused-variables --ignore-init-module-imports --in-place foo.py with below code:

def foo1():
    a = 1

    return 2

def foo2():
    a = 1
    return 2

Will produce:

def foo1():
    pass

    return 2


def foo2():
    return 2

Expected output

def foo1():
    return 2


def foo2():
    return 2

Question

Why is the redundant pass hasn't been removed? Is this a bug? Is it intended behaviour? Is there any hidden directive I need to use to get rid of it? I can see there was this old issue https://github.com/myint/autoflake/pull/25 but after reading it it's still unclear to me what the final decission was...

Thanks in advance :)

brupelo avatar Apr 15 '20 15:04 brupelo