SkillAgentSearch skills...

Importchecker

Command line utility to find unused imports in Python modules

Install / Use

/learn @zopefoundation/Importchecker
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

.. caution::

This repository is no longer maintained and thus it got archived.

If you want to work on it please open a ticket in
https://github.com/zopefoundation/meta/issues requesting its unarchival.

Importchecker

What is importchecker?

Importchecker is a command line utility to find unused imports in Python modules.

Its output is "grep-like" (and thus "emacs-friendly"), reporting both the module's filenames and line numbers where names are imported that are not actually used in the module.

Importchecker will not modify any of the source files. Whether the import needs to be removed is left to the judgement of the developer.

Installation

The importchecker command line utility can be installed using the pip::

$ pip install importchecker

The command can then be invoked with either a directory or a Python file::

$ importchecker /path/to/a/source/tree $ importchecker /path/to/a/source/tree/module.py

Buildout

Projects that make use of zc.buildout_ for development might find the following buildout.cfg. snippet useful for using the importchecker on the developed codebase::

[buildout] ... parts = importchecker ... ...

[importchecker] recipe = zc.recipe.egg eggs = importchecker arguments = "${buildout:directory}/src"

.. _zc.buildout: https://pypi.org/project/zc.buildout/

Known issues

  • One source tree path argument at the time can be passed to the command line utility.

  • Command line argument parsing is rather naïve.

View on GitHub
GitHub Stars7
CategoryDevelopment
Updated7mo ago
Forks1

Languages

Python

Security Score

62/100

Audited on Sep 3, 2025

No findings