
Security News
Deno 2.4 Brings Back deno bundle, Improves Dependency Management and Observability
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
FindImports extracts Python module dependencies by parsing source files. It can report names that are imported but not used, and it can generate module import graphs in ASCII or graphviz formats.
A distinguishing feature of findimports used to be that it could parse doctest code inside docstrings.
Note that not all cases are handled correctly, especially if you use 'import foo.bar.baz'.
If you need to find unused imports in your codebase, I recommend Pyflakes_ instead -- it's better maintained and more reliable. For import graphs consider pydeps_.
.. _Pyflakes: https://pypi.org/project/pyflakes/ .. _pydeps: https://pypi.org/project/pydeps/
Home page: https://github.com/mgedmin/findimports
Licence: MIT (https://mit-license.org/)
|buildstatus|_ |appveyor|_ |coverage|_
.. |buildstatus| image:: https://github.com/mgedmin/findimports/actions/workflows/build.yml/badge.svg?branch=master .. _buildstatus: https://github.com/mgedmin/findimports/actions
.. |appveyor| image:: https://ci.appveyor.com/api/projects/status/github/mgedmin/findimports?branch=master&svg=true .. _appveyor: https://ci.appveyor.com/project/mgedmin/findimports
.. |coverage| image:: https://coveralls.io/repos/mgedmin/findimports/badge.svg?branch=master .. _coverage: https://coveralls.io/r/mgedmin/findimports
Drop support for Python 3.7.
Add --csv
/-C
output format: pull request 32 <https://github.com/mgedmin/findimports/pull/32>
_.
Add --search-import
/-s
command-line option to filter imports by
substring: pull request 33 <https://github.com/mgedmin/findimports/pull/33>
_.
Bugfix: findimports was treating all imports as relative, just like in the good old Python 2 days. Oops.
When reporting that it couldn't find the source for an imported module, findimports will now mention the line number that contained the import statement.
Fixed extension module detection that never worked on Python 3. See pull request 29 <https://github.com/mgedmin/findimports/pull/29>
_.
Add --attr
/-A
to add arbitrary graphviz graph attributes <https://graphviz.org/docs/graph/>
_ to the output. See pull request 30 <https://github.com/mgedmin/findimports/pull/30>
_.
Add support for Python 3.12.
Change license from GPL to MIT. See issue 27 <https://github.com/mgedmin/findimports/issues/27>
_.
Add --package-externals
/-pE
to simplify the module graph.
Add --rmprefix PREFIX
/-R PREFIX
to remove a package prefix from
displayed names.
Add --depth N
/-D N
to ignore import statements nested too deep in the
syntax tree (e.g. in functions or if statements).
Rewrote command-line parsing to use argparse. Options that select an action
(--imports
/--dot
/--names
/--unused
) now conflict instead of
all but the last one being ignored. See pull request #20 <https://github.com/mgedmin/findimports/pull/20>
_.
Add support for Python 3.11.
Drop support for Python 3.6.
Add support for Python 3.10.
Add --ignore-stdlib
flag to ignore modules from the Python standard
library.
--ignore
flag to ignore files and directories, it can be used multiple
times. See pull request #14 <https://github.com/mgedmin/findimports/pull/14>
_.Add support for Python 3.9.
Drop support for Python 3.5 and 2.7.
Fix a bug where the encoding of Python files was not determined in the
same way as by Python itself. See issue 15 <https://github.com/mgedmin/findimports/issues/15>
_. This requires
the use of tokenize.open
which is not in Python 2.7.
Add support for Python 3.8.
Fix a bug where a package/module with a name that is a prefix of another
package/module might accidentally be used instead of the other one (e.g. py
instead of pylab). See issue 10 <https://github.com/mgedmin/findimports/issues/10>
_.
Support Python 3.6 and 3.7.
Drop support for Python 2.6 and 3.3.
Suppress duplicate import warnings if the line in question has a comment.
getopt
with optparse
. This changes the --help
message as a side effect (#4 <https://github.com/mgedmin/findimports/issues/4>
_).Python 3 support (3.3 and newer).
Use ast
instead of compiler
(#1 <https://github.com/mgedmin/findimports/issues/1>
_).
Fix "cannot find datetime" on Ubuntu 14.04 LTS (#3 <https://github.com/mgedmin/findimports/issues/3>
_).
100% test coverage.
from .. import foo
).Moved to Github.
Drop Python 2.4 and 2.5 support.
Handle unicode docstrings with doctests.
sys.builtin_module_names
.
Fixes https://bugs.launchpad.net/findimports/+bug/880989.*.egg-info
files listed in
sys.path.Is able to find modules inside zip files (e.g. eggs).
Fixed deprecation warning on Python 2.6.
FAQs
Python module import analysis tool
We found that findimports demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.