autoflake icon indicating copy to clipboard operation
autoflake copied to clipboard

Remove ununsed import error

Open trim21 opened this issue 6 years ago • 2 comments

I can't describe it well in title, so I just show the example.

try:
    import playhouse.postgres_ext as pw_pext
except ImportError:
    pass

in this case, pw_pext is unused import.

After autoflake --in-place --remove-unused-variables --remove-all-unused-imports $file

try:
    pass
except ImportError:
    pass

trim21 avatar May 17 '19 16:05 trim21

To be clear autoflake is replacing "unused imports" with pass statements.

sevdog avatar Nov 22 '22 16:11 sevdog

Running the autoflake command twice, the first with -remove-all-unused-imports flag and the second with --ignore-pass-statements, got the desired outcome (removed unused imports weren't replaced with "pass").

LiorYardeni avatar Dec 28 '22 12:12 LiorYardeni