Skip to main content

Command line interface for analyzing Python imports.

Project description

https://img.shields.io/pypi/v/impulse.svg Python versions https://github.com/seddonym/impulse/actions/workflows/main.yml/badge.svg https://img.shields.io/badge/License-BSD_2--Clause-orange.svg

Impulse is a command line tool for exploring the imports in a Python package.

Running it will open up the graph in a browser window, along with download links for SVG and PNG.

Screenshot

Graph of django.db.

Installation

  1. Install Impulse using your favorite Python package manager. E.g., with pip:

    pip install impulse

2. Ensure the package under test is importable, e.g. by changing your working directory to the one containing the package, or installing it via a Python package manager.

One liner using uv tool

If you use uv you can run it with this one-liner, without needing to install anything.

uv tool run --with=PACKAGE impulse drawgraph MODULE_NAME

Command overview

There is currently only one command.

drawgraph

Usage: impulse drawgraph [OPTIONS] MODULE_NAME

Options:
  --show-import-totals   Label arrows with the number of imports they
                         represent.
  --show-cycle-breakers  Identify a set of dependencies that, if removed,
                         would make the graph acyclic, and display them as
                         dashed lines.
  --help                 Show this message and exit.

Draw a graph of the dependencies within any installed Python package or subpackage.

The graph shows the relationship between all the immediate children of the package. An arrow indicates that there is at least one import by the child (or any of its descendants) from the subpackage where the arrow points.

The graph visualization is opened in a browser.

Example

impulse drawgraph django.db
Graph of django.db package.

In this example, there is an arrow from .models to .utils. This is because (along with one other import) django.db.models.constraints imports django.db.utils.DEFAULT_DB_ALIAS.

Example with import totals

impulse drawgraph django.db --show-import-totals
Graph of django.db package with import totals.

Here you can see that there are two imports from modules within django.db.models of modules within django.db.utils.

Example with cycle breakers

impulse drawgraph django.db --show-cycle-breakers
Graph of django.db package with cycle breakers.

Here you can see that two of the dependencies are shown as a dashed line. If these dependencies were to be removed, the graph would be acyclic. To decide on the cycle breakers, Impulse uses the nominate_cycle_breakers method provided by Grimp.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

impulse-2.2.tar.gz (209.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

impulse-2.2-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file impulse-2.2.tar.gz.

File metadata

  • Download URL: impulse-2.2.tar.gz
  • Upload date:
  • Size: 209.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for impulse-2.2.tar.gz
Algorithm Hash digest
SHA256 0a187ec357b870ba813d6a59bd1ca10ea41b2671300f75fe33da02d53619be9c
MD5 a8300b3972d8481b4600828481edf659
BLAKE2b-256 b138081074e503675159250c0d1c2aa4991f67fc4cdc19c3d498ac658e850955

See more details on using hashes here.

Provenance

The following attestation bundles were made for impulse-2.2.tar.gz:

Publisher: release.yml on seddonym/impulse

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file impulse-2.2-py3-none-any.whl.

File metadata

  • Download URL: impulse-2.2-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for impulse-2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c8e2a9367254d73b9363e73076e090bcfb4209876fe5475ce814805ddd0916f3
MD5 ce4583961c4830c1de7d78b751f7c673
BLAKE2b-256 ea9d9936ec79fe890befe9dc82cb98c4be72742e16a8f8f55107de5f8a7075af

See more details on using hashes here.

Provenance

The following attestation bundles were made for impulse-2.2-py3-none-any.whl:

Publisher: release.yml on seddonym/impulse

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page