A similar issue was raised here and the OP was able to solve the issue by removing
[tool.autoflake] check = true
in the pyproject.toml. See Remove unused imports not working in place.
pyproject.toml