A Python utility and library that automatically sorts and groups your import statements.
hakancelikdev/unimport
A Python linter and formatter that detects and removes unused import statements from your code.
- Stars
- 247
- Forks
- 20
- Open issues
- 0
- Last commit
- last month
What is it?
Unimport is a command-line tool for Python projects that finds import statements which are never used and removes them. It works as both a linter, reporting unused imports, and a formatter, rewriting files to drop them.
Unused imports clutter code and slow down reading. Unimport automates the cleanup so developers do not have to track them down by hand, and it can be run as part of a development workflow to keep a codebase tidy over time.
The project is published on PyPI and documented on its project site. It is released under the MIT license.
Key features
- 01Detects unused import statements in Python source files.
- 02Removes unused imports automatically when run as a formatter.
- 03Can be run as a command-line tool.
- 04Published on PyPI for easy installation.
Use cases
- Cleaning up unused imports in an existing Python codebase.
- Enforcing import hygiene in a pre-commit hook or CI pipeline.
- Reviewing a project for leftover imports after refactoring.
Quick start
- 1
Install unimport from PyPI
pip install unimport - 2
Run unimport on your code to see unused imports
unimport
Things to know
- The README gives little detail beyond a link to the documentation site.
In collections
Topics
FAQ
- What is unimport?
- A Python linter and formatter that detects and removes unused import statements from your code. Unimport is a command-line tool for Python projects that finds import statements which are never used and removes them. It works as both a linter, reporting unused imports, and a formatter, rewriting files to drop them.
- Is unimport free to use? What license does it have?
- unimport is open source under the MIT license. Check the license terms before using it in commercial products.
- Is unimport still maintained?
- Updated within 6 months. The last commit to unimport was on Oct 2, 2026.
- What can I use unimport for?
- Cleaning up unused imports in an existing Python codebase. Enforcing import hygiene in a pre-commit hook or CI pipeline. Reviewing a project for leftover imports after refactoring.
- How do I install unimport?
- Install unimport from PyPI: pip install unimport Run unimport on your code to see unused imports: unimport
- Where can I get unimport?
- The source code and installation instructions are on GitHub: https://github.com/hakancelikdev/unimport
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A ready-to-run collection of linters and formatters that runs as a GitHub Action or standalone container to check and fix source code.
A Rust-based multi-language CLI that runs linters, auto-formatters, security scanners and maintainability checks through one tool and config file.
A static code analyser for Python that checks for errors, enforces coding standards, and flags code smells without running your code.
A pluggable linter for ECMAScript/JavaScript that finds problematic patterns in code and can automatically fix many of them.
A Rust linter with over 800 lints that catches common mistakes and suggests more idiomatic code, run as a cargo subcommand.