py-import-checker
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
ImportErrorandModuleNotFoundError - Ignores runtime errors raised during module execution
- Skips virtual environments and build directories
- Works in CI with meaningful exit codes
- Auto-fix broken imports with
--fix(installs missing packages via pip) - Dry-run preview with
--dry-run(shows what would be installed, no side-effects)
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
Auto-fix
Install every missing package detected during the scan:
py-import-checker . --fix
Preview what would be installed without touching the environment:
py-import-checker . --dry-run
After a successful --fix, the tool re-scans automatically to confirm all imports are resolved.
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.5
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
Metadata
Release files for py-import-checker 0.2.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| py_import_checker-0.2.5.tar.gz | 7.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| py_import_checker-0.2.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.9 kB
Release files / py_import_checker-0.2.5.tar.gz
| Download URL | py_import_checker-0.2.5.tar.gz |
|---|---|
| Size | 7.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d5d88d448daa281650d84a783f6964fe2293d21b49bf55de642ec41e3afd7a3d
|
|
BLAKE2b-256 checksum How to use checksums |
af14639e71666f3a35066eb41ee42c584484ff6330867a597549f70ac427dbaa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 21, 2026.
Transparency logRelease files / py_import_checker-0.2.5-py3-none-any.whl
| Download URL | py_import_checker-0.2.5-py3-none-any.whl |
|---|---|
| Size | 7.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e823c705fa5349702e67f027728ea3831e08b8cd1ce6e221b90cb16ce3ec541c
|
|
BLAKE2b-256 checksum How to use checksums |
c526c7c3c85eaed60069a4e0f93ffe60e4008867a6faf7422f6fb98e4d38695b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 21, 2026.
Transparency log