py_code_improver


Namepy_code_improver JSON
Version 0.2.0 PyPI version JSON
download
home_pagehttps://github.com/polovinko1980/llm-code-cleaner
Summaryutility to suggest code refactoring
upload_time2024-12-08 18:54:02
maintainerAlex Polovinko
docs_urlNone
authorAlex Polovinko
requires_pythonNone
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Code Improver Tool

## Overview

The **Code Improver Tool** is a Python application that leverages OpenAI's language models to enhance code quality.

It can perform various actions such as cleaning code, adding docstrings, generating tests, and creating README files based on the provided source code.
This tool is designed for developers who want to automate the improvement of their codebases efficiently.

## Features

- **Code Cleaning**: Automatically refines the code for better readability and performance.
- **Docstring Generation**: Adds meaningful docstrings to functions and classes for improved documentation.
- **Test Generation**: Creates unit tests to ensure code reliability.
- **README Generation**: Generates a README file to provide an overview of the project.

## Requirements

- Python 3.11 or higher
- `langchain_core`
- `langchain_openai`
- Access to OpenAI API

## Installation

1. Clone the repository:
   ```bash
   git clone <repository-url>
   cd <repository-directory>
   ```

2. Install the required packages:
   ```bash
   pip3 install -r requirements.txt
   ```

3. Set your OpenAI API key in your environment variables:
   ```bash
   export OPEN_AI_API_KEY='your_openai_api_key'
   ```

## Usage

To use the Code Improver Tool, run the script from the command line with the required arguments:

```bash
python3 cli.py --file <path_to_your_code_file> --action <action_type>
```

### Arguments

- `--file` or `-f`: The path to the code file that you want to process (required).
- `--action` or `-a`: The action you want to perform. Options include:
  - `clean`: Clean the code.
  - `docstrings`: Add docstrings to the code.
  - `tests`: Generate tests for the code.
  - `readme`: Create a README file for the project.

### Example

To clean a Python file named `example.py`, you would run:

```bash
python3 cli.py --file example.py --action clean
```

### CLI

It is possible to install:

```bash
pip3 install py_code_improver

```

and run as cli:

```bash
py_code_improver --file example.py --action docstrings

poetry run py_code_improver --file example.py --action readme

```



## Output

The tool generates a new file with the same name as the input file, appended with a timestamp and the extension `.llm`. For example, if you process `example.py`, the output file will be named `example.py.llm<timestamp>`.

## Logging

The application logs its activities to the console. You can adjust the logging level in the code if you want more or less verbosity.

## Error Handling

The tool includes error handling for the following scenarios:
- If the specified file exceeds the character limit (9999 characters).
- If an unrecognized action is provided.

## Contributing

Contributions are welcome! Feel free to submit a pull request or open an issue for any bugs or feature requests.

## License

This project is licensed under the MIT License. See the LICENSE file for more details.

## Contact

