Skip to main content

A Python project to detect real code changes.

Project description

python_code_changed

CI PyPI License: MIT Ruff Coverage

Black isort mypy pip-audit

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_code_changed-0.3.1.tar.gz (17.6 kB view details)

Uploaded Source

Built Distribution

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

python_code_changed-0.3.1-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file python_code_changed-0.3.1.tar.gz.

File metadata

  • Download URL: python_code_changed-0.3.1.tar.gz
  • Upload date:
  • Size: 17.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for python_code_changed-0.3.1.tar.gz
Algorithm Hash digest
SHA256 ef8a881163572b4672f08d11602d54994b7dd6761ea5fe710b7200489a47c7f6
MD5 13f179dd88bb10ca4e3f99960258bf26
BLAKE2b-256 d8343d7d2b995525baf8d911d8feda62f7c400c7f0a7a347cf533fcf3cd2173a

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_code_changed-0.3.1.tar.gz:

Publisher: publish.yml on DeanGodfreeItalia/python_code_changed

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file python_code_changed-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for python_code_changed-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 11b00014523b0a47414600dbccc63275b8371f7411059ee0fdaa715ff4c66587
MD5 f5b41baf4be71b59b640c9bff0082cd1
BLAKE2b-256 a0aa5ccfdc8b7bcf1f3388561b8dd7f7f113ca9fdaf880a1d4701d3d70151f7d

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_code_changed-0.3.1-py3-none-any.whl:

Publisher: publish.yml on DeanGodfreeItalia/python_code_changed

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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