TIL - 🧹 unimport linter formatter
✨ Unimport - A linter & formatter for finding & removing unused import statements. - looks good to me. If it works in large codebases as well as it just did on a few smaller projects for me then I'll add it to my toolbelt. https://t.co/yk1X2UMemX
— ✨ Jeff Triplett ✨ (@webology) December 12, 2020
Thanks to this Jeff Triplets tweet I discovered unimport, which is an interesting tool to detect unused imports (like flake8 would do) and to remove them from the code.
And the cherry on top it’s that it can scan the requirements file and detect unused dependencies (which is probably even more important).
Historically this has not been a problem for me (or Nephila team), as flake8 is already well ingrained in our workflow, so we are used to handle code cleanup before committing.
But as I sometimes inherit a large codebase with messy code, and it’s awesome how much you can achieve with the right tools.
Currently isort
+ black
+ pyupgrade
already do a really good job, but adding unimport
to the equation is 💥: a much nicer codebase with zero effort
I will surely give it a more in depth test, and I might add to my linting reference toolbox.
Shootout to Hakan Çelik for this package, and its awesome documentation.