Metadata-Version: 2.4
Name: python_code_changed
Version: 0.3.1
Summary: A Python project to detect real code changes.
Author-email: Dean Godfree <deangodfree@outlook.com>
License: MIT License
        
        Copyright (c) 2025 DeanGodfreeItalia
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/DeanGodfreeItalia/python_code_changed
Project-URL: Repository, https://github.com/DeanGodfreeItalia/python_code_changed
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: typer>=0.16.0
Provides-Extra: dev
Requires-Dist: ruff>=0.4.4; extra == "dev"
Requires-Dist: black>=24.4.0; extra == "dev"
Requires-Dist: pytest>=8.4.1; extra == "dev"
Requires-Dist: typer>=0.16.0; extra == "dev"
Requires-Dist: isort>=5.13.2; extra == "dev"
Requires-Dist: pip-audit>=2.7.2; extra == "dev"
Requires-Dist: pytest-cov>=5.0.0; extra == "dev"
Requires-Dist: mypy>=1.10.0; extra == "dev"
Requires-Dist: hatch>=1.9.0; extra == "dev"
Requires-Dist: toml-cli>=0.8.1; extra == "dev"
Dynamic: license-file


# python_code_changed



![CI](https://github.com/DeanGodfreeItalia/python_code_changed/actions/workflows/ci.yml/badge.svg)
![PyPI](https://img.shields.io/pypi/v/python_code_changed)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
![Coverage](./coverage.svg)

![Black](https://img.shields.io/badge/code%20style-black-000000.svg)
![isort](https://img.shields.io/badge/imports-isort-ef8336.svg)
![mypy](https://img.shields.io/badge/type%20checker-mypy-blue.svg)
![pip-audit](https://img.shields.io/badge/security-pip--audit-yellow)


## Overview
`python_code_changed` is a tool to detect real logic changes in Python code, ignoring trivial changes like formatting, comments, import reordering, and unreachable code. It is designed for code review automation and CI pipelines.

#### PIP Package Usage

After installing via PIP, run:

```sh
python-code-changed [FILES or OPTIONS]
```

For example, to check for real code changes in staged files:

```sh
python-code-changed --staged
```

See all options:

```sh
python-code-changed --help
```

## Project Structure

```
python_code_changed/
├── src/
│   ├── ast_utils.py
│   ├── detect_real_code_changes.py
│   ├── helpers_logic.py
│   └── helpers_trivial.py
├── tests/
│   └── test_detect_real_code_changes.py
├── .github/
│   └── workflows/
│       └── ci.yml
├── .devcontainer/
│   └── devcontainer.json
├── pyproject.toml
├── requirements.txt
├── LICENSE
└── README.md
```

## Getting Started

### Development Environment
This project supports [Dev Containers](https://containers.dev/) for reproducible development. Open in VS Code and install the recommended extensions. NB. You will need to set your git user.name and git user.email on the devcontainer terminal after its loaded.
```sh
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
```


### Installation
Install dependencies using [uv](https://github.com/astral-sh/uv):

```sh
uv pip install -e .'[dev]'
```

### Configuration

`python_code_changed` uses an optional configuration file named `real_code_checks.ini` (located in the project root) to control analysis options and behavior. You can customise which checks are enabled, ignored, or how the tool treats certain code changes by editing this file. You can alternatively pass in command-line arguments when runnin the script.

See the comments in `real_code_checks.ini` for available options and usage examples.
### Usage

You can use `python_code_changed` as a CLI tool or as a Python library.

#### CLI Usage

After installing dependencies, run:

```sh
uv run python-code-changed [FILES or OPTIONS]
```

For example, to check for real code changes in staged files:

```sh
uv run python-code-changed --staged
```

See all options:

```sh
uv run python-code-changed --help
```

#### Library Usage

You can import and use the main functions in your own Python code:

```python
from python_code_changed import detect_real_code_changes
# Use detect_real_code_changes(...) as needed
```

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on contributing to this project.

## License

MIT License
