Skip to main content

Advanced Python import diagnostic tool with deep analysis, subprocess isolation, auto-fixing suggestions, and CI-ready enforcement.

Project description

importdoc logo

PyPI version Python Wheel Release

Build status Codecov Test Coverage Code style: black Ruff Security

Downloads OS Python Versions

License: MIT

Docs

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

importdoc-1.0.0.tar.gz (25.6 kB view details)

Uploaded Source

Built Distribution

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

importdoc-1.0.0-py3-none-any.whl (26.2 kB view details)

Uploaded Python 3

File details

Details for the file importdoc-1.0.0.tar.gz.

File metadata

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

File hashes

Hashes for importdoc-1.0.0.tar.gz
Algorithm Hash digest
SHA256 6545d011740a592a226302db7bae5d825c7bdc976b2eed8ae47248696c8a79b3
MD5 ae641f6db35288e9659788bd72aa21e3
BLAKE2b-256 75bdcde3e2a1f1a61671c9cd0dd6fd3475bf7176c796a3c26fe41fb6eaf2162a

See more details on using hashes here.

Provenance

The following attestation bundles were made for importdoc-1.0.0.tar.gz:

Publisher: publish.yml on dhruv13x/importdoc

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

File details

Details for the file importdoc-1.0.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for importdoc-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 28f5756c1b02de8ed04c0dd998aa2f131b3192a4c8d535f942dc9f2899a6e426
MD5 8a97ef8d9cc3cb080fcf0a1589ebdc4d
BLAKE2b-256 5426042c2249ac924a0353cc63c6d70a3c25d7f33ae61debefe2e82ee2a02521

See more details on using hashes here.

Provenance

The following attestation bundles were made for importdoc-1.0.0-py3-none-any.whl:

Publisher: publish.yml on dhruv13x/importdoc

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