A Python project to detect real code changes.
Project description
python_code_changed
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:
python-code-changed [FILES or OPTIONS]
For example, to check for real code changes in staged files:
python-code-changed --staged
See all options:
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 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.
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
Installation
Install dependencies using uv:
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:
uv run python-code-changed [FILES or OPTIONS]
For example, to check for real code changes in staged files:
uv run python-code-changed --staged
See all options:
uv run python-code-changed --help
Library Usage
You can import and use the main functions in your own Python code:
from python_code_changed import detect_real_code_changes
# Use detect_real_code_changes(...) as needed
Contributing
See CONTRIBUTING.md for guidelines on contributing to this project.
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_code_changed-0.4.0.tar.gz.
File metadata
- Download URL: python_code_changed-0.4.0.tar.gz
- Upload date:
- Size: 18.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2201d5cd0f60967ca07c9b891b59f07fab7482712e76e76c4b44c03a55190db8
|
|
| MD5 |
33e67a34a7ad8d1f2a9f7757eba1fa88
|
|
| BLAKE2b-256 |
0b36282043cf6c7b8a8f67442744553d5859b8f185caaa309a3957183b31c4dc
|
Provenance
The following attestation bundles were made for python_code_changed-0.4.0.tar.gz:
Publisher:
publish.yml on DeanGodfreeItalia/python_code_changed
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
python_code_changed-0.4.0.tar.gz -
Subject digest:
2201d5cd0f60967ca07c9b891b59f07fab7482712e76e76c4b44c03a55190db8 - Sigstore transparency entry: 385381855
- Sigstore integration time:
-
Permalink:
DeanGodfreeItalia/python_code_changed@91bd2f4abf4c4bb7d93c03c50217f1e1b367b665 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/DeanGodfreeItalia
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@91bd2f4abf4c4bb7d93c03c50217f1e1b367b665 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file python_code_changed-0.4.0-py3-none-any.whl.
File metadata
- Download URL: python_code_changed-0.4.0-py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35f45ee80fc7e9096c2fd43a9a87e6fcb1d917e78a1fc8de7ffa130d67aeddaf
|
|
| MD5 |
f2845320fcafd7783e9f9598ca09e6b8
|
|
| BLAKE2b-256 |
87aa77b038fff6d7e91a588209d139998643dec0841a3b1aeabd9d97b9fa2d60
|
Provenance
The following attestation bundles were made for python_code_changed-0.4.0-py3-none-any.whl:
Publisher:
publish.yml on DeanGodfreeItalia/python_code_changed
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
python_code_changed-0.4.0-py3-none-any.whl -
Subject digest:
35f45ee80fc7e9096c2fd43a9a87e6fcb1d917e78a1fc8de7ffa130d67aeddaf - Sigstore transparency entry: 385381877
- Sigstore integration time:
-
Permalink:
DeanGodfreeItalia/python_code_changed@91bd2f4abf4c4bb7d93c03c50217f1e1b367b665 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/DeanGodfreeItalia
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@91bd2f4abf4c4bb7d93c03c50217f1e1b367b665 -
Trigger Event:
workflow_dispatch
-
Statement type: