Skip to main content

A Python library for detecting logical and syntactical errors in Python code

Project description

Code Error Detector

A Python library for detecting logical and syntactical errors in Python code.

Features

  • Syntax error detection and analysis
  • Logical error detection using pattern-based and machine learning approaches
  • Command-line interface for analyzing Python files
  • Training capabilities for custom error detection models

Installation

# Install from source
git clone https://github.com/Preksha-7/pybughunt.git
cd pybughunt
pip install -e .

Usage

Command Line

# Analyze Python files
pybughunt analyze file1.py file2.py

# Analyze with custom model
pybughunt analyze file1.py --model path/to/model.pkl

# Output in JSON format
pybughunt analyze file1.py --format json --output results.json

# Train a new model
pybughunt train --dataset path/to/dataset --output path/to/model.pkl

Python API

from pybughunt import CodeErrorDetector

# Initialize the detector
detector = CodeErrorDetector()

# Analyze code
code = '''
def example():
    print("Hello, world!"
'''
results = detector.analyze(code)

# Get fix suggestions
if results["syntax_errors"] or results["logic_errors"]:
    errors = results["syntax_errors"] + results["logic_errors"]
    suggestions = detector.fix_suggestions(code, results)
    for error_key, suggestion in suggestions.items():
        print(f"Suggestion for {error_key}: {suggestion}")

Supported Error Types

Syntax Errors

  • Missing parentheses, brackets, or braces
  • Indentation errors
  • Invalid syntax
  • Unterminated string literals

Logical Errors

  • Infinite loops (while True without break)
  • Unused variables
  • Potential off-by-one errors
  • Division by zero
  • Unreachable code

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

pybughunt-0.1.1.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

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

pybughunt-0.1.1-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file pybughunt-0.1.1.tar.gz.

File metadata

  • Download URL: pybughunt-0.1.1.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for pybughunt-0.1.1.tar.gz
Algorithm Hash digest
SHA256 195429d3f6a4a81b8c66131a1163ed599624d87f3c3f95694b65c8b5d9ac317a
MD5 3cabaaeee30d5017c79dd4e1c9cab25c
BLAKE2b-256 628ffa91c5e3b900397c95fbd7792faff70b528625df32f126c59e211dd1f6dd

See more details on using hashes here.

File details

Details for the file pybughunt-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pybughunt-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for pybughunt-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 784b2117dde1843be110f6327b43cb418973ff15c833939b5a82846469667485
MD5 f6ed0c4080a32778a7b62b4ca783028c
BLAKE2b-256 1487b92046901f95e6e254654ba0b2014d74b67bd409c78468e300405a24bed7

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