codeshift 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- codeshift-0.2.0/LICENSE +21 -0
- codeshift-0.2.0/PKG-INFO +326 -0
- codeshift-0.2.0/README.md +270 -0
- codeshift-0.2.0/codeshift/__init__.py +8 -0
- codeshift-0.2.0/codeshift/analyzer/__init__.py +5 -0
- codeshift-0.2.0/codeshift/analyzer/risk_assessor.py +388 -0
- codeshift-0.2.0/codeshift/api/__init__.py +1 -0
- codeshift-0.2.0/codeshift/api/auth.py +182 -0
- codeshift-0.2.0/codeshift/api/config.py +73 -0
- codeshift-0.2.0/codeshift/api/database.py +215 -0
- codeshift-0.2.0/codeshift/api/main.py +103 -0
- codeshift-0.2.0/codeshift/api/models/__init__.py +55 -0
- codeshift-0.2.0/codeshift/api/models/auth.py +108 -0
- codeshift-0.2.0/codeshift/api/models/billing.py +92 -0
- codeshift-0.2.0/codeshift/api/models/migrate.py +42 -0
- codeshift-0.2.0/codeshift/api/models/usage.py +116 -0
- codeshift-0.2.0/codeshift/api/routers/__init__.py +5 -0
- codeshift-0.2.0/codeshift/api/routers/auth.py +440 -0
- codeshift-0.2.0/codeshift/api/routers/billing.py +395 -0
- codeshift-0.2.0/codeshift/api/routers/migrate.py +304 -0
- codeshift-0.2.0/codeshift/api/routers/usage.py +291 -0
- codeshift-0.2.0/codeshift/api/routers/webhooks.py +289 -0
- codeshift-0.2.0/codeshift/cli/__init__.py +5 -0
- codeshift-0.2.0/codeshift/cli/commands/__init__.py +7 -0
- codeshift-0.2.0/codeshift/cli/commands/apply.py +352 -0
- codeshift-0.2.0/codeshift/cli/commands/auth.py +842 -0
- codeshift-0.2.0/codeshift/cli/commands/diff.py +221 -0
- codeshift-0.2.0/codeshift/cli/commands/scan.py +368 -0
- codeshift-0.2.0/codeshift/cli/commands/upgrade.py +436 -0
- codeshift-0.2.0/codeshift/cli/commands/upgrade_all.py +518 -0
- codeshift-0.2.0/codeshift/cli/main.py +221 -0
- codeshift-0.2.0/codeshift/cli/quota.py +210 -0
- codeshift-0.2.0/codeshift/knowledge/__init__.py +50 -0
- codeshift-0.2.0/codeshift/knowledge/cache.py +167 -0
- codeshift-0.2.0/codeshift/knowledge/generator.py +231 -0
- codeshift-0.2.0/codeshift/knowledge/models.py +151 -0
- codeshift-0.2.0/codeshift/knowledge/parser.py +270 -0
- codeshift-0.2.0/codeshift/knowledge/sources.py +388 -0
- codeshift-0.2.0/codeshift/knowledge_base/__init__.py +17 -0
- codeshift-0.2.0/codeshift/knowledge_base/loader.py +102 -0
- codeshift-0.2.0/codeshift/knowledge_base/models.py +110 -0
- codeshift-0.2.0/codeshift/migrator/__init__.py +23 -0
- codeshift-0.2.0/codeshift/migrator/ast_transforms.py +256 -0
- codeshift-0.2.0/codeshift/migrator/engine.py +395 -0
- codeshift-0.2.0/codeshift/migrator/llm_migrator.py +320 -0
- codeshift-0.2.0/codeshift/migrator/transforms/__init__.py +19 -0
- codeshift-0.2.0/codeshift/migrator/transforms/fastapi_transformer.py +174 -0
- codeshift-0.2.0/codeshift/migrator/transforms/pandas_transformer.py +236 -0
- codeshift-0.2.0/codeshift/migrator/transforms/pydantic_v1_to_v2.py +637 -0
- codeshift-0.2.0/codeshift/migrator/transforms/requests_transformer.py +218 -0
- codeshift-0.2.0/codeshift/migrator/transforms/sqlalchemy_transformer.py +175 -0
- codeshift-0.2.0/codeshift/scanner/__init__.py +6 -0
- codeshift-0.2.0/codeshift/scanner/code_scanner.py +352 -0
- codeshift-0.2.0/codeshift/scanner/dependency_parser.py +473 -0
- codeshift-0.2.0/codeshift/utils/__init__.py +5 -0
- codeshift-0.2.0/codeshift/utils/api_client.py +266 -0
- codeshift-0.2.0/codeshift/utils/cache.py +318 -0
- codeshift-0.2.0/codeshift/utils/config.py +71 -0
- codeshift-0.2.0/codeshift/utils/llm_client.py +221 -0
- codeshift-0.2.0/codeshift/validator/__init__.py +6 -0
- codeshift-0.2.0/codeshift/validator/syntax_checker.py +183 -0
- codeshift-0.2.0/codeshift/validator/test_runner.py +224 -0
- codeshift-0.2.0/codeshift.egg-info/PKG-INFO +326 -0
- codeshift-0.2.0/codeshift.egg-info/SOURCES.txt +77 -0
- codeshift-0.2.0/codeshift.egg-info/dependency_links.txt +1 -0
- codeshift-0.2.0/codeshift.egg-info/entry_points.txt +2 -0
- codeshift-0.2.0/codeshift.egg-info/requires.txt +36 -0
- codeshift-0.2.0/codeshift.egg-info/top_level.txt +1 -0
- codeshift-0.2.0/pyproject.toml +117 -0
- codeshift-0.2.0/setup.cfg +4 -0
- codeshift-0.2.0/tests/test_code_scanner.py +275 -0
- codeshift-0.2.0/tests/test_fastapi_transforms.py +162 -0
- codeshift-0.2.0/tests/test_knowledge_base.py +184 -0
- codeshift-0.2.0/tests/test_pandas_transforms.py +135 -0
- codeshift-0.2.0/tests/test_pydantic_transforms.py +278 -0
- codeshift-0.2.0/tests/test_requests_transforms.py +113 -0
- codeshift-0.2.0/tests/test_risk_assessor.py +309 -0
- codeshift-0.2.0/tests/test_sqlalchemy_transforms.py +97 -0
- codeshift-0.2.0/tests/test_syntax_checker.py +203 -0
codeshift-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 PyResolve
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
codeshift-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: codeshift
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: AI-powered CLI tool that migrates Python code to handle breaking dependency changes
|
|
5
|
+
Author: PyResolve Team
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/youssefragab/PyResolve
|
|
8
|
+
Project-URL: Repository, https://github.com/youssefragab/PyResolve
|
|
9
|
+
Project-URL: Issues, https://github.com/youssefragab/PyResolve/issues
|
|
10
|
+
Keywords: migration,dependencies,ast,refactoring,pydantic
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
19
|
+
Requires-Python: >=3.10
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: click>=8.0
|
|
23
|
+
Requires-Dist: libcst>=1.0
|
|
24
|
+
Requires-Dist: anthropic>=0.20
|
|
25
|
+
Requires-Dist: pyyaml>=6.0
|
|
26
|
+
Requires-Dist: rich>=13.0
|
|
27
|
+
Requires-Dist: toml>=0.10
|
|
28
|
+
Requires-Dist: packaging>=23.0
|
|
29
|
+
Requires-Dist: httpx>=0.25
|
|
30
|
+
Requires-Dist: pytest>=8.4.2
|
|
31
|
+
Requires-Dist: nox>=2025.11.12
|
|
32
|
+
Requires-Dist: black>=24.10.0
|
|
33
|
+
Requires-Dist: mypy>=1.19.1
|
|
34
|
+
Requires-Dist: supabase>=2.27.2
|
|
35
|
+
Requires-Dist: pre-commit>=4.5.1
|
|
36
|
+
Provides-Extra: api
|
|
37
|
+
Requires-Dist: fastapi>=0.109.0; extra == "api"
|
|
38
|
+
Requires-Dist: uvicorn>=0.27.0; extra == "api"
|
|
39
|
+
Requires-Dist: supabase>=2.3.0; extra == "api"
|
|
40
|
+
Requires-Dist: stripe>=7.0.0; extra == "api"
|
|
41
|
+
Requires-Dist: pydantic-settings>=2.1.0; extra == "api"
|
|
42
|
+
Requires-Dist: email-validator>=2.0.0; extra == "api"
|
|
43
|
+
Provides-Extra: dev
|
|
44
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
45
|
+
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
46
|
+
Requires-Dist: black<25.0,>=24.0; extra == "dev"
|
|
47
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
48
|
+
Requires-Dist: mypy>=1.0; extra == "dev"
|
|
49
|
+
Requires-Dist: nox>=2024.0; extra == "dev"
|
|
50
|
+
Requires-Dist: pre-commit>=3.6.0; extra == "dev"
|
|
51
|
+
Requires-Dist: types-toml>=0.10; extra == "dev"
|
|
52
|
+
Requires-Dist: types-PyYAML>=6.0; extra == "dev"
|
|
53
|
+
Provides-Extra: all
|
|
54
|
+
Requires-Dist: codeshift[api,dev]; extra == "all"
|
|
55
|
+
Dynamic: license-file
|
|
56
|
+
|
|
57
|
+
# PyResolve
|
|
58
|
+
|
|
59
|
+
[](https://github.com/youssefragab/PyResolve/actions/workflows/ci.yml)
|
|
60
|
+
[](https://pypi.org/project/pyresolve/)
|
|
61
|
+
[](https://www.python.org/downloads/)
|
|
62
|
+
[](LICENSE)
|
|
63
|
+
|
|
64
|
+
**Don't just flag the update. Fix the break.**
|
|
65
|
+
|
|
66
|
+
PyResolve is an AI-powered CLI tool that migrates Python code to handle breaking dependency changes. Unlike Dependabot/Renovate which just bump versions, PyResolve actually rewrites code to be compatible with new library versions.
|
|
67
|
+
|
|
68
|
+
## Features
|
|
69
|
+
|
|
70
|
+
- **Auto-generated knowledge bases** - Fetches changelogs and migration guides from GitHub, parses them with LLM to detect breaking changes
|
|
71
|
+
- **Tiered migration approach** - Deterministic AST transforms for known patterns, KB-guided LLM for medium confidence, pure LLM fallback for complex cases
|
|
72
|
+
- **Confidence-based change detection** - Shows HIGH/MEDIUM/LOW confidence breaking changes before migration
|
|
73
|
+
- **Local test execution** to validate changes before applying
|
|
74
|
+
- **Beautiful diff output** with explanations for each change
|
|
75
|
+
|
|
76
|
+
## Supported Libraries
|
|
77
|
+
|
|
78
|
+
### Tier 1 Libraries (Deterministic AST Transforms)
|
|
79
|
+
|
|
80
|
+
| Library | Migration Path | Status |
|
|
81
|
+
|---------|---------------|--------|
|
|
82
|
+
| Pydantic | v1 → v2 | ✅ Full support |
|
|
83
|
+
| FastAPI | 0.x → 0.100+ | ✅ Supported |
|
|
84
|
+
| SQLAlchemy | 1.4 → 2.0 | ✅ Supported |
|
|
85
|
+
| Pandas | 1.x → 2.x | ✅ Supported |
|
|
86
|
+
| Requests | Various | ✅ Supported |
|
|
87
|
+
|
|
88
|
+
### Any Library (Auto-Generated Knowledge Base)
|
|
89
|
+
|
|
90
|
+
PyResolve can migrate **any Python library** by automatically fetching changelogs from GitHub and detecting breaking changes. For libraries not in Tier 1, it uses KB-guided or pure LLM migration.
|
|
91
|
+
|
|
92
|
+
## Installation
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
pip install pyresolve
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Quick Start
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# Scan your project for all possible migrations
|
|
102
|
+
pyresolve scan
|
|
103
|
+
|
|
104
|
+
# Scan with detailed breaking change analysis
|
|
105
|
+
pyresolve scan --fetch-changes
|
|
106
|
+
|
|
107
|
+
# Analyze and propose changes for a specific library
|
|
108
|
+
pyresolve upgrade pydantic --target 2.5.0
|
|
109
|
+
|
|
110
|
+
# View detailed diff of proposed changes
|
|
111
|
+
pyresolve diff
|
|
112
|
+
|
|
113
|
+
# Apply changes to your files
|
|
114
|
+
pyresolve apply
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Example Output
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
$ pyresolve upgrade pydantic --target 2.5.0
|
|
121
|
+
|
|
122
|
+
╭──────────────────────── PyResolve Migration ─────────────────────────╮
|
|
123
|
+
│ Upgrading Pydantic to version 2.5.0 │
|
|
124
|
+
│ Migration guide: https://docs.pydantic.dev/latest/migration/ │
|
|
125
|
+
╰──────────────────────────────────────────────────────────────────────╯
|
|
126
|
+
|
|
127
|
+
Fetching knowledge sources...
|
|
128
|
+
✓ GitHub: CHANGELOG.md
|
|
129
|
+
✓ GitHub: docs/migration.md
|
|
130
|
+
|
|
131
|
+
Breaking changes detected:
|
|
132
|
+
|
|
133
|
+
HIGH CONFIDENCE:
|
|
134
|
+
├── .dict() → .model_dump()
|
|
135
|
+
├── @validator → @field_validator
|
|
136
|
+
└── class Config → model_config = ConfigDict()
|
|
137
|
+
|
|
138
|
+
MEDIUM CONFIDENCE:
|
|
139
|
+
├── .json() → .model_dump_json()
|
|
140
|
+
└── parse_obj() → model_validate()
|
|
141
|
+
|
|
142
|
+
Scanning for library usage...
|
|
143
|
+
Found 12 imports from pydantic
|
|
144
|
+
Found 45 usages of pydantic symbols
|
|
145
|
+
|
|
146
|
+
┏━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━┓
|
|
147
|
+
┃ File ┃ Changes ┃ Status ┃
|
|
148
|
+
┡━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━┩
|
|
149
|
+
│ src/models/user.py │ 5 │ Ready │
|
|
150
|
+
│ src/api/schemas.py │ 3 │ Ready │
|
|
151
|
+
└────────────────────┴─────────┴────────┘
|
|
152
|
+
|
|
153
|
+
Total: 8 changes across 2 files
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Usage
|
|
157
|
+
|
|
158
|
+
### Scan Command
|
|
159
|
+
|
|
160
|
+
Scan your entire project for possible dependency migrations:
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
pyresolve scan
|
|
164
|
+
|
|
165
|
+
# Options:
|
|
166
|
+
# --path, -p Path to scan (default: current directory)
|
|
167
|
+
# --fetch-changes Fetch changelogs and detect breaking changes (slower)
|
|
168
|
+
# --major-only Only show major version upgrades
|
|
169
|
+
# --json-output Output results as JSON
|
|
170
|
+
# --verbose, -v Show detailed output
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Example output:
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
$ pyresolve scan
|
|
177
|
+
|
|
178
|
+
Found 13 dependencies
|
|
179
|
+
|
|
180
|
+
Outdated Dependencies (5)
|
|
181
|
+
┏━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━┳━━━━━━━┳━━━━━━━━━━┓
|
|
182
|
+
┃ Package ┃ Current ┃ Latest ┃ Type ┃ Tier ┃
|
|
183
|
+
┡━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━╇━━━━━━━╇━━━━━━━━━━┩
|
|
184
|
+
│ pydantic │ 1.0 │ 2.5.0 │ Major │ Tier 1 │
|
|
185
|
+
│ rich │ 13.0 │ 14.0.0 │ Major │ Tier 2/3 │
|
|
186
|
+
└────────────┴─────────┴────────┴───────┴──────────┘
|
|
187
|
+
|
|
188
|
+
Suggested Migrations (2)
|
|
189
|
+
pydantic 1.0 → 2.5.0 (Tier 1 - deterministic)
|
|
190
|
+
rich 13.0 → 14.0.0 (Tier 2/3 - LLM-assisted)
|
|
191
|
+
|
|
192
|
+
Quick commands:
|
|
193
|
+
pyresolve upgrade pydantic --target 2.5.0
|
|
194
|
+
pyresolve upgrade rich --target 14.0.0
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### Upgrade Command
|
|
198
|
+
|
|
199
|
+
Analyze your codebase and propose changes for a library upgrade:
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
pyresolve upgrade <library> --target <version>
|
|
203
|
+
|
|
204
|
+
# Options:
|
|
205
|
+
# --target, -t Target version to upgrade to
|
|
206
|
+
# --path, -p Path to analyze (default: current directory)
|
|
207
|
+
# --dry-run Show what would be changed without saving state
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Diff Command
|
|
211
|
+
|
|
212
|
+
View the detailed diff of proposed changes:
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
pyresolve diff
|
|
216
|
+
|
|
217
|
+
# Options:
|
|
218
|
+
# --file, -f Show diff for specific file only
|
|
219
|
+
# --no-color Disable colored output
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Apply Command
|
|
223
|
+
|
|
224
|
+
Apply the proposed changes to your files:
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
pyresolve apply
|
|
228
|
+
|
|
229
|
+
# Options:
|
|
230
|
+
# --backup Create backup files before applying changes
|
|
231
|
+
# --file, -f Apply changes to specific file only
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## How It Works
|
|
235
|
+
|
|
236
|
+
```text
|
|
237
|
+
┌─────────────────────────────────────────────────────────────────────┐
|
|
238
|
+
│ Knowledge Acquisition Pipeline │
|
|
239
|
+
│ ┌─────────────┐ ┌──────────────────┐ ┌─────────────────────┐ │
|
|
240
|
+
│ │ Local Cache │──▶│ On-Demand Gen │──▶│ LLM Parser │ │
|
|
241
|
+
│ │ (instant) │ │ (fetches sources)│ │ (breaking changes) │ │
|
|
242
|
+
│ └─────────────┘ └──────────────────┘ └─────────────────────┘ │
|
|
243
|
+
│ │ │
|
|
244
|
+
│ ┌───────────────┴───────────────┐ │
|
|
245
|
+
│ │ Source Fetchers │ │
|
|
246
|
+
│ │ ├── GitHub (CHANGELOG.md) │ │
|
|
247
|
+
│ │ ├── Docs (migration guides) │ │
|
|
248
|
+
│ │ └── Release notes │ │
|
|
249
|
+
│ └───────────────────────────────┘ │
|
|
250
|
+
└─────────────────────────────────────────────────────────────────────┘
|
|
251
|
+
│
|
|
252
|
+
▼
|
|
253
|
+
┌─────────────────────────────────────────────────────────────────────┐
|
|
254
|
+
│ Migration Engine (Tiered) │
|
|
255
|
+
│ Tier 1: AST Transforms │ Tier 2: KB-Guided │ Tier 3: LLM │
|
|
256
|
+
│ (deterministic) │ (context + LLM) │ (fallback) │
|
|
257
|
+
└─────────────────────────────────────────────────────────────────────┘
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
1. **Fetch Knowledge**: Discovers and fetches changelogs, migration guides from GitHub/PyPI
|
|
261
|
+
2. **Parse Changes**: Uses LLM to extract breaking changes with confidence levels (HIGH/MEDIUM/LOW)
|
|
262
|
+
3. **Scan Codebase**: Finds imports and usage of the target library
|
|
263
|
+
4. **Tiered Migration**:
|
|
264
|
+
- **Tier 1**: Deterministic AST transforms for known libraries (pydantic, fastapi, sqlalchemy, pandas, requests)
|
|
265
|
+
- **Tier 2**: Knowledge base guided migration with LLM assistance
|
|
266
|
+
- **Tier 3**: Pure LLM migration for unknown patterns
|
|
267
|
+
5. **Validate**: Runs syntax checks and optionally your test suite
|
|
268
|
+
6. **Report**: Shows a detailed diff with explanations for each change
|
|
269
|
+
|
|
270
|
+
## Pydantic v1 → v2 Transforms
|
|
271
|
+
|
|
272
|
+
PyResolve handles the following Pydantic migrations automatically:
|
|
273
|
+
|
|
274
|
+
- `Config` class → `model_config = ConfigDict(...)`
|
|
275
|
+
- `@validator` → `@field_validator` with `@classmethod`
|
|
276
|
+
- `@root_validator` → `@model_validator`
|
|
277
|
+
- `.dict()` → `.model_dump()`
|
|
278
|
+
- `.json()` → `.model_dump_json()`
|
|
279
|
+
- `.schema()` → `.model_json_schema()`
|
|
280
|
+
- `.parse_obj()` → `.model_validate()`
|
|
281
|
+
- `orm_mode = True` → `from_attributes = True`
|
|
282
|
+
- `Field(regex=...)` → `Field(pattern=...)`
|
|
283
|
+
|
|
284
|
+
## Configuration
|
|
285
|
+
|
|
286
|
+
PyResolve can be configured via `pyproject.toml`:
|
|
287
|
+
|
|
288
|
+
```toml
|
|
289
|
+
[tool.pyresolve]
|
|
290
|
+
# Path patterns to exclude from scanning (defaults: .pyresolve/*, tests/*, .venv/*, venv/*)
|
|
291
|
+
exclude = ["tests/*", "migrations/*"]
|
|
292
|
+
|
|
293
|
+
# Enable/disable LLM fallback
|
|
294
|
+
use_llm = true
|
|
295
|
+
|
|
296
|
+
# Anthropic API key (can also use ANTHROPIC_API_KEY env var)
|
|
297
|
+
# anthropic_api_key = "sk-..."
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
## Pricing
|
|
301
|
+
|
|
302
|
+
PyResolve uses a tiered pricing model:
|
|
303
|
+
|
|
304
|
+
| Tier | Price | Features |
|
|
305
|
+
|------|-------|----------|
|
|
306
|
+
| **Free** | $0/month | Tier 1 deterministic transforms (Pydantic, FastAPI, SQLAlchemy, Pandas, Requests) |
|
|
307
|
+
| **Pro** | $19/month | Tier 2 KB-guided LLM migrations for any library |
|
|
308
|
+
| **Unlimited** | $49/month | Tier 3 pure LLM migrations + priority support |
|
|
309
|
+
|
|
310
|
+
**How it works:**
|
|
311
|
+
- **Tier 1 (Free)**: Runs entirely locally using deterministic AST transforms. No account required.
|
|
312
|
+
- **Tier 2/3 (Paid)**: LLM-powered migrations are processed through the PyResolve API to ensure quality and manage costs.
|
|
313
|
+
|
|
314
|
+
```bash
|
|
315
|
+
# Login to access Pro/Unlimited features
|
|
316
|
+
pyresolve login
|
|
317
|
+
|
|
318
|
+
# Check your current plan and usage
|
|
319
|
+
pyresolve quota
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
## License
|
|
323
|
+
|
|
324
|
+
This software is licensed under the [MIT License](LICENSE).
|
|
325
|
+
|
|
326
|
+
You are free to use, modify, and distribute this software. The CLI tool and all transforms are fully open source.
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
# PyResolve
|
|
2
|
+
|
|
3
|
+
[](https://github.com/youssefragab/PyResolve/actions/workflows/ci.yml)
|
|
4
|
+
[](https://pypi.org/project/pyresolve/)
|
|
5
|
+
[](https://www.python.org/downloads/)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
|
|
8
|
+
**Don't just flag the update. Fix the break.**
|
|
9
|
+
|
|
10
|
+
PyResolve is an AI-powered CLI tool that migrates Python code to handle breaking dependency changes. Unlike Dependabot/Renovate which just bump versions, PyResolve actually rewrites code to be compatible with new library versions.
|
|
11
|
+
|
|
12
|
+
## Features
|
|
13
|
+
|
|
14
|
+
- **Auto-generated knowledge bases** - Fetches changelogs and migration guides from GitHub, parses them with LLM to detect breaking changes
|
|
15
|
+
- **Tiered migration approach** - Deterministic AST transforms for known patterns, KB-guided LLM for medium confidence, pure LLM fallback for complex cases
|
|
16
|
+
- **Confidence-based change detection** - Shows HIGH/MEDIUM/LOW confidence breaking changes before migration
|
|
17
|
+
- **Local test execution** to validate changes before applying
|
|
18
|
+
- **Beautiful diff output** with explanations for each change
|
|
19
|
+
|
|
20
|
+
## Supported Libraries
|
|
21
|
+
|
|
22
|
+
### Tier 1 Libraries (Deterministic AST Transforms)
|
|
23
|
+
|
|
24
|
+
| Library | Migration Path | Status |
|
|
25
|
+
|---------|---------------|--------|
|
|
26
|
+
| Pydantic | v1 → v2 | ✅ Full support |
|
|
27
|
+
| FastAPI | 0.x → 0.100+ | ✅ Supported |
|
|
28
|
+
| SQLAlchemy | 1.4 → 2.0 | ✅ Supported |
|
|
29
|
+
| Pandas | 1.x → 2.x | ✅ Supported |
|
|
30
|
+
| Requests | Various | ✅ Supported |
|
|
31
|
+
|
|
32
|
+
### Any Library (Auto-Generated Knowledge Base)
|
|
33
|
+
|
|
34
|
+
PyResolve can migrate **any Python library** by automatically fetching changelogs from GitHub and detecting breaking changes. For libraries not in Tier 1, it uses KB-guided or pure LLM migration.
|
|
35
|
+
|
|
36
|
+
## Installation
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install pyresolve
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Quick Start
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# Scan your project for all possible migrations
|
|
46
|
+
pyresolve scan
|
|
47
|
+
|
|
48
|
+
# Scan with detailed breaking change analysis
|
|
49
|
+
pyresolve scan --fetch-changes
|
|
50
|
+
|
|
51
|
+
# Analyze and propose changes for a specific library
|
|
52
|
+
pyresolve upgrade pydantic --target 2.5.0
|
|
53
|
+
|
|
54
|
+
# View detailed diff of proposed changes
|
|
55
|
+
pyresolve diff
|
|
56
|
+
|
|
57
|
+
# Apply changes to your files
|
|
58
|
+
pyresolve apply
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Example Output
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
$ pyresolve upgrade pydantic --target 2.5.0
|
|
65
|
+
|
|
66
|
+
╭──────────────────────── PyResolve Migration ─────────────────────────╮
|
|
67
|
+
│ Upgrading Pydantic to version 2.5.0 │
|
|
68
|
+
│ Migration guide: https://docs.pydantic.dev/latest/migration/ │
|
|
69
|
+
╰──────────────────────────────────────────────────────────────────────╯
|
|
70
|
+
|
|
71
|
+
Fetching knowledge sources...
|
|
72
|
+
✓ GitHub: CHANGELOG.md
|
|
73
|
+
✓ GitHub: docs/migration.md
|
|
74
|
+
|
|
75
|
+
Breaking changes detected:
|
|
76
|
+
|
|
77
|
+
HIGH CONFIDENCE:
|
|
78
|
+
├── .dict() → .model_dump()
|
|
79
|
+
├── @validator → @field_validator
|
|
80
|
+
└── class Config → model_config = ConfigDict()
|
|
81
|
+
|
|
82
|
+
MEDIUM CONFIDENCE:
|
|
83
|
+
├── .json() → .model_dump_json()
|
|
84
|
+
└── parse_obj() → model_validate()
|
|
85
|
+
|
|
86
|
+
Scanning for library usage...
|
|
87
|
+
Found 12 imports from pydantic
|
|
88
|
+
Found 45 usages of pydantic symbols
|
|
89
|
+
|
|
90
|
+
┏━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━┓
|
|
91
|
+
┃ File ┃ Changes ┃ Status ┃
|
|
92
|
+
┡━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━┩
|
|
93
|
+
│ src/models/user.py │ 5 │ Ready │
|
|
94
|
+
│ src/api/schemas.py │ 3 │ Ready │
|
|
95
|
+
└────────────────────┴─────────┴────────┘
|
|
96
|
+
|
|
97
|
+
Total: 8 changes across 2 files
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Usage
|
|
101
|
+
|
|
102
|
+
### Scan Command
|
|
103
|
+
|
|
104
|
+
Scan your entire project for possible dependency migrations:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
pyresolve scan
|
|
108
|
+
|
|
109
|
+
# Options:
|
|
110
|
+
# --path, -p Path to scan (default: current directory)
|
|
111
|
+
# --fetch-changes Fetch changelogs and detect breaking changes (slower)
|
|
112
|
+
# --major-only Only show major version upgrades
|
|
113
|
+
# --json-output Output results as JSON
|
|
114
|
+
# --verbose, -v Show detailed output
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Example output:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
$ pyresolve scan
|
|
121
|
+
|
|
122
|
+
Found 13 dependencies
|
|
123
|
+
|
|
124
|
+
Outdated Dependencies (5)
|
|
125
|
+
┏━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━┳━━━━━━━┳━━━━━━━━━━┓
|
|
126
|
+
┃ Package ┃ Current ┃ Latest ┃ Type ┃ Tier ┃
|
|
127
|
+
┡━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━╇━━━━━━━╇━━━━━━━━━━┩
|
|
128
|
+
│ pydantic │ 1.0 │ 2.5.0 │ Major │ Tier 1 │
|
|
129
|
+
│ rich │ 13.0 │ 14.0.0 │ Major │ Tier 2/3 │
|
|
130
|
+
└────────────┴─────────┴────────┴───────┴──────────┘
|
|
131
|
+
|
|
132
|
+
Suggested Migrations (2)
|
|
133
|
+
pydantic 1.0 → 2.5.0 (Tier 1 - deterministic)
|
|
134
|
+
rich 13.0 → 14.0.0 (Tier 2/3 - LLM-assisted)
|
|
135
|
+
|
|
136
|
+
Quick commands:
|
|
137
|
+
pyresolve upgrade pydantic --target 2.5.0
|
|
138
|
+
pyresolve upgrade rich --target 14.0.0
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Upgrade Command
|
|
142
|
+
|
|
143
|
+
Analyze your codebase and propose changes for a library upgrade:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
pyresolve upgrade <library> --target <version>
|
|
147
|
+
|
|
148
|
+
# Options:
|
|
149
|
+
# --target, -t Target version to upgrade to
|
|
150
|
+
# --path, -p Path to analyze (default: current directory)
|
|
151
|
+
# --dry-run Show what would be changed without saving state
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Diff Command
|
|
155
|
+
|
|
156
|
+
View the detailed diff of proposed changes:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
pyresolve diff
|
|
160
|
+
|
|
161
|
+
# Options:
|
|
162
|
+
# --file, -f Show diff for specific file only
|
|
163
|
+
# --no-color Disable colored output
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Apply Command
|
|
167
|
+
|
|
168
|
+
Apply the proposed changes to your files:
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
pyresolve apply
|
|
172
|
+
|
|
173
|
+
# Options:
|
|
174
|
+
# --backup Create backup files before applying changes
|
|
175
|
+
# --file, -f Apply changes to specific file only
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## How It Works
|
|
179
|
+
|
|
180
|
+
```text
|
|
181
|
+
┌─────────────────────────────────────────────────────────────────────┐
|
|
182
|
+
│ Knowledge Acquisition Pipeline │
|
|
183
|
+
│ ┌─────────────┐ ┌──────────────────┐ ┌─────────────────────┐ │
|
|
184
|
+
│ │ Local Cache │──▶│ On-Demand Gen │──▶│ LLM Parser │ │
|
|
185
|
+
│ │ (instant) │ │ (fetches sources)│ │ (breaking changes) │ │
|
|
186
|
+
│ └─────────────┘ └──────────────────┘ └─────────────────────┘ │
|
|
187
|
+
│ │ │
|
|
188
|
+
│ ┌───────────────┴───────────────┐ │
|
|
189
|
+
│ │ Source Fetchers │ │
|
|
190
|
+
│ │ ├── GitHub (CHANGELOG.md) │ │
|
|
191
|
+
│ │ ├── Docs (migration guides) │ │
|
|
192
|
+
│ │ └── Release notes │ │
|
|
193
|
+
│ └───────────────────────────────┘ │
|
|
194
|
+
└─────────────────────────────────────────────────────────────────────┘
|
|
195
|
+
│
|
|
196
|
+
▼
|
|
197
|
+
┌─────────────────────────────────────────────────────────────────────┐
|
|
198
|
+
│ Migration Engine (Tiered) │
|
|
199
|
+
│ Tier 1: AST Transforms │ Tier 2: KB-Guided │ Tier 3: LLM │
|
|
200
|
+
│ (deterministic) │ (context + LLM) │ (fallback) │
|
|
201
|
+
└─────────────────────────────────────────────────────────────────────┘
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
1. **Fetch Knowledge**: Discovers and fetches changelogs, migration guides from GitHub/PyPI
|
|
205
|
+
2. **Parse Changes**: Uses LLM to extract breaking changes with confidence levels (HIGH/MEDIUM/LOW)
|
|
206
|
+
3. **Scan Codebase**: Finds imports and usage of the target library
|
|
207
|
+
4. **Tiered Migration**:
|
|
208
|
+
- **Tier 1**: Deterministic AST transforms for known libraries (pydantic, fastapi, sqlalchemy, pandas, requests)
|
|
209
|
+
- **Tier 2**: Knowledge base guided migration with LLM assistance
|
|
210
|
+
- **Tier 3**: Pure LLM migration for unknown patterns
|
|
211
|
+
5. **Validate**: Runs syntax checks and optionally your test suite
|
|
212
|
+
6. **Report**: Shows a detailed diff with explanations for each change
|
|
213
|
+
|
|
214
|
+
## Pydantic v1 → v2 Transforms
|
|
215
|
+
|
|
216
|
+
PyResolve handles the following Pydantic migrations automatically:
|
|
217
|
+
|
|
218
|
+
- `Config` class → `model_config = ConfigDict(...)`
|
|
219
|
+
- `@validator` → `@field_validator` with `@classmethod`
|
|
220
|
+
- `@root_validator` → `@model_validator`
|
|
221
|
+
- `.dict()` → `.model_dump()`
|
|
222
|
+
- `.json()` → `.model_dump_json()`
|
|
223
|
+
- `.schema()` → `.model_json_schema()`
|
|
224
|
+
- `.parse_obj()` → `.model_validate()`
|
|
225
|
+
- `orm_mode = True` → `from_attributes = True`
|
|
226
|
+
- `Field(regex=...)` → `Field(pattern=...)`
|
|
227
|
+
|
|
228
|
+
## Configuration
|
|
229
|
+
|
|
230
|
+
PyResolve can be configured via `pyproject.toml`:
|
|
231
|
+
|
|
232
|
+
```toml
|
|
233
|
+
[tool.pyresolve]
|
|
234
|
+
# Path patterns to exclude from scanning (defaults: .pyresolve/*, tests/*, .venv/*, venv/*)
|
|
235
|
+
exclude = ["tests/*", "migrations/*"]
|
|
236
|
+
|
|
237
|
+
# Enable/disable LLM fallback
|
|
238
|
+
use_llm = true
|
|
239
|
+
|
|
240
|
+
# Anthropic API key (can also use ANTHROPIC_API_KEY env var)
|
|
241
|
+
# anthropic_api_key = "sk-..."
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## Pricing
|
|
245
|
+
|
|
246
|
+
PyResolve uses a tiered pricing model:
|
|
247
|
+
|
|
248
|
+
| Tier | Price | Features |
|
|
249
|
+
|------|-------|----------|
|
|
250
|
+
| **Free** | $0/month | Tier 1 deterministic transforms (Pydantic, FastAPI, SQLAlchemy, Pandas, Requests) |
|
|
251
|
+
| **Pro** | $19/month | Tier 2 KB-guided LLM migrations for any library |
|
|
252
|
+
| **Unlimited** | $49/month | Tier 3 pure LLM migrations + priority support |
|
|
253
|
+
|
|
254
|
+
**How it works:**
|
|
255
|
+
- **Tier 1 (Free)**: Runs entirely locally using deterministic AST transforms. No account required.
|
|
256
|
+
- **Tier 2/3 (Paid)**: LLM-powered migrations are processed through the PyResolve API to ensure quality and manage costs.
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
# Login to access Pro/Unlimited features
|
|
260
|
+
pyresolve login
|
|
261
|
+
|
|
262
|
+
# Check your current plan and usage
|
|
263
|
+
pyresolve quota
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
## License
|
|
267
|
+
|
|
268
|
+
This software is licensed under the [MIT License](LICENSE).
|
|
269
|
+
|
|
270
|
+
You are free to use, modify, and distribute this software. The CLI tool and all transforms are fully open source.
|