Advanced Python import diagnostic tool with deep analysis, subprocess isolation, auto-fixing suggestions, and CI-ready enforcement.
Project description
importdoc
Advanced Import Diagnostic Tool for Python
Deep, automated import analysis for Python projects — with subprocess-safe imports, circular dependency detection, auto-fix suggestions, AST-based symbol resolution, and CI-ready JSON output.
🚀 Features
| Capability | Description |
|---|---|
| 🔍 Import graph discovery | Recursively maps and validates imports across a project |
| 🧠 AST-based analysis | Detects missing imports, wrong module paths, and unresolved symbols |
| ⚡ Subprocess safe imports | Imports each module in a sandboxed subprocess (timeout safe) |
| 🛑 Circular import detection | Identifies dependency cycles with stack traces |
| 🛠️ Automated fix suggestions | Suggest proper import paths + generate JSON patches |
| 📊 JSON diagnostic mode | CI-friendly structured reports |
| 📦 Cache & telemetry | Optional cache + performance metrics |
| 🛡️ Safe mode | Avoids dangerous imports outside venv by default |
| 📈 Graph export | DOT dependency graph generation (Graphviz) |
📦 Installation
PyPI
pip install importdoc
Development (editable)
pip uninstall importdoc -y
pip install -e .
---
🔧 CLI Usage
Basic usage
importdoc your_package
Running in a project dir
importdoc your_package --dir .
Allow root (CI / Docker)
importdoc your_package --allow-root
Enable full diagnostics
importdoc your_package --verbose --enable-cache --enable-telemetry
JSON output (CI pipelines)
importdoc your_package --json > import_report.json
Auto-fix suggestions
importdoc your_package --generate-fixes --fix-output fixes.json
Dependency graph (Graphviz)
importdoc your_package --graph --dot-file imports.dot
dot -Tpng imports.dot -o graph.png
---
🧪 Example Output (Success)
🎉 ALL MODULES IMPORTED SUCCESSFULLY!
✨ Production-ready: No import issues detected
🚨 Example Output (Import Error)
🚨 FAILED TO IMPORT: myapp.models.user
🔥 ROOT CAUSE: ImportError: cannot import name 'Profile' from 'myapp.profile'
📊 Evidence:
- myapp/profile.py:15: class Profile
💡 Suggested Fixes:
1. from myapp.profile import Profile
🧠 Confidence: 9/10
---
⚙️ Options Summary
Flag Purpose
--continue-on-error Never stop on failures
--parallel N Parallel subprocess imports
--json JSON report mode
--graph Create DOT graph
--no-safe-mode Allow global environment imports
--enable-cache Speed up repeated runs
--dev-trace Debug import chain tracing
Run full help:
importdoc --help
---
🛡️ CI/CD Usage
GitHub Actions
- name: Run import diagnostics
run: importdoc mypkg --json --continue-on-error > import_report.json
---
🧠 When to Use importdoc
Situation importdoc saves you
❓ Random import failures ✅ Pinpoints real source
🔁 Circular imports ✅ Finds cycles with stack trace
⚙️ Large refactors ✅ Detects broken import paths
🤖 CI safety ✅ Reports without executing package runtime logic
📦 Package release testing ✅ Ensures import reliability
---
🧩 Project Structure Example
yourproject/
├─ src/
│ └─ yourpackage/
│ ├─ __init__.py
│ ├─ ...
└─ tests/
Run:
importdoc yourpackage --dir ./src
---
🤝 Contributing
PRs & issues welcome!
---
📄 License
MIT © 2025
---
⭐ Support
If you find this tool useful:
pip install importdoc
And give the repo a ⭐ on GitHub!
https://github.com/dhruv13x/importdoc
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file importdoc-3.0.1.tar.gz.
File metadata
- Download URL: importdoc-3.0.1.tar.gz
- Upload date:
- Size: 42.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7fe02cab1c9b5c3f8f01d52b4b6c215b16767fee0f577b80cbade090776efb16
|
|
| MD5 |
aa022e07bf5e6ea00fd29dab4f740cbc
|
|
| BLAKE2b-256 |
480e56d4faeb3ad8adb350eb11e1f711447901fbe4e8f4974f0e95ea07e3b736
|
Provenance
The following attestation bundles were made for importdoc-3.0.1.tar.gz:
Publisher:
publish.yml on dhruv13x/importdoc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
importdoc-3.0.1.tar.gz -
Subject digest:
7fe02cab1c9b5c3f8f01d52b4b6c215b16767fee0f577b80cbade090776efb16 - Sigstore transparency entry: 720835061
- Sigstore integration time:
-
Permalink:
dhruv13x/importdoc@18ffc3778dbc2da5fe9942af03425b0cd36fdee3 -
Branch / Tag:
refs/tags/v3.0.1 - Owner: https://github.com/dhruv13x
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@18ffc3778dbc2da5fe9942af03425b0cd36fdee3 -
Trigger Event:
push
-
Statement type:
File details
Details for the file importdoc-3.0.1-py3-none-any.whl.
File metadata
- Download URL: importdoc-3.0.1-py3-none-any.whl
- Upload date:
- Size: 31.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
91ba077da38fa3ad2cf12ae96ef422cd6aac411593e50afa8acc3530b769e006
|
|
| MD5 |
ab17f643c9a8180c73e5f69ffaae44b4
|
|
| BLAKE2b-256 |
dfea01942783090956642deeaab9b153c77087b480c72dd8f73beb5eff2a7e03
|
Provenance
The following attestation bundles were made for importdoc-3.0.1-py3-none-any.whl:
Publisher:
publish.yml on dhruv13x/importdoc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
importdoc-3.0.1-py3-none-any.whl -
Subject digest:
91ba077da38fa3ad2cf12ae96ef422cd6aac411593e50afa8acc3530b769e006 - Sigstore transparency entry: 720835065
- Sigstore integration time:
-
Permalink:
dhruv13x/importdoc@18ffc3778dbc2da5fe9942af03425b0cd36fdee3 -
Branch / Tag:
refs/tags/v3.0.1 - Owner: https://github.com/dhruv13x
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@18ffc3778dbc2da5fe9942af03425b0cd36fdee3 -
Trigger Event:
push
-
Statement type: