codeshift 0.3.5__py3-none-any.whl → 0.3.7__py3-none-any.whl

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.
@@ -0,0 +1,472 @@
1
+ Metadata-Version: 2.4
2
+ Name: codeshift
3
+ Version: 0.3.7
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/Ragab-Technologies/Codeshift
8
+ Project-URL: Repository, https://github.com/Ragab-Technologies/Codeshift
9
+ Project-URL: Issues, https://github.com/Ragab-Technologies/Codeshift/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
+ # Codeshift
58
+
59
+ [![PyPI version](https://badge.fury.io/py/codeshift.svg)](https://pypi.org/project/codeshift/)
60
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
61
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
62
+
63
+ **Don't just flag the update. Fix the break.**
64
+
65
+ Codeshift is an AI-powered CLI tool that migrates Python code when dependencies are upgraded. Unlike Dependabot or Renovate which only bump version numbers, Codeshift rewrites your code to be compatible with new library APIs.
66
+
67
+ ## Why Codeshift?
68
+
69
+ Upgrading a dependency often means updating dozens of call sites to match a new API. Codeshift automates that:
70
+
71
+ - **Scans** your project for outdated dependencies
72
+ - **Detects** breaking changes from changelogs and migration guides
73
+ - **Rewrites** your code using deterministic AST transforms or LLM assistance
74
+ - **Shows** a detailed diff with explanations before touching any file
75
+
76
+ ## Features
77
+
78
+ - **Deterministic AST transforms** for 15 popular libraries (no LLM required)
79
+ - **Auto-generated knowledge bases** - fetches changelogs and migration guides from GitHub, parses them with an LLM to detect breaking changes
80
+ - **Tiered migration engine** - deterministic transforms first, KB-guided LLM second, pure LLM fallback last
81
+ - **Confidence-based change detection** - shows HIGH/MEDIUM/LOW confidence breaking changes before migration
82
+ - **Beautiful diff output** with per-change explanations
83
+ - **Backup and restore** so you can safely revert
84
+ - **Batch upgrades** - migrate all outdated dependencies in one command
85
+
86
+ ## Supported Libraries
87
+
88
+ ### Tier 1 (Deterministic AST Transforms - Free, No LLM Required)
89
+
90
+ | Library | Migration Path | Status |
91
+ |---------|---------------|--------|
92
+ | Pydantic | v1 → v2 | Supported |
93
+ | FastAPI | 0.x → 0.100+ | Supported |
94
+ | SQLAlchemy | 1.4 → 2.0 | Supported |
95
+ | Pandas | 1.x → 2.x | Supported |
96
+ | Requests | Various | Supported |
97
+ | Django | 3.x → 4.x/5.x | Supported |
98
+ | Flask | 1.x → 2.x/3.x | Supported |
99
+ | NumPy | 1.x → 2.x | Supported |
100
+ | attrs | attr → attrs | Supported |
101
+ | Celery | 4.x → 5.x | Supported |
102
+ | Click | 7.x → 8.x | Supported |
103
+ | aiohttp | 2.x → 3.x | Supported |
104
+ | httpx | 0.x → 0.24+ | Supported |
105
+ | Marshmallow | 2.x → 3.x | Supported |
106
+ | pytest | 6.x → 7.x/8.x | Supported |
107
+
108
+ ### Any Library (Auto-Generated Knowledge Base)
109
+
110
+ Codeshift 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.
111
+
112
+ ## Installation
113
+
114
+ ```bash
115
+ pip install codeshift
116
+ ```
117
+
118
+ For development:
119
+
120
+ ```bash
121
+ pip install codeshift[dev]
122
+ ```
123
+
124
+ Verify the installation:
125
+
126
+ ```bash
127
+ codeshift --help
128
+ ```
129
+
130
+ ## Quick Start
131
+
132
+ ```bash
133
+ # 1. Scan your project for outdated dependencies
134
+ codeshift scan
135
+
136
+ # 2. Upgrade a specific library
137
+ codeshift upgrade pydantic --target 2.5.0
138
+
139
+ # 3. Review the proposed changes
140
+ codeshift diff
141
+
142
+ # 4. Apply the changes
143
+ codeshift apply
144
+
145
+ # 5. Run your tests to verify
146
+ pytest
147
+ ```
148
+
149
+ Or upgrade everything at once:
150
+
151
+ ```bash
152
+ codeshift upgrade-all
153
+ ```
154
+
155
+ ### Example Output
156
+
157
+ ```
158
+ $ codeshift upgrade pydantic --target 2.5.0
159
+
160
+ ╭──────────────────────── Codeshift Migration ─────────────────────────╮
161
+ │ Upgrading Pydantic to version 2.5.0 │
162
+ │ Migration guide: https://docs.pydantic.dev/latest/migration/ │
163
+ ╰──────────────────────────────────────────────────────────────────────╯
164
+
165
+ Fetching knowledge sources...
166
+ ✓ GitHub: CHANGELOG.md
167
+ ✓ GitHub: docs/migration.md
168
+
169
+ Breaking changes detected:
170
+
171
+ HIGH CONFIDENCE:
172
+ ├── .dict() → .model_dump()
173
+ ├── @validator → @field_validator
174
+ └── class Config → model_config = ConfigDict()
175
+
176
+ MEDIUM CONFIDENCE:
177
+ ├── .json() → .model_dump_json()
178
+ └── parse_obj() → model_validate()
179
+
180
+ Scanning for library usage...
181
+ Found 12 imports from pydantic
182
+ Found 45 usages of pydantic symbols
183
+
184
+ ┏━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━┓
185
+ ┃ File ┃ Changes ┃ Status ┃
186
+ ┡━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━┩
187
+ │ src/models/user.py │ 5 │ Ready │
188
+ │ src/api/schemas.py │ 3 │ Ready │
189
+ └────────────────────┴─────────┴────────┘
190
+
191
+ Total: 8 changes across 2 files
192
+ ```
193
+
194
+ ## Commands
195
+
196
+ ### `codeshift scan`
197
+
198
+ Scan your project for outdated dependencies and available migrations.
199
+
200
+ ```bash
201
+ codeshift scan [OPTIONS]
202
+
203
+ Options:
204
+ --path, -p PATH Path to scan (default: current directory)
205
+ --fetch-changes Fetch changelogs and detect breaking changes
206
+ --major-only Only show major version upgrades
207
+ --json-output Output results as JSON
208
+ --verbose, -v Show detailed output
209
+ ```
210
+
211
+ Example:
212
+
213
+ ```
214
+ $ codeshift scan
215
+
216
+ Found 13 dependencies
217
+
218
+ Outdated Dependencies (5)
219
+ ┏━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━┳━━━━━━━┳━━━━━━━━━━┓
220
+ ┃ Package ┃ Current ┃ Latest ┃ Type ┃ Tier ┃
221
+ ┡━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━╇━━━━━━━╇━━━━━━━━━━┩
222
+ │ pydantic │ 1.0 │ 2.5.0 │ Major │ Tier 1 │
223
+ │ rich │ 13.0 │ 14.0.0 │ Major │ Tier 2/3 │
224
+ └────────────┴─────────┴────────┴───────┴──────────┘
225
+
226
+ Suggested Migrations (2)
227
+ pydantic 1.0 → 2.5.0 (Tier 1 - deterministic)
228
+ rich 13.0 → 14.0.0 (Tier 2/3 - LLM-assisted)
229
+
230
+ Quick commands:
231
+ codeshift upgrade pydantic --target 2.5.0
232
+ codeshift upgrade rich --target 14.0.0
233
+ ```
234
+
235
+ ### `codeshift upgrade`
236
+
237
+ Analyze your codebase and propose changes for a specific library upgrade.
238
+
239
+ ```bash
240
+ codeshift upgrade <library> --target <version> [OPTIONS]
241
+
242
+ Arguments:
243
+ LIBRARY Library name to upgrade (required)
244
+
245
+ Options:
246
+ --target, -t VERSION Target version to upgrade to (required)
247
+ --path, -p PATH Path to analyze (default: current directory)
248
+ --file, -f PATH Analyze a single file instead of the entire project
249
+ --dry-run Show what would be changed without saving state
250
+ --verbose, -v Show detailed output
251
+ ```
252
+
253
+ ### `codeshift upgrade-all`
254
+
255
+ Upgrade all outdated packages to their latest versions in one go.
256
+
257
+ ```bash
258
+ codeshift upgrade-all [OPTIONS]
259
+
260
+ Options:
261
+ --path, -p PATH Path to analyze (default: current directory)
262
+ --all Include all outdated packages (not just Tier 1)
263
+ --tier1-only Only upgrade Tier 1 libraries (deterministic transforms)
264
+ --major-only Only perform major version upgrades
265
+ --include, -i LIB Only include specific libraries (repeatable)
266
+ --exclude, -e LIB Exclude specific libraries (repeatable)
267
+ --update-deps Update dependency files with new versions (default: yes)
268
+ --no-update-deps Skip updating dependency files
269
+ --dry-run Show what would be changed without saving state
270
+ --verbose, -v Show detailed output
271
+ ```
272
+
273
+ ### `codeshift diff`
274
+
275
+ View the detailed diff of proposed changes.
276
+
277
+ ```bash
278
+ codeshift diff [OPTIONS]
279
+
280
+ Options:
281
+ --path, -p PATH Path to the project (default: current directory)
282
+ --file, -f FILE Show diff for a specific file only
283
+ --no-color Disable colored output
284
+ --context, -c INT Number of context lines (default: 3)
285
+ --summary Show only a summary without the full diff
286
+ ```
287
+
288
+ ### `codeshift show`
289
+
290
+ Show the full transformed or original code for a file.
291
+
292
+ ```bash
293
+ codeshift show <file_path> [OPTIONS]
294
+
295
+ Arguments:
296
+ FILE_PATH File to display (required)
297
+
298
+ Options:
299
+ --path, -p PATH Path to the project (default: current directory)
300
+ --original Show the original code instead of the transformed version
301
+ ```
302
+
303
+ ### `codeshift apply`
304
+
305
+ Apply the proposed changes to your files.
306
+
307
+ ```bash
308
+ codeshift apply [OPTIONS]
309
+
310
+ Options:
311
+ --path, -p PATH Path to the project (default: current directory)
312
+ --file, -f FILE Apply changes to a specific file only
313
+ --backup Create .bak backup files before applying changes
314
+ --yes, -y Skip confirmation prompt
315
+ --validate Validate syntax after applying (default: yes)
316
+ --no-validate Skip syntax validation
317
+ ```
318
+
319
+ ### `codeshift reset`
320
+
321
+ Cancel the current migration and clear all pending changes.
322
+
323
+ ```bash
324
+ codeshift reset [OPTIONS]
325
+
326
+ Options:
327
+ --path, -p PATH Path to the project (default: current directory)
328
+ --yes, -y Skip confirmation prompt
329
+ ```
330
+
331
+ ### `codeshift restore`
332
+
333
+ Restore files from a backup created by `apply --backup`.
334
+
335
+ ```bash
336
+ codeshift restore <backup_dir> [OPTIONS]
337
+
338
+ Arguments:
339
+ BACKUP_DIR Path to backup directory (required)
340
+
341
+ Options:
342
+ --path, -p PATH Path to the project (default: current directory)
343
+ --yes, -y Skip confirmation prompt
344
+ ```
345
+
346
+ ### `codeshift libraries`
347
+
348
+ List all supported libraries and their migration paths.
349
+
350
+ ```bash
351
+ codeshift libraries
352
+ ```
353
+
354
+ ### `codeshift status`
355
+
356
+ Show current migration status, pending changes, and quota info.
357
+
358
+ ```bash
359
+ codeshift status [OPTIONS]
360
+
361
+ Options:
362
+ --path, -p PATH Path to the project (default: current directory)
363
+ ```
364
+
365
+ ### Account Commands
366
+
367
+ ```bash
368
+ codeshift login # Login to enable cloud features
369
+ codeshift register # Create a new account
370
+ codeshift logout # Logout and remove credentials
371
+ codeshift whoami # Show current user info
372
+ codeshift quota # Show usage and limits
373
+ codeshift upgrade-plan # View or upgrade your plan
374
+ codeshift billing # Open billing portal
375
+ ```
376
+
377
+ ## How It Works
378
+
379
+ ```
380
+ ┌─────────────────────────────────────────────────────────────────────┐
381
+ │ Knowledge Acquisition Pipeline │
382
+ │ ┌─────────────┐ ┌──────────────────┐ ┌─────────────────────┐ │
383
+ │ │ Local Cache │──▶│ On-Demand Gen │──▶│ LLM Parser │ │
384
+ │ │ (instant) │ │ (fetches sources)│ │ (breaking changes) │ │
385
+ │ └─────────────┘ └──────────────────┘ └─────────────────────┘ │
386
+ │ │ │
387
+ │ ┌───────────────┴───────────────┐ │
388
+ │ │ Source Fetchers │ │
389
+ │ │ ├── GitHub (CHANGELOG.md) │ │
390
+ │ │ ├── Docs (migration guides) │ │
391
+ │ │ └── Release notes │ │
392
+ │ └───────────────────────────────┘ │
393
+ └─────────────────────────────────────────────────────────────────────┘
394
+
395
+
396
+ ┌─────────────────────────────────────────────────────────────────────┐
397
+ │ Migration Engine (Tiered) │
398
+ │ Tier 1: AST Transforms │ Tier 2: KB-Guided │ Tier 3: LLM │
399
+ │ (deterministic) │ (context + LLM) │ (fallback) │
400
+ └─────────────────────────────────────────────────────────────────────┘
401
+ ```
402
+
403
+ 1. **Fetch Knowledge** - discovers and fetches changelogs, migration guides from GitHub/PyPI
404
+ 2. **Parse Changes** - uses an LLM to extract breaking changes with confidence levels (HIGH/MEDIUM/LOW)
405
+ 3. **Scan Codebase** - finds imports and usage of the target library using libcst
406
+ 4. **Tiered Migration**:
407
+ - **Tier 1**: deterministic AST transforms for 15 supported libraries - no LLM needed
408
+ - **Tier 2**: knowledge base guided migration with LLM assistance
409
+ - **Tier 3**: pure LLM migration for unknown patterns
410
+ 5. **Validate** - runs syntax checks on the transformed code
411
+ 6. **Report** - shows a detailed diff with explanations for each change
412
+
413
+ ## Pydantic v1 → v2 Example
414
+
415
+ Codeshift handles the following Pydantic migrations automatically:
416
+
417
+ | v1 Pattern | v2 Replacement |
418
+ |---|---|
419
+ | `Config` class | `model_config = ConfigDict(...)` |
420
+ | `@validator` | `@field_validator` with `@classmethod` |
421
+ | `@root_validator` | `@model_validator` |
422
+ | `.dict()` | `.model_dump()` |
423
+ | `.json()` | `.model_dump_json()` |
424
+ | `.schema()` | `.model_json_schema()` |
425
+ | `.parse_obj()` | `.model_validate()` |
426
+ | `orm_mode = True` | `from_attributes = True` |
427
+ | `Field(regex=...)` | `Field(pattern=...)` |
428
+
429
+ ## Configuration
430
+
431
+ Codeshift can be configured via `pyproject.toml`:
432
+
433
+ ```toml
434
+ [tool.codeshift]
435
+ # Path patterns to exclude from scanning
436
+ exclude = ["tests/*", "migrations/*"]
437
+
438
+ # Enable/disable LLM fallback
439
+ use_llm = true
440
+
441
+ # Anthropic API key (can also use ANTHROPIC_API_KEY env var)
442
+ # anthropic_api_key = "sk-..."
443
+ ```
444
+
445
+ ## Environment Variables
446
+
447
+ | Variable | Required | Description |
448
+ |---|---|---|
449
+ | `ANTHROPIC_API_KEY` | For Tier 2/3 | Enables LLM-powered migrations |
450
+ | `GITHUB_TOKEN` | No | Higher GitHub API rate limits |
451
+
452
+ ## Pricing
453
+
454
+ | Tier | Price | What You Get |
455
+ |------|-------|--------------|
456
+ | **Free** | $0/month | Tier 1 deterministic transforms for all 15 supported libraries. Runs entirely locally. |
457
+ | **Pro** | $19/month | Tier 2 KB-guided LLM migrations for any library |
458
+ | **Unlimited** | $49/month | Tier 3 pure LLM migrations + priority support |
459
+
460
+ ```bash
461
+ # Login to access Pro/Unlimited features
462
+ codeshift login
463
+
464
+ # Check your current plan and usage
465
+ codeshift quota
466
+ ```
467
+
468
+ ## License
469
+
470
+ This software is licensed under the [MIT License](LICENSE).
471
+
472
+ You are free to use, modify, and distribute this software. The CLI tool and all transforms are fully open source.
@@ -83,9 +83,9 @@ codeshift/utils/llm_client.py,sha256=WkT3KftJi7rsj8MXH4MVJvznugicb2XpkKqnqRET1eo
83
83
  codeshift/validator/__init__.py,sha256=WRQSfJ7eLJdjR2_f_dXSaBtfawkvu1Dlu20Gh76D12c,280
84
84
  codeshift/validator/syntax_checker.py,sha256=FJeLIqhNhV7_Xj2RskHScJZks6A9fybaqv5Z1-MGDfo,5343
85
85
  codeshift/validator/test_runner.py,sha256=VX0OqkuI3AJxOUzRW2_BEjdDsMw1N4a0od-pPbSF6O8,6760
86
- codeshift-0.3.5.dist-info/licenses/LICENSE,sha256=SrjIFBfm7GQh90Giv7mEiPnYdgp1wsp0RnOTT6HkeVw,1066
87
- codeshift-0.3.5.dist-info/METADATA,sha256=CX0pZvNDbIZg_4_pQppo0PibOBsQgUh4ieAs6wFqHH4,14492
88
- codeshift-0.3.5.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
89
- codeshift-0.3.5.dist-info/entry_points.txt,sha256=AlJ8V7a2pNyu-9UiRKUWiTMIJtaYAUnlg53Y-wFHiK0,53
90
- codeshift-0.3.5.dist-info/top_level.txt,sha256=Ct42mtGs5foZ4MyYSksd5rXP0qFhWSZz8Y8mON0EEds,10
91
- codeshift-0.3.5.dist-info/RECORD,,
86
+ codeshift-0.3.7.dist-info/licenses/LICENSE,sha256=SrjIFBfm7GQh90Giv7mEiPnYdgp1wsp0RnOTT6HkeVw,1066
87
+ codeshift-0.3.7.dist-info/METADATA,sha256=CwpDXX4P62C0Cgq5cR5cVneNXQeEkJCyoNyj8P0TOY0,17312
88
+ codeshift-0.3.7.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
89
+ codeshift-0.3.7.dist-info/entry_points.txt,sha256=AlJ8V7a2pNyu-9UiRKUWiTMIJtaYAUnlg53Y-wFHiK0,53
90
+ codeshift-0.3.7.dist-info/top_level.txt,sha256=Ct42mtGs5foZ4MyYSksd5rXP0qFhWSZz8Y8mON0EEds,10
91
+ codeshift-0.3.7.dist-info/RECORD,,
@@ -1,368 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: codeshift
3
- Version: 0.3.5
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
- [![CI](https://github.com/youssefragab/PyResolve/actions/workflows/ci.yml/badge.svg)](https://github.com/youssefragab/PyResolve/actions/workflows/ci.yml)
60
- [![PyPI version](https://badge.fury.io/py/pyresolve.svg)](https://pypi.org/project/pyresolve/)
61
- [![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
62
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](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
- | Django | 3.x → 4.x/5.x | ✅ Supported |
88
- | Flask | 1.x → 2.x/3.x | ✅ Supported |
89
- | NumPy | 1.x → 2.x | ✅ Supported |
90
- | attrs | attr → attrs | ✅ Supported |
91
- | Celery | 4.x → 5.x | ✅ Supported |
92
- | Click | 7.x → 8.x | ✅ Supported |
93
- | aiohttp | 2.x → 3.x | ✅ Supported |
94
- | httpx | 0.x → 0.24+ | ✅ Supported |
95
- | Marshmallow | 2.x → 3.x | ✅ Supported |
96
- | pytest | 6.x → 7.x/8.x | ✅ Supported |
97
-
98
- ### Any Library (Auto-Generated Knowledge Base)
99
-
100
- 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.
101
-
102
- ## Installation
103
-
104
- ```bash
105
- pip install pyresolve
106
- ```
107
-
108
- ## Quick Start
109
-
110
- ```bash
111
- # Scan your project for all possible migrations
112
- pyresolve scan
113
-
114
- # Scan with detailed breaking change analysis
115
- pyresolve scan --fetch-changes
116
-
117
- # Upgrade all outdated packages at once
118
- pyresolve upgrade-all
119
-
120
- # Or analyze and propose changes for a specific library
121
- pyresolve upgrade pydantic --target 2.5.0
122
-
123
- # View detailed diff of proposed changes
124
- pyresolve diff
125
-
126
- # Apply changes to your files
127
- pyresolve apply
128
- ```
129
-
130
- ### Example Output
131
-
132
- ```bash
133
- $ pyresolve upgrade pydantic --target 2.5.0
134
-
135
- ╭──────────────────────── PyResolve Migration ─────────────────────────╮
136
- │ Upgrading Pydantic to version 2.5.0 │
137
- │ Migration guide: https://docs.pydantic.dev/latest/migration/ │
138
- ╰──────────────────────────────────────────────────────────────────────╯
139
-
140
- Fetching knowledge sources...
141
- ✓ GitHub: CHANGELOG.md
142
- ✓ GitHub: docs/migration.md
143
-
144
- Breaking changes detected:
145
-
146
- HIGH CONFIDENCE:
147
- ├── .dict() → .model_dump()
148
- ├── @validator → @field_validator
149
- └── class Config → model_config = ConfigDict()
150
-
151
- MEDIUM CONFIDENCE:
152
- ├── .json() → .model_dump_json()
153
- └── parse_obj() → model_validate()
154
-
155
- Scanning for library usage...
156
- Found 12 imports from pydantic
157
- Found 45 usages of pydantic symbols
158
-
159
- ┏━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━┓
160
- ┃ File ┃ Changes ┃ Status ┃
161
- ┡━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━┩
162
- │ src/models/user.py │ 5 │ Ready │
163
- │ src/api/schemas.py │ 3 │ Ready │
164
- └────────────────────┴─────────┴────────┘
165
-
166
- Total: 8 changes across 2 files
167
- ```
168
-
169
- ## Usage
170
-
171
- ### Scan Command
172
-
173
- Scan your entire project for possible dependency migrations:
174
-
175
- ```bash
176
- pyresolve scan
177
-
178
- # Options:
179
- # --path, -p Path to scan (default: current directory)
180
- # --fetch-changes Fetch changelogs and detect breaking changes (slower)
181
- # --major-only Only show major version upgrades
182
- # --json-output Output results as JSON
183
- # --verbose, -v Show detailed output
184
- ```
185
-
186
- Example output:
187
-
188
- ```bash
189
- $ pyresolve scan
190
-
191
- Found 13 dependencies
192
-
193
- Outdated Dependencies (5)
194
- ┏━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━┳━━━━━━━┳━━━━━━━━━━┓
195
- ┃ Package ┃ Current ┃ Latest ┃ Type ┃ Tier ┃
196
- ┡━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━╇━━━━━━━╇━━━━━━━━━━┩
197
- │ pydantic │ 1.0 │ 2.5.0 │ Major │ Tier 1 │
198
- │ rich │ 13.0 │ 14.0.0 │ Major │ Tier 2/3 │
199
- └────────────┴─────────┴────────┴───────┴──────────┘
200
-
201
- Suggested Migrations (2)
202
- pydantic 1.0 → 2.5.0 (Tier 1 - deterministic)
203
- rich 13.0 → 14.0.0 (Tier 2/3 - LLM-assisted)
204
-
205
- Quick commands:
206
- pyresolve upgrade pydantic --target 2.5.0
207
- pyresolve upgrade rich --target 14.0.0
208
- ```
209
-
210
- ### Upgrade Command
211
-
212
- Analyze your codebase and propose changes for a library upgrade:
213
-
214
- ```bash
215
- pyresolve upgrade <library> --target <version>
216
-
217
- # Options:
218
- # --target, -t Target version to upgrade to
219
- # --path, -p Path to analyze (default: current directory)
220
- # --dry-run Show what would be changed without saving state
221
- ```
222
-
223
- ### Diff Command
224
-
225
- View the detailed diff of proposed changes:
226
-
227
- ```bash
228
- pyresolve diff
229
-
230
- # Options:
231
- # --file, -f Show diff for specific file only
232
- # --no-color Disable colored output
233
- ```
234
-
235
- ### Apply Command
236
-
237
- Apply the proposed changes to your files:
238
-
239
- ```bash
240
- pyresolve apply
241
-
242
- # Options:
243
- # --backup Create backup files before applying changes
244
- # --file, -f Apply changes to specific file only
245
- ```
246
-
247
- ### Upgrade-All Command
248
-
249
- Upgrade all outdated packages to their latest versions in one go:
250
-
251
- ```bash
252
- pyresolve upgrade-all
253
-
254
- # Options:
255
- # --all, -a Include all outdated packages (not just Tier 1)
256
- # --path, -p Path to analyze (default: current directory)
257
- # --dry-run Show what would be changed without saving state
258
- ```
259
-
260
- ### Libraries Command
261
-
262
- List all supported libraries and their migration paths:
263
-
264
- ```bash
265
- pyresolve libraries
266
- ```
267
-
268
- ### Status Command
269
-
270
- Show current migration status, pending changes, and quota information:
271
-
272
- ```bash
273
- pyresolve status
274
- ```
275
-
276
- ## How It Works
277
-
278
- ```text
279
- ┌─────────────────────────────────────────────────────────────────────┐
280
- │ Knowledge Acquisition Pipeline │
281
- │ ┌─────────────┐ ┌──────────────────┐ ┌─────────────────────┐ │
282
- │ │ Local Cache │──▶│ On-Demand Gen │──▶│ LLM Parser │ │
283
- │ │ (instant) │ │ (fetches sources)│ │ (breaking changes) │ │
284
- │ └─────────────┘ └──────────────────┘ └─────────────────────┘ │
285
- │ │ │
286
- │ ┌───────────────┴───────────────┐ │
287
- │ │ Source Fetchers │ │
288
- │ │ ├── GitHub (CHANGELOG.md) │ │
289
- │ │ ├── Docs (migration guides) │ │
290
- │ │ └── Release notes │ │
291
- │ └───────────────────────────────┘ │
292
- └─────────────────────────────────────────────────────────────────────┘
293
-
294
-
295
- ┌─────────────────────────────────────────────────────────────────────┐
296
- │ Migration Engine (Tiered) │
297
- │ Tier 1: AST Transforms │ Tier 2: KB-Guided │ Tier 3: LLM │
298
- │ (deterministic) │ (context + LLM) │ (fallback) │
299
- └─────────────────────────────────────────────────────────────────────┘
300
- ```
301
-
302
- 1. **Fetch Knowledge**: Discovers and fetches changelogs, migration guides from GitHub/PyPI
303
- 2. **Parse Changes**: Uses LLM to extract breaking changes with confidence levels (HIGH/MEDIUM/LOW)
304
- 3. **Scan Codebase**: Finds imports and usage of the target library
305
- 4. **Tiered Migration**:
306
- - **Tier 1**: Deterministic AST transforms for 15 supported libraries (Pydantic, FastAPI, SQLAlchemy, Django, Flask, NumPy, Pandas, Requests, attrs, Celery, Click, aiohttp, httpx, Marshmallow, pytest)
307
- - **Tier 2**: Knowledge base guided migration with LLM assistance
308
- - **Tier 3**: Pure LLM migration for unknown patterns
309
- 5. **Validate**: Runs syntax checks and optionally your test suite
310
- 6. **Report**: Shows a detailed diff with explanations for each change
311
-
312
- ## Pydantic v1 → v2 Transforms
313
-
314
- PyResolve handles the following Pydantic migrations automatically:
315
-
316
- - `Config` class → `model_config = ConfigDict(...)`
317
- - `@validator` → `@field_validator` with `@classmethod`
318
- - `@root_validator` → `@model_validator`
319
- - `.dict()` → `.model_dump()`
320
- - `.json()` → `.model_dump_json()`
321
- - `.schema()` → `.model_json_schema()`
322
- - `.parse_obj()` → `.model_validate()`
323
- - `orm_mode = True` → `from_attributes = True`
324
- - `Field(regex=...)` → `Field(pattern=...)`
325
-
326
- ## Configuration
327
-
328
- PyResolve can be configured via `pyproject.toml`:
329
-
330
- ```toml
331
- [tool.pyresolve]
332
- # Path patterns to exclude from scanning (defaults: .pyresolve/*, tests/*, .venv/*, venv/*)
333
- exclude = ["tests/*", "migrations/*"]
334
-
335
- # Enable/disable LLM fallback
336
- use_llm = true
337
-
338
- # Anthropic API key (can also use ANTHROPIC_API_KEY env var)
339
- # anthropic_api_key = "sk-..."
340
- ```
341
-
342
- ## Pricing
343
-
344
- PyResolve uses a tiered pricing model:
345
-
346
- | Tier | Price | Features |
347
- |------|-------|----------|
348
- | **Free** | $0/month | Tier 1 deterministic transforms (15 libraries including Pydantic, Django, Flask, SQLAlchemy, and more) |
349
- | **Pro** | $19/month | Tier 2 KB-guided LLM migrations for any library |
350
- | **Unlimited** | $49/month | Tier 3 pure LLM migrations + priority support |
351
-
352
- **How it works:**
353
- - **Tier 1 (Free)**: Runs entirely locally using deterministic AST transforms. No account required.
354
- - **Tier 2/3 (Paid)**: LLM-powered migrations are processed through the PyResolve API to ensure quality and manage costs.
355
-
356
- ```bash
357
- # Login to access Pro/Unlimited features
358
- pyresolve login
359
-
360
- # Check your current plan and usage
361
- pyresolve quota
362
- ```
363
-
364
- ## License
365
-
366
- This software is licensed under the [MIT License](LICENSE).
367
-
368
- You are free to use, modify, and distribute this software. The CLI tool and all transforms are fully open source.