Skip to main content

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 ast module, 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

classmap_hanthink-0.2.0.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

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

classmap_hanthink-0.2.0-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

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

Hashes for classmap_hanthink-0.2.0.tar.gz
Algorithm Hash digest
SHA256 e2f1c3e7faa7d8a4ef650526e9ac061474718b0dbfcd39fa591619f147a63ba0
MD5 e06216faa3dce1591b5b43dec718762f
BLAKE2b-256 9a9614aa3ff10338250366954b2f0bc545b8e36096907683b1dafced1c3b377f

See more details on using hashes here.

File details

Details for the file classmap_hanthink-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for classmap_hanthink-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f81b6337a19df2f8f2a892106d4a45b4e8096df69e5523c1e3033cee8420229b
MD5 a96a5121f6eadd7be4ef349cc934124f
BLAKE2b-256 40e896504c77fca68adb88be5984566304e09e277c11e897ade077050c2b1cd1

See more details on using hashes here.

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