Skip to main content

Python import health scanner

Project description

py-import-checker

PyPI Downloads PyPI version Tests License: MIT Python 3.10+

A zero-dependency Python tool that scans a project and reports broken imports.

It loads Python files using the standard library and reports import failures before they reach runtime.

Features

  • Zero dependencies (Python standard library only)
  • Supports src/ layouts with --src
  • Reports ImportError and ModuleNotFoundError
  • Ignores runtime errors raised during module execution
  • Skips virtual environments and build directories
  • Works in CI with meaningful exit codes

Installation

pip install py-import-checker

Usage

py-import-checker
py-import-checker path/to/project
py-import-checker . --src src/
py-import-checker . --src src/ --src lib/
py-import-checker . --glob "app/**/*.py"
py-import-checker . --verbose

Python API

from pathlib import Path

from py_import_checker.checker import check_directory

result = check_directory(
    Path("src"),
    extra_paths=[Path("src")],
)

if not result.success:
    for error in result.errors:
        print(error.file, error.message)

Pre-commit

repos:
  - repo: https://github.com/matthieugraziani/py-import-checker
    rev: v0.2.4
    hooks:
      - id: py-import-checker
        args: [--src, src/]

Development

pip install hatch
hatch env create
hatch run test
hatch run lint
hatch run type-check

License

MIT

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

py_import_checker-0.2.4.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

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

py_import_checker-0.2.4-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file py_import_checker-0.2.4.tar.gz.

File metadata

  • Download URL: py_import_checker-0.2.4.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for py_import_checker-0.2.4.tar.gz
Algorithm Hash digest
SHA256 74bef1e19446d7cfeb1bf349e189f054bc548f0ef09880ecdab264421a9badd7
MD5 bd6e57fcd49a7225cfb2eee965809698
BLAKE2b-256 998df3c1c4f045d19180c4cf837b5c1706fb01e9bf66d43875da4cbd2a73b54c

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_import_checker-0.2.4.tar.gz:

Publisher: publish.yml on matthieugraziani/py-import-checker

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

File details

Details for the file py_import_checker-0.2.4-py3-none-any.whl.

File metadata

File hashes

Hashes for py_import_checker-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 17ad5f7190312f017808f739a01c0cf806bdab63b23111858e0e88cd95709bca
MD5 eac40c84de3aff9d2310dd44879f45b8
BLAKE2b-256 257587f61ae8fdf7d85d2ff46fc628e7c1c6435ffaf4b4b721a2295931a0add5

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_import_checker-0.2.4-py3-none-any.whl:

Publisher: publish.yml on matthieugraziani/py-import-checker

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