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

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.1.0.tar.gz (12.4 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.1.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file classmap_hanthink-0.1.0.tar.gz.

File metadata

  • Download URL: classmap_hanthink-0.1.0.tar.gz
  • Upload date:
  • Size: 12.4 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.1.0.tar.gz
Algorithm Hash digest
SHA256 7e2938bf05061b1a88b0affa8222fefe7fd2aa782ff1b7550d8ae2bde43cd9bd
MD5 642cc5a0653df403f6f5ccb701686e4a
BLAKE2b-256 da7811bcef00bdc83217cfb6ab154db1ca4190d52cd030a4f3337904cfc40592

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for classmap_hanthink-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0716c51e380d45b4352dd229fc9f9c6d4c2ff231b37542c90af6fb2bdcdcfbbe
MD5 91d513aa9f70017467b74291206fcc20
BLAKE2b-256 0b6088e328d84567c4402e248aa556e5c7a87324fb5253fc56a8330aae847fee

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