Skip to main content

A package for finding the list of errors in a code compared to the expected code

Project description

AST ERROR DETECTION

Overview

ast-error-detection is a Python library designed for analyzing and annotating algorithmic errors in code. It leverages the Abstract Syntax Tree (AST) module from Python's standard library to identify, categorize, and contextualize errors. The output of the library is a list of errors, where each error is a dictionary describing the issue and its context.

This library is under an ongoing scientific study. If you use it for academic purposes, please cite the forthcoming publication (details will be provided).


Features

  • Parses and processes Python code using the AST module.
  • Identifies and categorizes errors with detailed contextual information.
  • Provides actionable insights for debugging.

Installation

Install the package via pip:

pip install ast_error_detection

Usage

Here’s a basic example of how to use the library:

from ast-error-detection import get_code_errors

# Example erroneous code to analyze
code_1 = """ 
# Code snippet here
"""
# Example expected code
code_2 = """ 
# Code snippet here
"""

# Convert AST to custom node representation
result = get_code_errors(code_1, code_2)

# Print the results
print(result)

Output Format

The output is always a list of errors. Each error is a dictionary structured as follows:

  • For delete or insert errors (3 elements):

    • error: Description of the error.
    • value: The value to delete or insert.
    • context: Contextual location of the error (see below).
  • For update errors (4 elements):

    • error: Description of the error.
    • old_value: The old value to update.
    • new_value: The new value to update.
    • context: Contextual location of the error.

Context Format

The context describes where the error occurred in the code execution hierarchy. For example:

Module > Function Name > For Loop > If > Condition

This indicates that the error is in the condition of an if statement inside a for loop within a function in the module.


Example

Input Code 1

print('Hello')

Input Code 2

print('Hello1')

Output

[('CONST_VALUE_MISMATCH', "Const: 'Hello'", "Const: 'Hello1'", "Module > Call: print > Const: 'Hello'")]

License

This project is licensed under the GNU Affero General Public License v3 (AGPL-3.0). If you wish to use this library for proprietary or commercial purposes, you must obtain a separate license.

Please contact Badmavasan [Lip6] at [badmavasan.kirouchenassamy@lip6.fr] for commercial licensing inquiries.


Scientific Publication

This library is part of an ongoing scientific study. If you use it for academic purposes, please cite the forthcoming publication:

[Publication details will be added here once available.]

Stay tuned for updates!

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

asterrdetection-0.2.tar.gz (29.5 kB view details)

Uploaded Source

Built Distribution

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

asterrdetection-0.2-py3-none-any.whl (33.3 kB view details)

Uploaded Python 3

File details

Details for the file asterrdetection-0.2.tar.gz.

File metadata

  • Download URL: asterrdetection-0.2.tar.gz
  • Upload date:
  • Size: 29.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.6

File hashes

Hashes for asterrdetection-0.2.tar.gz
Algorithm Hash digest
SHA256 7fa6cb7ac75848e332462fc1cb71eb18691e3b5d8b813a19b5fe4ae6f5fdab47
MD5 45ec4221586eff897dacd3ffdc792962
BLAKE2b-256 20e0fcc4eb55db3fc5d335c82afe7a9abb683b081fcab7cf11e0e846812f11ae

See more details on using hashes here.

File details

Details for the file asterrdetection-0.2-py3-none-any.whl.

File metadata

  • Download URL: asterrdetection-0.2-py3-none-any.whl
  • Upload date:
  • Size: 33.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.6

File hashes

Hashes for asterrdetection-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a4301914841bb985e07bf8dbefb555b97584af5dbc4eac43f944d9bdb4f116b0
MD5 f74d3ba1ff6b9c2ce369bfbd643d56c2
BLAKE2b-256 ebc029f43536160942ee177fe113ba2b150857f8667dbafc57edfc0bc1a3556b

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