For questions or feedback, please reach out to [alex.polovinko+git@gmail.com].

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/polovinko1980/llm-code-cleaner",
    "name": "py_code_improver",
    "maintainer": "Alex Polovinko",
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": "alex.polovinko@gmail.com",
    "keywords": null,
    "author": "Alex Polovinko",
    "author_email": "alex.polovinko@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/f2/a2/552a06eb10262cd5efa1847779fc9a56b9b150a71010d0a14a24c510e51e/py_code_improver-0.2.0.tar.gz",
    "platform": null,
    "description": "# Code Improver Tool\n\n## Overview\n\nThe **Code Improver Tool** is a Python application that leverages OpenAI's language models to enhance code quality.\n\nIt can perform various actions such as cleaning code, adding docstrings, generating tests, and creating README files based on the provided source code.\nThis tool is designed for developers who want to automate the improvement of their codebases efficiently.\n\n## Features\n\n- **Code Cleaning**: Automatically refines the code for better readability and performance.\n- **Docstring Generation**: Adds meaningful docstrings to functions and classes for improved documentation.\n- **Test Generation**: Creates unit tests to ensure code reliability.\n- **README Generation**: Generates a README file to provide an overview of the project.\n\n## Requirements\n\n- Python 3.11 or higher\n- `langchain_core`\n- `langchain_openai`\n- Access to OpenAI API\n\n## Installation\n\n1. Clone the repository:\n   ```bash\n   git clone <repository-url>\n   cd <repository-directory>\n   ```\n\n2. Install the required packages:\n   ```bash\n   pip3 install -r requirements.txt\n   ```\n\n3. Set your OpenAI API key in your environment variables:\n   ```bash\n   export OPEN_AI_API_KEY='your_openai_api_key'\n   ```\n\n## Usage\n\nTo use the Code Improver Tool, run the script from the command line with the required arguments:\n\n```bash\npython3 cli.py --file <path_to_your_code_file> --action <action_type>\n```\n\n### Arguments\n\n- `--file` or `-f`: The path to the code file that you want to process (required).\n- `--action` or `-a`: The action you want to perform. Options include:\n  - `clean`: Clean the code.\n  - `docstrings`: Add docstrings to the code.\n  - `tests`: Generate tests for the code.\n  - `readme`: Create a README file for the project.\n\n### Example\n\nTo clean a Python file named `example.py`, you would run:\n\n```bash\npython3 cli.py --file example.py --action clean\n```\n\n### CLI\n\nIt is possible to install:\n\n```bash\npip3 install py_code_improver\n\n```\n\nand run as cli:\n\n```bash\npy_code_improver --file example.py --action docstrings\n\npoetry run py_code_improver --file example.py --action readme\n\n```\n\n\n\n## Output\n\nThe tool generates a new file with the same name as the input file, appended with a timestamp and the extension `.llm`. For example, if you process `example.py`, the output file will be named `example.py.llm<timestamp>`.\n\n## Logging\n\nThe application logs its activities to the console. You can adjust the logging level in the code if you want more or less verbosity.\n\n## Error Handling\n\nThe tool includes error handling for the following scenarios:\n- If the specified file exceeds the character limit (9999 characters).\n- If an unrecognized action is provided.\n\n## Contributing\n\nContributions are welcome! Feel free to submit a pull request or open an issue for any bugs or feature requests.\n\n## License\n\nThis project is licensed under the MIT License. See the LICENSE file for more details.\n\n## Contact\n\nFor questions or feedback, please reach out to [alex.polovinko+git@gmail.com].\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "utility to suggest code refactoring",
    "version": "0.2.0",
    "project_urls": {
        "Homepage": "https://github.com/polovinko1980/llm-code-cleaner",
        "Repository": "https://github.com/polovinko1980/llm-code-cleaner"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1e7aa47fc4c00e45ccb2aa97883986d21d933106f382589c63124d14f3c82f49",
                "md5": "3f81ed427ebc6e0b950e08df90204393",
                "sha256": "bbea13ad80623313d61d720535bced907b04042e94776a5b473ca6353bc569f5"
            },
            "downloads": -1,
            "filename": "py_code_improver-0.2.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3f81ed427ebc6e0b950e08df90204393",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 9720,
            "upload_time": "2024-12-08T18:54:00",
            "upload_time_iso_8601": "2024-12-08T18:54:00.992348Z",
            "url": "https://files.pythonhosted.org/packages/1e/7a/a47fc4c00e45ccb2aa97883986d21d933106f382589c63124d14f3c82f49/py_code_improver-0.2.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f2a2552a06eb10262cd5efa1847779fc9a56b9b150a71010d0a14a24c510e51e",
                "md5": "835bb27d1412de0b26bb61e361e81e83",
                "sha256": "c810204177df1435e9efce9348eb2063c75e1c20d043e6c1d2025c6421baf50d"
            },
            "downloads": -1,
            "filename": "py_code_improver-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "835bb27d1412de0b26bb61e361e81e83",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 9159,
            "upload_time": "2024-12-08T18:54:02",
            "upload_time_iso_8601": "2024-12-08T18:54:02.564168Z",
            "url": "https://files.pythonhosted.org/packages/f2/a2/552a06eb10262cd5efa1847779fc9a56b9b150a71010d0a14a24c510e51e/py_code_improver-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-08 18:54:02",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "polovinko1980",
    "github_project": "llm-code-cleaner",
    "github_not_found": true,
    "lcname": "py_code_improver"
}
        
Elapsed time: 0.37546s