migrator-gen 1.0.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.
- migrator_gen-1.0.0/.gitignore +72 -0
- migrator_gen-1.0.0/LICENSE +21 -0
- migrator_gen-1.0.0/PKG-INFO +204 -0
- migrator_gen-1.0.0/README.md +163 -0
- migrator_gen-1.0.0/pyproject.toml +74 -0
- migrator_gen-1.0.0/src/migrator_gen/__init__.py +78 -0
- migrator_gen-1.0.0/src/migrator_gen/_version.py +15 -0
- migrator_gen-1.0.0/src/migrator_gen/api/__init__.py +2 -0
- migrator_gen-1.0.0/src/migrator_gen/api/client_async.py +169 -0
- migrator_gen-1.0.0/src/migrator_gen/api/client_sync.py +160 -0
- migrator_gen-1.0.0/src/migrator_gen/config/__init__.py +1 -0
- migrator_gen-1.0.0/src/migrator_gen/config/settings.py +128 -0
- migrator_gen-1.0.0/src/migrator_gen/core/__init__.py +104 -0
- migrator_gen-1.0.0/src/migrator_gen/core/changelog_parser.py +240 -0
- migrator_gen-1.0.0/src/migrator_gen/core/constants.py +67 -0
- migrator_gen-1.0.0/src/migrator_gen/core/diff_analyzer.py +658 -0
- migrator_gen-1.0.0/src/migrator_gen/core/llm_engine.py +442 -0
- migrator_gen-1.0.0/src/migrator_gen/core/migration_engine.py +708 -0
- migrator_gen-1.0.0/src/migrator_gen/core/migrator_generator.py +579 -0
- migrator_gen-1.0.0/src/migrator_gen/core/models.py +195 -0
- migrator_gen-1.0.0/src/migrator_gen/core/parallel_engine.py +349 -0
- migrator_gen-1.0.0/src/migrator_gen/core/protocols.py +172 -0
- migrator_gen-1.0.0/src/migrator_gen/core/symbol_resolver.py +423 -0
- migrator_gen-1.0.0/src/migrator_gen/core/transformers.py +569 -0
- migrator_gen-1.0.0/src/migrator_gen/core/transformers_advanced.py +628 -0
- migrator_gen-1.0.0/src/migrator_gen/core/validation.py +804 -0
- migrator_gen-1.0.0/src/migrator_gen/core/version_resolver.py +172 -0
- migrator_gen-1.0.0/src/migrator_gen/exceptions/__init__.py +16 -0
- migrator_gen-1.0.0/src/migrator_gen/exceptions/errors.py +83 -0
- migrator_gen-1.0.0/src/migrator_gen/py.typed +0 -0
- migrator_gen-1.0.0/src/migrator_gen/services/__init__.py +2 -0
- migrator_gen-1.0.0/src/migrator_gen/services/local_service.py +491 -0
- migrator_gen-1.0.0/src/migrator_gen/services/remote_service.py +403 -0
- migrator_gen-1.0.0/src/migrator_gen/utils/__init__.py +2 -0
- migrator_gen-1.0.0/src/migrator_gen/utils/retry.py +72 -0
- migrator_gen-1.0.0/src/migrator_gen/utils/serialization.py +35 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# ── OS ──────────────────────────────────────────────
|
|
2
|
+
.DS_Store
|
|
3
|
+
Thumbs.db
|
|
4
|
+
*.swp
|
|
5
|
+
*.swo
|
|
6
|
+
*~
|
|
7
|
+
|
|
8
|
+
# ── IDE ─────────────────────────────────────────────
|
|
9
|
+
.vscode/
|
|
10
|
+
.idea/
|
|
11
|
+
*.code-workspace
|
|
12
|
+
|
|
13
|
+
# ── Environment ─────────────────────────────────────
|
|
14
|
+
.env
|
|
15
|
+
.env.*
|
|
16
|
+
!.env.example
|
|
17
|
+
!.env.test
|
|
18
|
+
|
|
19
|
+
# ── Python ──────────────────────────────────────────
|
|
20
|
+
.venv/
|
|
21
|
+
__pycache__/
|
|
22
|
+
*.pyc
|
|
23
|
+
*.pyo
|
|
24
|
+
*.egg-info/
|
|
25
|
+
dist/
|
|
26
|
+
build/
|
|
27
|
+
.coverage
|
|
28
|
+
htmlcov/
|
|
29
|
+
.pytest_cache/
|
|
30
|
+
.mypy_cache/
|
|
31
|
+
.ruff_cache/
|
|
32
|
+
*.bak
|
|
33
|
+
bandit-report.json
|
|
34
|
+
safety_report.json
|
|
35
|
+
pip_audit_report.json
|
|
36
|
+
|
|
37
|
+
# ── Node / Next.js ─────────────────────────────────
|
|
38
|
+
node_modules/
|
|
39
|
+
.next/
|
|
40
|
+
out/
|
|
41
|
+
.pnp
|
|
42
|
+
.pnp.*
|
|
43
|
+
.yarn/*
|
|
44
|
+
!.yarn/patches
|
|
45
|
+
!.yarn/plugins
|
|
46
|
+
!.yarn/releases
|
|
47
|
+
!.yarn/versions
|
|
48
|
+
*.tsbuildinfo
|
|
49
|
+
next-env.d.ts
|
|
50
|
+
npm-debug.log*
|
|
51
|
+
yarn-debug.log*
|
|
52
|
+
yarn-error.log*
|
|
53
|
+
.pnpm-debug.log*
|
|
54
|
+
|
|
55
|
+
# ── Project-specific ────────────────────────────────
|
|
56
|
+
# Generated output
|
|
57
|
+
generated/
|
|
58
|
+
generated_migrator/
|
|
59
|
+
generated_migrator_md/
|
|
60
|
+
|
|
61
|
+
# Auth DB (local dev)
|
|
62
|
+
webapp/auth.db
|
|
63
|
+
webapp/data/user-packs/*.json
|
|
64
|
+
|
|
65
|
+
# Synced engine files (copied from sdk/python at build time)
|
|
66
|
+
webapp/python/engine/
|
|
67
|
+
|
|
68
|
+
# Vercel
|
|
69
|
+
.vercel/
|
|
70
|
+
|
|
71
|
+
# Coverage
|
|
72
|
+
webapp/coverage/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2026 Aayush Gid
|
|
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.
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: migrator-gen
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Python SDK for MigratorGen — automatically migrate Python code across library versions
|
|
5
|
+
Project-URL: Homepage, https://github.com/aayush598/MigratorGen
|
|
6
|
+
Project-URL: Repository, https://github.com/aayush598/MigratorGen
|
|
7
|
+
Project-URL: Issues, https://github.com/aayush598/MigratorGen/issues
|
|
8
|
+
Project-URL: Documentation, https://github.com/aayush598/MigratorGen#readme
|
|
9
|
+
Author-email: Aayush Gid <aayushgid598@gmail.com>
|
|
10
|
+
License: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: ast,codemod,libcst,migration,migrator-gen,sdk
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
|
+
Classifier: Topic :: Utilities
|
|
24
|
+
Classifier: Typing :: Typed
|
|
25
|
+
Requires-Python: >=3.10
|
|
26
|
+
Requires-Dist: pydantic>=2.0.0
|
|
27
|
+
Requires-Dist: pyyaml>=6.0
|
|
28
|
+
Provides-Extra: all
|
|
29
|
+
Requires-Dist: httpx>=0.27.0; extra == 'all'
|
|
30
|
+
Requires-Dist: libcst>=1.0.0; extra == 'all'
|
|
31
|
+
Provides-Extra: dev
|
|
32
|
+
Requires-Dist: mypy>=1.8; extra == 'dev'
|
|
33
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
|
|
34
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
35
|
+
Requires-Dist: ruff>=0.3; extra == 'dev'
|
|
36
|
+
Provides-Extra: local
|
|
37
|
+
Requires-Dist: libcst>=1.0.0; extra == 'local'
|
|
38
|
+
Provides-Extra: remote
|
|
39
|
+
Requires-Dist: httpx>=0.27.0; extra == 'remote'
|
|
40
|
+
Description-Content-Type: text/markdown
|
|
41
|
+
|
|
42
|
+
# migrator-gen
|
|
43
|
+
|
|
44
|
+
[](https://pypi.org/project/migrator-gen/)
|
|
45
|
+
[](https://pypi.org/project/migrator-gen/)
|
|
46
|
+
[](https://opensource.org/licenses/MIT)
|
|
47
|
+
|
|
48
|
+
Python SDK for **MigratorGen** — automatically migrate Python code across library versions using structured changelog rules and AST-accurate transformations.
|
|
49
|
+
|
|
50
|
+
## Features
|
|
51
|
+
|
|
52
|
+
- **Transactional migrations** — atomic all-or-nothing file modifications with checkpoint-based rollback
|
|
53
|
+
- **AST-aware transformations** — powered by [LibCST](https://github.com/Instagram/LibCST) for syntax-tree-level precision
|
|
54
|
+
- **Idempotency guards** — safe to re-run migrations without duplicating changes
|
|
55
|
+
- **Confidence scoring** — per-rule confidence metrics and safety classification (`safe` / `review_required` / `risky`)
|
|
56
|
+
- **Structured changelogs** — JSON-based rule packs describing renames, argument changes, module moves, and more
|
|
57
|
+
- **Sync and async clients** — use locally or connect to a remote MigratorGen API server
|
|
58
|
+
|
|
59
|
+
## Installation
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
pip install migrator-gen
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
For the full local engine (LibCST-based transformations):
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
pip install migrator-gen[local]
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
For remote API access:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
pip install migrator-gen[remote]
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Quick Start
|
|
78
|
+
|
|
79
|
+
### Local Engine
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
from migrator_gen import SyncMigrationClient, Rule, ChangeType
|
|
83
|
+
|
|
84
|
+
client = SyncMigrationClient()
|
|
85
|
+
|
|
86
|
+
# Define a migration rule
|
|
87
|
+
rule = Rule(
|
|
88
|
+
id="REQ-001",
|
|
89
|
+
change_type=ChangeType.RENAME_FUNCTION,
|
|
90
|
+
description="requests.get renamed to httpx.get",
|
|
91
|
+
old_name="requests.get",
|
|
92
|
+
new_name="httpx.get",
|
|
93
|
+
version_introduced="2.0.0",
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
# Migrate code
|
|
97
|
+
result = client.migrate_code(
|
|
98
|
+
source_code="import requests\nresp = requests.get(url)",
|
|
99
|
+
rules=[rule],
|
|
100
|
+
target_version="2.0.0",
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
print(result.transformed_code)
|
|
104
|
+
# import httpx
|
|
105
|
+
# resp = httpx.get(url)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Remote API
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
from migrator_gen import MigrationClient
|
|
112
|
+
|
|
113
|
+
async with MigrationClient(base_url="https://api.migratorgen.dev") as client:
|
|
114
|
+
result = await client.migrate(
|
|
115
|
+
source_code=open("my_app.py").read(),
|
|
116
|
+
rules=open("migration-pack.json").read(),
|
|
117
|
+
target_version="2.0.0",
|
|
118
|
+
)
|
|
119
|
+
print(result.transformed_code)
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Preview Changes (Dry Run)
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
preview = client.preview_migration(source_code, rules)
|
|
126
|
+
print(preview) # Unified diff output
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Validate Rules
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
report = client.validate_rules("migration-pack.json")
|
|
133
|
+
if report.valid:
|
|
134
|
+
print("All rules are valid")
|
|
135
|
+
else:
|
|
136
|
+
for error in report.errors:
|
|
137
|
+
print(f"Error: {error}")
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Rule Structure
|
|
141
|
+
|
|
142
|
+
Rules are defined as JSON objects conforming to the `MigrationRule` schema:
|
|
143
|
+
|
|
144
|
+
```json
|
|
145
|
+
{
|
|
146
|
+
"id": "H001",
|
|
147
|
+
"change_type": "rename_function",
|
|
148
|
+
"version_introduced": "1.0.0",
|
|
149
|
+
"description": "Rename escape() to html.escape()",
|
|
150
|
+
"old_name": "cgi.escape",
|
|
151
|
+
"new_name": "html.escape",
|
|
152
|
+
"safety": "safe",
|
|
153
|
+
"confidence_hint": "high"
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Supported Change Types
|
|
158
|
+
|
|
159
|
+
| Change Type | Description |
|
|
160
|
+
|---|---|
|
|
161
|
+
| `rename_function` | Rename a function or method |
|
|
162
|
+
| `rename_class` | Rename a class |
|
|
163
|
+
| `rename_import` | Update import path |
|
|
164
|
+
| `add_argument` | Add a new function argument |
|
|
165
|
+
| `remove_argument` | Remove a function argument |
|
|
166
|
+
| `rename_argument` | Rename a function argument |
|
|
167
|
+
| `change_argument_default` | Change a default parameter value |
|
|
168
|
+
| `deprecate_function` | Mark a function as deprecated |
|
|
169
|
+
| `move_to_module` | Move code to a different module |
|
|
170
|
+
| `wrap_in_context_manager` | Wrap a call in a context manager |
|
|
171
|
+
| `sync_to_async` | Convert sync code to async |
|
|
172
|
+
| `enum_migration` | Migrate enum definitions |
|
|
173
|
+
|
|
174
|
+
See `migrator_gen.core.constants.ChangeType` for the full list.
|
|
175
|
+
|
|
176
|
+
## Configuration
|
|
177
|
+
|
|
178
|
+
```python
|
|
179
|
+
from migrator_gen import SDKConfig
|
|
180
|
+
|
|
181
|
+
config = SDKConfig(
|
|
182
|
+
base_url="https://api.migratorgen.dev",
|
|
183
|
+
timeout=30,
|
|
184
|
+
max_retries=3,
|
|
185
|
+
)
|
|
186
|
+
client = SyncMigrationClient(config=config)
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Development
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
git clone https://github.com/aayush598/MigratorGen.git
|
|
193
|
+
cd MigratorGen/sdk/python
|
|
194
|
+
pip install -e ".[dev]"
|
|
195
|
+
pytest
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## License
|
|
199
|
+
|
|
200
|
+
MIT License. See [LICENSE](LICENSE) for details.
|
|
201
|
+
|
|
202
|
+
## Author
|
|
203
|
+
|
|
204
|
+
**Aayush Gid** — [GitHub](https://github.com/aayush598) · [LinkedIn](https://www.linkedin.com/in/aayush-gid)
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# migrator-gen
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/migrator-gen/)
|
|
4
|
+
[](https://pypi.org/project/migrator-gen/)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
|
|
7
|
+
Python SDK for **MigratorGen** — automatically migrate Python code across library versions using structured changelog rules and AST-accurate transformations.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- **Transactional migrations** — atomic all-or-nothing file modifications with checkpoint-based rollback
|
|
12
|
+
- **AST-aware transformations** — powered by [LibCST](https://github.com/Instagram/LibCST) for syntax-tree-level precision
|
|
13
|
+
- **Idempotency guards** — safe to re-run migrations without duplicating changes
|
|
14
|
+
- **Confidence scoring** — per-rule confidence metrics and safety classification (`safe` / `review_required` / `risky`)
|
|
15
|
+
- **Structured changelogs** — JSON-based rule packs describing renames, argument changes, module moves, and more
|
|
16
|
+
- **Sync and async clients** — use locally or connect to a remote MigratorGen API server
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install migrator-gen
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
For the full local engine (LibCST-based transformations):
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pip install migrator-gen[local]
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
For remote API access:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pip install migrator-gen[remote]
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Quick Start
|
|
37
|
+
|
|
38
|
+
### Local Engine
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
from migrator_gen import SyncMigrationClient, Rule, ChangeType
|
|
42
|
+
|
|
43
|
+
client = SyncMigrationClient()
|
|
44
|
+
|
|
45
|
+
# Define a migration rule
|
|
46
|
+
rule = Rule(
|
|
47
|
+
id="REQ-001",
|
|
48
|
+
change_type=ChangeType.RENAME_FUNCTION,
|
|
49
|
+
description="requests.get renamed to httpx.get",
|
|
50
|
+
old_name="requests.get",
|
|
51
|
+
new_name="httpx.get",
|
|
52
|
+
version_introduced="2.0.0",
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
# Migrate code
|
|
56
|
+
result = client.migrate_code(
|
|
57
|
+
source_code="import requests\nresp = requests.get(url)",
|
|
58
|
+
rules=[rule],
|
|
59
|
+
target_version="2.0.0",
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
print(result.transformed_code)
|
|
63
|
+
# import httpx
|
|
64
|
+
# resp = httpx.get(url)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Remote API
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from migrator_gen import MigrationClient
|
|
71
|
+
|
|
72
|
+
async with MigrationClient(base_url="https://api.migratorgen.dev") as client:
|
|
73
|
+
result = await client.migrate(
|
|
74
|
+
source_code=open("my_app.py").read(),
|
|
75
|
+
rules=open("migration-pack.json").read(),
|
|
76
|
+
target_version="2.0.0",
|
|
77
|
+
)
|
|
78
|
+
print(result.transformed_code)
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Preview Changes (Dry Run)
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
preview = client.preview_migration(source_code, rules)
|
|
85
|
+
print(preview) # Unified diff output
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Validate Rules
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
report = client.validate_rules("migration-pack.json")
|
|
92
|
+
if report.valid:
|
|
93
|
+
print("All rules are valid")
|
|
94
|
+
else:
|
|
95
|
+
for error in report.errors:
|
|
96
|
+
print(f"Error: {error}")
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Rule Structure
|
|
100
|
+
|
|
101
|
+
Rules are defined as JSON objects conforming to the `MigrationRule` schema:
|
|
102
|
+
|
|
103
|
+
```json
|
|
104
|
+
{
|
|
105
|
+
"id": "H001",
|
|
106
|
+
"change_type": "rename_function",
|
|
107
|
+
"version_introduced": "1.0.0",
|
|
108
|
+
"description": "Rename escape() to html.escape()",
|
|
109
|
+
"old_name": "cgi.escape",
|
|
110
|
+
"new_name": "html.escape",
|
|
111
|
+
"safety": "safe",
|
|
112
|
+
"confidence_hint": "high"
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Supported Change Types
|
|
117
|
+
|
|
118
|
+
| Change Type | Description |
|
|
119
|
+
|---|---|
|
|
120
|
+
| `rename_function` | Rename a function or method |
|
|
121
|
+
| `rename_class` | Rename a class |
|
|
122
|
+
| `rename_import` | Update import path |
|
|
123
|
+
| `add_argument` | Add a new function argument |
|
|
124
|
+
| `remove_argument` | Remove a function argument |
|
|
125
|
+
| `rename_argument` | Rename a function argument |
|
|
126
|
+
| `change_argument_default` | Change a default parameter value |
|
|
127
|
+
| `deprecate_function` | Mark a function as deprecated |
|
|
128
|
+
| `move_to_module` | Move code to a different module |
|
|
129
|
+
| `wrap_in_context_manager` | Wrap a call in a context manager |
|
|
130
|
+
| `sync_to_async` | Convert sync code to async |
|
|
131
|
+
| `enum_migration` | Migrate enum definitions |
|
|
132
|
+
|
|
133
|
+
See `migrator_gen.core.constants.ChangeType` for the full list.
|
|
134
|
+
|
|
135
|
+
## Configuration
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
from migrator_gen import SDKConfig
|
|
139
|
+
|
|
140
|
+
config = SDKConfig(
|
|
141
|
+
base_url="https://api.migratorgen.dev",
|
|
142
|
+
timeout=30,
|
|
143
|
+
max_retries=3,
|
|
144
|
+
)
|
|
145
|
+
client = SyncMigrationClient(config=config)
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Development
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
git clone https://github.com/aayush598/MigratorGen.git
|
|
152
|
+
cd MigratorGen/sdk/python
|
|
153
|
+
pip install -e ".[dev]"
|
|
154
|
+
pytest
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## License
|
|
158
|
+
|
|
159
|
+
MIT License. See [LICENSE](LICENSE) for details.
|
|
160
|
+
|
|
161
|
+
## Author
|
|
162
|
+
|
|
163
|
+
**Aayush Gid** — [GitHub](https://github.com/aayush598) · [LinkedIn](https://www.linkedin.com/in/aayush-gid)
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "migrator-gen"
|
|
3
|
+
version = "1.0.0"
|
|
4
|
+
description = "Python SDK for MigratorGen — automatically migrate Python code across library versions"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.10"
|
|
7
|
+
license = {text = "MIT"}
|
|
8
|
+
authors = [
|
|
9
|
+
{name = "Aayush Gid", email = "aayushgid598@gmail.com"},
|
|
10
|
+
]
|
|
11
|
+
keywords = ["migrator-gen", "migration", "codemod", "libcst", "sdk", "ast"]
|
|
12
|
+
classifiers = [
|
|
13
|
+
"Development Status :: 4 - Beta",
|
|
14
|
+
"Intended Audience :: Developers",
|
|
15
|
+
"License :: OSI Approved :: MIT License",
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
18
|
+
"Programming Language :: Python :: 3.10",
|
|
19
|
+
"Programming Language :: Python :: 3.11",
|
|
20
|
+
"Programming Language :: Python :: 3.12",
|
|
21
|
+
"Programming Language :: Python :: 3.13",
|
|
22
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
23
|
+
"Topic :: Utilities",
|
|
24
|
+
"Typing :: Typed",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
dependencies = [
|
|
28
|
+
"pydantic>=2.0.0",
|
|
29
|
+
"PyYAML>=6.0",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[project.optional-dependencies]
|
|
33
|
+
local = ["libcst>=1.0.0"]
|
|
34
|
+
remote = ["httpx>=0.27.0"]
|
|
35
|
+
all = ["migrator-gen[local,remote]"]
|
|
36
|
+
dev = [
|
|
37
|
+
"pytest>=8.0",
|
|
38
|
+
"pytest-asyncio>=0.23",
|
|
39
|
+
"ruff>=0.3",
|
|
40
|
+
"mypy>=1.8",
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
[project.urls]
|
|
44
|
+
Homepage = "https://github.com/aayush598/MigratorGen"
|
|
45
|
+
Repository = "https://github.com/aayush598/MigratorGen"
|
|
46
|
+
Issues = "https://github.com/aayush598/MigratorGen/issues"
|
|
47
|
+
Documentation = "https://github.com/aayush598/MigratorGen#readme"
|
|
48
|
+
|
|
49
|
+
[build-system]
|
|
50
|
+
requires = ["hatchling"]
|
|
51
|
+
build-backend = "hatchling.build"
|
|
52
|
+
|
|
53
|
+
[tool.hatch.build.targets.wheel]
|
|
54
|
+
packages = ["src/migrator_gen"]
|
|
55
|
+
|
|
56
|
+
[tool.hatch.build.targets.sdist]
|
|
57
|
+
include = ["/src"]
|
|
58
|
+
|
|
59
|
+
[tool.pytest.ini_options]
|
|
60
|
+
testpaths = ["tests"]
|
|
61
|
+
python_files = ["test_*.py"]
|
|
62
|
+
addopts = "-v --tb=short"
|
|
63
|
+
asyncio_mode = "auto"
|
|
64
|
+
|
|
65
|
+
[tool.ruff]
|
|
66
|
+
line-length = 100
|
|
67
|
+
target-version = "py310"
|
|
68
|
+
lint.select = ["E", "F", "W", "I", "N", "UP", "B", "C4"]
|
|
69
|
+
lint.ignore = ["E501"]
|
|
70
|
+
lint.per-file-ignores = {"__init__.py" = ["F401"]}
|
|
71
|
+
|
|
72
|
+
[tool.mypy]
|
|
73
|
+
python_version = "3.10"
|
|
74
|
+
ignore_missing_imports = true
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
from ._version import __version__
|
|
2
|
+
from .api import MigrationClient, SyncMigrationClient
|
|
3
|
+
from .config import SDKConfig
|
|
4
|
+
from .core import (
|
|
5
|
+
ChangeType,
|
|
6
|
+
DiffPreview,
|
|
7
|
+
EngineMode,
|
|
8
|
+
HealthStatus,
|
|
9
|
+
LibraryInfo,
|
|
10
|
+
MigrateResponse,
|
|
11
|
+
MigrationFile,
|
|
12
|
+
MigrationJob,
|
|
13
|
+
MigrationReport,
|
|
14
|
+
MigrationStatus,
|
|
15
|
+
MigrationStep,
|
|
16
|
+
ResolvedPath,
|
|
17
|
+
Rule,
|
|
18
|
+
RuleResultSummary,
|
|
19
|
+
RuleWhenCondition,
|
|
20
|
+
SafetyLevel,
|
|
21
|
+
ValidationReport,
|
|
22
|
+
VersionChangelog,
|
|
23
|
+
)
|
|
24
|
+
from .exceptions import (
|
|
25
|
+
APIError,
|
|
26
|
+
AuthenticationError,
|
|
27
|
+
ConfigurationError,
|
|
28
|
+
ConflictError,
|
|
29
|
+
EngineError,
|
|
30
|
+
MigrationEngineError,
|
|
31
|
+
MigrationError,
|
|
32
|
+
MigrationParseError,
|
|
33
|
+
MigrationValidationError,
|
|
34
|
+
NotFoundError,
|
|
35
|
+
RateLimitError,
|
|
36
|
+
SDKError,
|
|
37
|
+
TimeoutError,
|
|
38
|
+
ValidationError,
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
__all__ = [
|
|
42
|
+
"__version__",
|
|
43
|
+
"MigrationClient",
|
|
44
|
+
"SyncMigrationClient",
|
|
45
|
+
"SDKConfig",
|
|
46
|
+
"ChangeType",
|
|
47
|
+
"SafetyLevel",
|
|
48
|
+
"MigrationStatus",
|
|
49
|
+
"EngineMode",
|
|
50
|
+
"Rule",
|
|
51
|
+
"RuleWhenCondition",
|
|
52
|
+
"VersionChangelog",
|
|
53
|
+
"MigrationFile",
|
|
54
|
+
"LibraryInfo",
|
|
55
|
+
"RuleResultSummary",
|
|
56
|
+
"MigrateResponse",
|
|
57
|
+
"DiffPreview",
|
|
58
|
+
"ValidationReport",
|
|
59
|
+
"MigrationJob",
|
|
60
|
+
"MigrationReport",
|
|
61
|
+
"MigrationStep",
|
|
62
|
+
"ResolvedPath",
|
|
63
|
+
"HealthStatus",
|
|
64
|
+
"SDKError",
|
|
65
|
+
"ConfigurationError",
|
|
66
|
+
"APIError",
|
|
67
|
+
"AuthenticationError",
|
|
68
|
+
"RateLimitError",
|
|
69
|
+
"ValidationError",
|
|
70
|
+
"NotFoundError",
|
|
71
|
+
"ConflictError",
|
|
72
|
+
"MigrationError",
|
|
73
|
+
"MigrationParseError",
|
|
74
|
+
"MigrationValidationError",
|
|
75
|
+
"MigrationEngineError",
|
|
76
|
+
"EngineError",
|
|
77
|
+
"TimeoutError",
|
|
78
|
+
]
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from importlib.metadata import PackageNotFoundError
|
|
4
|
+
from importlib.metadata import version as _pkg_version
|
|
5
|
+
|
|
6
|
+
__version__: str
|
|
7
|
+
try:
|
|
8
|
+
__version__ = _pkg_version("migrator-gen")
|
|
9
|
+
except PackageNotFoundError:
|
|
10
|
+
__version__ = "1.0.0"
|
|
11
|
+
|
|
12
|
+
VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH = (int(x) for x in __version__.split(".")[:3])
|
|
13
|
+
VERSION_TRIPLE: str = f"{VERSION_MAJOR}.{VERSION_MINOR}.{VERSION_PATCH}"
|
|
14
|
+
SDK_NAME: str = "migrator-gen"
|
|
15
|
+
USER_AGENT: str = f"migrator-gen-sdk/{__version__}"
|