autopatch 🛠️
autopatch is an intelligent Python dependency upgrade and breaking change migration tool. It detects public API breaking changes between package versions, scans your codebase to find where you use them, and suggests/applies patches automatically.
The Problem
When upgrading packages (e.g., pydantic from v1 to v2, or requests versions), developers face breaking changes:
- Functions or classes get removed.
- Method parameters are renamed or deleted.
- Mandatory arguments are added without defaults.
Currently, developers find these changes through runtime crashes, linters, or reading massive changelogs.
The Solution
autopatch automatically:
- Downloads and isolates target package versions from PyPI.
- Parses ASTs of both versions to extract and diff public interfaces.
- Scans your local codebase to locate usages of deleted or changed symbols.
- Generates and applies unified diff patches to automatically migrate your codebase (with optional LLM assistance).
Quick Start
Installation
Install autopatch from source:
pip install -e .
Basic Usage
To analyze upgrades for a specific package, specify the package name, the source version, and the target version:
# Scan current directory for breaking changes from package updates
autopatch package_name --from 1.10.0 --to 2.0.0
Auto-Patching
To generate and apply migration patches directly:
# Add --patch to generate and apply fixes (optionally uses OPENAI_API_KEY/GEMINI_API_KEY)
autopatch package_name --from 1.10.0 --to 2.0.0 --patch
Engineering Design
┌──────────────────┐
│ User Codebase │
└────────┬─────────┘
│ 1. Parse Imports
▼
┌─────────────┐ ┌──────────────────┐ ┌──────────────┐
│ PyPI API ├─────►│ Package Sources ├─────►│ AST Analyzer │
└─────────────┘ 2. └──────────────────┘ 3. └──────┬───────┘
Download │
▼
┌──────────────┐
│ API Diff │
└──────┬───────┘
│ 4. Detect Breaks
▼
┌─────────────┐ ┌──────────────────┐ ┌──────────────┐
│ Patch Apply │◄─────┤ Patch Generator │◄─────┤ Symbol Match │
└─────────────┘ 6. └──────────────────┘ 5. └──────────────┘
- AST Extraction:
autopatchuses standard Pythonast.NodeVisitorto traverse modules without importing or running the code, keeping the process fast and safe. - Diff Signature Validation: Standard signature matching checks positional, keyword-only, default values, and parameter existence.
- Intelligent LLM Patching: Integrates seamlessly with OpenAI/Gemini APIs to generate context-aware code refactoring.
Release files for depshift 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| depshift-0.1.0.tar.gz | 13.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| depshift-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 29.7 kB
Release files / depshift-0.1.0.tar.gz
| Download URL | depshift-0.1.0.tar.gz |
|---|---|
| Size | 13.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
657f766350abc659f85f637e19e324767317f137ebd35b2dc6ac1476c21f0901
|
|
BLAKE2b-256 checksum How to use checksums |
9fde27cf724428788bc4ef5cafe3aceb37c7b0b355eddfa1b9b818bde19e2946
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.1
|
Release files / depshift-0.1.0-py3-none-any.whl
| Download URL | depshift-0.1.0-py3-none-any.whl |
|---|---|
| Size | 16.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
64c8ab2962a3e6292773569e4327f4c63f4716a6ff7410a64971d5d62c3762d4
|
|
BLAKE2b-256 checksum How to use checksums |
b6e25a5fe02e210330423a724758c7cd4cad32a3895715ff7a2604abf8ef9f60
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.1
|