Skip to main content

X-ray your Python project: import graph + stub maturity metrics + Graphviz viz + CLI

Project description

CodeClinic (codeclinic)

Diagnose your Python project: import dependencies → maturity metrics (stub ratio) → Graphviz visualization.

Install

pip install codeclinic
# or, from source (dev):
pip install -e .

Note: Rendering SVG/PNG requires the Graphviz system tool (dot) in your PATH. macOS: brew install graphviz; Ubuntu: sudo apt-get install graphviz.

Quick start

codeclinic --path ./src --out build/cc_graph --format svg

This prints a summary + adjacency list and writes:

  • build/cc_graph.dot (DOT source)
  • build/cc_graph.svg (rendered)

Marking stubs

from codeclinic import stub

@stub
def todo_api():
    pass

@stub will (1) mark the function for static counting and (2) emit a warnings.warn when it’s actually called.

Config

You can keep settings in pyproject.toml under [tool.codeclinic] or in a codeclinic.toml file:

[tool.codeclinic]
paths = ["src"]
include = ["**/*.py"]
exclude = ["**/tests/**", "**/.venv/**"]
aggregate = "package"     # "module" | "package"
format = "svg"            # svg | png | pdf | dot
output = "build/cc_graph"
count_private = false

CLI flags override config.

CLI

codeclinic --path PATH [--out OUTPUT_BASE] [--format svg|png|pdf|dot] [--aggregate module|package]

How it works

  • Parses your code with ast (no import-time side effects).
  • Builds an internal import graph (absolute & relative imports resolved).
  • Counts public functions/methods and @stub-decorated ones to compute a stub ratio per node.
  • Renders a Graphviz graph with node colors by ratio (green→yellow→red).

Roadmap

  • Smell detectors (circulars, forbidden deps, god packages, layer rules).
  • HTML/PDF report with dashboards.
  • Plugin entry points: codeclinic.detector.

License

MIT

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

codeclinic-0.1.0.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

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

codeclinic-0.1.0-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: codeclinic-0.1.0.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for codeclinic-0.1.0.tar.gz
Algorithm Hash digest
SHA256 559999a0c4691aa97f22f2d8b11308dbb920d6da88ebd0fa846f22c48c04c0a7
MD5 5322a577439f22782b79f019e9ac1def
BLAKE2b-256 ca9db14d6ec2d9a055ee5691d23cc7bfe51c891dfc3b0362f0be728238cd3724

See more details on using hashes here.

File details

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

File metadata

  • Download URL: codeclinic-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for codeclinic-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ff62dbfec6088a586a29d0297507d24f9df1bf26888c4af4647c6a23da299067
MD5 6027c20413ee955273e55ea50f4d9a34
BLAKE2b-256 417241263b39289bf1eb409160dfc9f66497973cc6d4c91da5638cb36dcce352

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