I would like to auto-remove unused variables and imports in my Django 4/Python 3.9 project. I have installed autoflake (3.1.0). In my service file, I have a line like
from ..settings import PYTHON_ENV
which VSCode tells me
"PYTHON_ENV" is not accessedPylance
So I ran the autoflake command
autoflake --in-place --remove-unused-variables cbapp/services/my_service.py
but the unused imports remains. What else do I need to do to have the unused imports removed?
It says in the README that by default it only removes unused imports from the standard library. In order to remove all imports you need to give the
--remove-all-unused-imports
flag.https://github.com/PyCQA/autoflake#advanced-usage