Intelligent Python dependency upgrade and auto-migration tool
Project description
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.
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 depshift-0.1.0.tar.gz.
File metadata
- Download URL: depshift-0.1.0.tar.gz
- Upload date:
- Size: 13.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
657f766350abc659f85f637e19e324767317f137ebd35b2dc6ac1476c21f0901
|
|
| MD5 |
54dfaf96afedf6a4010d77f64a1c343a
|
|
| BLAKE2b-256 |
9fde27cf724428788bc4ef5cafe3aceb37c7b0b355eddfa1b9b818bde19e2946
|
File details
Details for the file depshift-0.1.0-py3-none-any.whl.
File metadata
- Download URL: depshift-0.1.0-py3-none-any.whl
- Upload date:
- Size: 16.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64c8ab2962a3e6292773569e4327f4c63f4716a6ff7410a64971d5d62c3762d4
|
|
| MD5 |
ac8872dce27903b785f69a5258b05e81
|
|
| BLAKE2b-256 |
b6e25a5fe02e210330423a724758c7cd4cad32a3895715ff7a2604abf8ef9f60
|