Skip to main content

Intelligent Python debugging library – explains errors, identifies root causes, and suggests fixes.

Project description

CodeMedic

Intelligent Python debugging library. Explains errors in plain English, identifies root causes, and suggests practical fixes.

Python 3.11+ License: MIT PyPI version Tests

Features

  • Human-friendly explanations – Beginner and professional modes
  • Root cause analysis – Pinpoints the exact file, line, and variable state
  • Fix suggestions – Non-destructive patch recommendations with confidence scores
  • Static analysis – 14 AST-based checks for common issues
  • Security scanning – Detects eval(), pickle, hardcoded secrets, weak hashes
  • Multiple report formats – HTML, JSON, Markdown
  • Terminal UI – Rich formatting with syntax highlighting
  • Extensible knowledge base – 40+ built-in exceptions, customizable

Installation

pip install codemedic

Requires Python 3.11+.

Usage

Command Line

Run a script with full error analysis:

codemedic run script.py

Analyze for static issues:

codemedic analyze script.py

Explain an exception:

codemedic explain TypeError

Show system diagnostics:

codemedic doctor

Generate report from a previous result:

codemedic report --format html --input result.json

Python API

Analyze a file:

from codemedic import Runner

runner = Runner(mode="beginner")
result = runner.run_file("script.py")

if not result.success:
    print(result.explanation["simple_explanation"])
    for fix in result.fixes:
        print(f"Line {fix.line_number}: {fix.description}")

Analyze a callable:

from codemedic import Runner

def process_data():
    return data["key"]

runner = Runner()
result = runner.run_with_capture(process_data)

if not result.success:
    print(result.trace.exception_type)

Generate reports:

from codemedic import Runner, ReportGenerator, Config

config = Config(output_folder="./reports")
runner = Runner(config=config)

result = runner.run_file("script.py")
if not result.success:
    gen = ReportGenerator(config)
    gen.generate(result.to_dict(), format="html")
    gen.generate(result.to_dict(), format="json")

Static analysis:

from codemedic import CodeAnalyzer

analyzer = CodeAnalyzer()
issues = analyzer.analyze_file("script.py")

for issue in issues:
    print(f"[{issue.severity}] Line {issue.line}: {issue.message}")

Security scanning:

from codemedic.security import check_file

warnings = check_file("script.py")
for w in warnings:
    print(f"[{w.code}] {w.message}: {w.recommendation}")

Architecture

  • runner.py – Script execution and exception capture
  • trace.py – Stack frame collection and structuring
  • explanations.py – Explanation generation
  • fixer.py – Patch suggestion generator
  • analyzer.py – Static analysis (AST-based checks)
  • security.py – Security scanning
  • database.py – SQLite knowledge base (40+ exceptions)
  • formatter.py – Terminal UI with Rich
  • report.py – HTML, JSON, Markdown report generation
  • cli.py – Command-line interface
  • config.py – Configuration management
  • utils.py – Shared utilities

Contributing

See CONTRIBUTING.md.

License

MIT. See LICENSE.

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

codemedic-1.0.0.tar.gz (54.6 kB view details)

Uploaded Source

Built Distribution

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

codemedic-1.0.0-py3-none-any.whl (47.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: codemedic-1.0.0.tar.gz
  • Upload date:
  • Size: 54.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for codemedic-1.0.0.tar.gz
Algorithm Hash digest
SHA256 7a9110d1848c4983827b00bf5797989cbd830656bfa9f06df3337d95597dc76e
MD5 790085463de7d502c22e2d4977947180
BLAKE2b-256 032ebf3c1300dcbd700d1b2e2049294dfde967127f093226490c7dde42d1a472

See more details on using hashes here.

File details

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

File metadata

  • Download URL: codemedic-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 47.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for codemedic-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 091664561610fe5201ddc0af6a3d1675eecd167cd10111fc093fa30bf404f937
MD5 215094405ba7978bee84dc6e6d3c843e
BLAKE2b-256 a0cad52db2383535914f243f0c9ec30efc4b4aeb424148bafe4f730a89029f51

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