Scan Python class inheritance relationships and render them as readable maps.
Project description
classmap-hanthink
classmap-hanthink is a small Python developer tool that scans Python files and shows class inheritance relationships as a readable tree.
Simple explanation:
It helps you see which class is the parent and which classes are children.
Technical explanation:
It parses Python source code with the standard
astmodule, extracts class definitions and base classes, builds a parent-to-child inheritance map, and renders the result as a text tree.
Installation
pip install classmap-hanthink
CLI Usage
Scan the current folder:
classmap .
Scan a specific file:
classmap examples/sample_classes.py
Show explanation text:
classmap . --explain
Show Mermaid class diagram output:
classmap . --mermaid
Python Usage
from classmap_hanthink import scan_path, build_inheritance_map, render_text_tree
classes = scan_path("examples/sample_classes.py")
tree = build_inheritance_map(classes)
print(render_text_tree(classes, tree))
Example Output
classmap report
Target: examples/sample_classes.py
Classes found: 6
Inheritance Tree
Animal [examples/sample_classes.py:1]
├── Cat [examples/sample_classes.py:13]
└── Dog [examples/sample_classes.py:5]
└── Puppy [examples/sample_classes.py:9]
Independent Classes
- Config [examples/sample_classes.py:17]
- ExternalChild [examples/sample_classes.py:21]
Development
uv sync --group dev
uv run pytest tests/ -v
uv build
Release Roadmap
v0.1.0
- Scan Python files and folders
- Extract class names, base classes, file paths, and line numbers
- Build parent-to-child inheritance relationships
- Render text tree output
- Render optional explanation output
- Render optional Mermaid classDiagram output
- Provide CLI command:
classmap
External Base Classes
Use --show-external to show classes that inherit from external or built-in base classes.
classmap examples/sample_classes.py --show-external
Example output:
External Base Classes
dict
└── ExternalChild [examples/sample_classes.py:21]
Project details
Release history Release notifications | RSS feed
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 classmap_hanthink-0.2.0.tar.gz.
File metadata
- Download URL: classmap_hanthink-0.2.0.tar.gz
- Upload date:
- Size: 13.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2f1c3e7faa7d8a4ef650526e9ac061474718b0dbfcd39fa591619f147a63ba0
|
|
| MD5 |
e06216faa3dce1591b5b43dec718762f
|
|
| BLAKE2b-256 |
9a9614aa3ff10338250366954b2f0bc545b8e36096907683b1dafced1c3b377f
|
File details
Details for the file classmap_hanthink-0.2.0-py3-none-any.whl.
File metadata
- Download URL: classmap_hanthink-0.2.0-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f81b6337a19df2f8f2a892106d4a45b4e8096df69e5523c1e3033cee8420229b
|
|
| MD5 |
a96a5121f6eadd7be4ef349cc934124f
|
|
| BLAKE2b-256 |
40e896504c77fca68adb88be5984566304e09e277c11e897ade077050c2b1cd1
|