vyupgrade 0.1.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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 banteg
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,176 @@
1
+ Metadata-Version: 2.3
2
+ Name: vyupgrade
3
+ Version: 0.1.0
4
+ Summary: Compiler-backed tool for upgrading Vyper contracts.
5
+ Keywords: codemod,migration,smart-contracts,vyper
6
+ Author: banteg
7
+ License: MIT License
8
+
9
+ Copyright (c) 2026 banteg
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
28
+ Classifier: Development Status :: 3 - Alpha
29
+ Classifier: Environment :: Console
30
+ Classifier: Intended Audience :: Developers
31
+ Classifier: License :: OSI Approved :: MIT License
32
+ Classifier: Programming Language :: Python :: 3
33
+ Classifier: Programming Language :: Python :: 3.11
34
+ Classifier: Topic :: Software Development :: Compilers
35
+ Classifier: Topic :: Software Development :: Quality Assurance
36
+ Requires-Dist: rich>=13.0.0
37
+ Requires-Dist: uv>=0.8.0
38
+ Requires-Python: >=3.11
39
+ Project-URL: Homepage, https://github.com/banteg/vyupgrade
40
+ Project-URL: Repository, https://github.com/banteg/vyupgrade
41
+ Project-URL: Issues, https://github.com/banteg/vyupgrade/issues
42
+ Project-URL: Changelog, https://github.com/banteg/vyupgrade/blob/master/CHANGELOG.md
43
+ Description-Content-Type: text/markdown
44
+
45
+ # vyupgrade
46
+
47
+ A compiler-backed tool for upgrading Vyper contracts across language
48
+ versions. It rewrites legacy syntax to a chosen target compiler, then proves the
49
+ rewrite is safe by compiling the source and the result and comparing their ABI,
50
+ method identifiers, and storage layout.
51
+
52
+ It covers the syntax changes from Vyper `0.2.1` through `0.4.3`. Rules are
53
+ version-gated: a given rewrite only fires when the migration from the source
54
+ version to the target version actually crosses the compiler release that
55
+ introduced the change.
56
+
57
+ ## Install
58
+
59
+ Run it once without installing:
60
+
61
+ ```bash
62
+ uvx vyupgrade contracts/
63
+ ```
64
+
65
+ Or install it as a tool:
66
+
67
+ ```bash
68
+ uv tool install vyupgrade
69
+ vyupgrade contracts/
70
+ ```
71
+
72
+ ## Usage
73
+
74
+ Preview the changes as a unified diff:
75
+
76
+ ```bash
77
+ vyupgrade contracts/ --diff
78
+ ```
79
+
80
+ Apply them in place and write a machine-readable report:
81
+
82
+ ```bash
83
+ vyupgrade contracts/ --write --report-json vyupgrade-report.json
84
+ ```
85
+
86
+ Fail without writing when files would change, for use in CI:
87
+
88
+ ```bash
89
+ vyupgrade contracts/ --check
90
+ ```
91
+
92
+ The target defaults to `0.4.3`; pass `--target-version` to migrate to a
93
+ different release.
94
+
95
+ Paths may be files or directories; directories are searched recursively for
96
+ `.vy` and `.vyi` sources. The source version is inferred per file from its
97
+ `#pragma version` (or legacy `# @version`) line. Pass `--source-version` to
98
+ override the inference for files that have no pragma.
99
+
100
+ ### How it validates
101
+
102
+ For each file, `vyupgrade` compiles the original under its source compiler and
103
+ the rewritten output under the target compiler, then compares the two
104
+ artifacts. A migration is only written back when every file still compiles
105
+ under the target. Differences in ABI, method identifiers, or storage layout are
106
+ surfaced as diagnostics rather than silently accepted.
107
+
108
+ Compiler subprocesses run through the bundled `uv`, using
109
+ `uv run --no-project --with vyper==<version>` so each side gets the exact
110
+ compiler it needs instead of inheriting an incompatible interpreter. When a file
111
+ belongs to another project, the nearest `pyproject.toml` is read and any
112
+ declared packages matching its Vyper imports (such as `snekmate`) are added to
113
+ the compiler environment.
114
+
115
+ Dependency inference is intentionally conservative. Exact requirements,
116
+ ordinary version ranges, and Git dependencies are supported. Project-specific
117
+ specifier syntaxes that cannot be translated to a compiler environment, such as
118
+ Poetry caret requirements, are skipped; use `--compiler-search-paths`,
119
+ `--source-vyper`, or `--target-vyper` for unusual layouts.
120
+
121
+ ## Options
122
+
123
+ - `--target-version` — target Vyper version or spec (default `0.4.3`).
124
+ - `--source-version` — override the per-file inferred source version.
125
+ - `--diff` — print a unified diff instead of the report.
126
+ - `--write` — apply changes in place (only when every file compiles).
127
+ - `--check` — exit non-zero if any file would change; write nothing.
128
+ - `--bump-pragma` — rewrite the pragma to the target so output compiles against the target compiler instead of preserving the original range.
129
+ - `--aggressive` — enable rewrites that change behavior or are not provably safe (e.g. `enum` → `flag`).
130
+ - `--select` / `--ignore` — comma-separated rule codes to include or exclude.
131
+ - `--report-json PATH` — write a JSON report of fixes, diagnostics, and validation results.
132
+ - `--format mamushi` — run `mamushi` over written files to reformat them.
133
+ - `--test-command CMD` — run a test command after a successful write and record its result.
134
+ - `--enable-decimals` — treat decimals as enabled when reasoning about `0.4.x` rules.
135
+ - `--source-vyper` / `--target-vyper` — pin the exact compiler version for each side.
136
+ - `--source-python` / `--target-python` — pin the Python interpreter for each compiler subprocess.
137
+ - `--compiler-search-paths` — extra import search paths for the compiler.
138
+ - `--config PATH` — read configuration from a specific `pyproject.toml`.
139
+
140
+ ### Configuration
141
+
142
+ Defaults can live in `pyproject.toml` under `[tool.vyupgrade]`. Command-line
143
+ flags take precedence.
144
+
145
+ ```toml
146
+ [tool.vyupgrade]
147
+ paths = ["contracts/"]
148
+ target-version = "0.4.3"
149
+ source-version = "infer"
150
+ report-json = "vyupgrade-report.json"
151
+ aggressive = false
152
+ format = "none"
153
+ ```
154
+
155
+ ### Exit codes
156
+
157
+ - `0` — success.
158
+ - `1` — `--check` found files that would change.
159
+ - `2` — a file failed to compile under the target compiler.
160
+ - `3` — a file failed to compile under the source compiler.
161
+ - `4` — usage error (no paths, or conflicting flags).
162
+ - `5` — an error-severity diagnostic was raised.
163
+
164
+ ## Coverage
165
+
166
+ Rewrites carry a `VY###` code and diagnostics a `VYD###` code. Where the source
167
+ intent cannot be proven safe, the change is reported as a manual-review
168
+ diagnostic instead of being applied.
169
+
170
+ - [docs/migration-coverage.md](docs/migration-coverage.md) — every syntax change
171
+ mapped to a rule, diagnostic, or explicit no-op.
172
+ - [docs/vyper-syntax-history.md](docs/vyper-syntax-history.md) — the versioned
173
+ Vyper syntax history from `0.4.3` back to `0.2.1`, with PR links and
174
+ before/after examples.
175
+ - [CHANGELOG.md](CHANGELOG.md) — release notes.
176
+ - [DEVELOPMENT.md](DEVELOPMENT.md) — maintainer validation and release workflow.
@@ -0,0 +1,132 @@
1
+ # vyupgrade
2
+
3
+ A compiler-backed tool for upgrading Vyper contracts across language
4
+ versions. It rewrites legacy syntax to a chosen target compiler, then proves the
5
+ rewrite is safe by compiling the source and the result and comparing their ABI,
6
+ method identifiers, and storage layout.
7
+
8
+ It covers the syntax changes from Vyper `0.2.1` through `0.4.3`. Rules are
9
+ version-gated: a given rewrite only fires when the migration from the source
10
+ version to the target version actually crosses the compiler release that
11
+ introduced the change.
12
+
13
+ ## Install
14
+
15
+ Run it once without installing:
16
+
17
+ ```bash
18
+ uvx vyupgrade contracts/
19
+ ```
20
+
21
+ Or install it as a tool:
22
+
23
+ ```bash
24
+ uv tool install vyupgrade
25
+ vyupgrade contracts/
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ Preview the changes as a unified diff:
31
+
32
+ ```bash
33
+ vyupgrade contracts/ --diff
34
+ ```
35
+
36
+ Apply them in place and write a machine-readable report:
37
+
38
+ ```bash
39
+ vyupgrade contracts/ --write --report-json vyupgrade-report.json
40
+ ```
41
+
42
+ Fail without writing when files would change, for use in CI:
43
+
44
+ ```bash
45
+ vyupgrade contracts/ --check
46
+ ```
47
+
48
+ The target defaults to `0.4.3`; pass `--target-version` to migrate to a
49
+ different release.
50
+
51
+ Paths may be files or directories; directories are searched recursively for
52
+ `.vy` and `.vyi` sources. The source version is inferred per file from its
53
+ `#pragma version` (or legacy `# @version`) line. Pass `--source-version` to
54
+ override the inference for files that have no pragma.
55
+
56
+ ### How it validates
57
+
58
+ For each file, `vyupgrade` compiles the original under its source compiler and
59
+ the rewritten output under the target compiler, then compares the two
60
+ artifacts. A migration is only written back when every file still compiles
61
+ under the target. Differences in ABI, method identifiers, or storage layout are
62
+ surfaced as diagnostics rather than silently accepted.
63
+
64
+ Compiler subprocesses run through the bundled `uv`, using
65
+ `uv run --no-project --with vyper==<version>` so each side gets the exact
66
+ compiler it needs instead of inheriting an incompatible interpreter. When a file
67
+ belongs to another project, the nearest `pyproject.toml` is read and any
68
+ declared packages matching its Vyper imports (such as `snekmate`) are added to
69
+ the compiler environment.
70
+
71
+ Dependency inference is intentionally conservative. Exact requirements,
72
+ ordinary version ranges, and Git dependencies are supported. Project-specific
73
+ specifier syntaxes that cannot be translated to a compiler environment, such as
74
+ Poetry caret requirements, are skipped; use `--compiler-search-paths`,
75
+ `--source-vyper`, or `--target-vyper` for unusual layouts.
76
+
77
+ ## Options
78
+
79
+ - `--target-version` — target Vyper version or spec (default `0.4.3`).
80
+ - `--source-version` — override the per-file inferred source version.
81
+ - `--diff` — print a unified diff instead of the report.
82
+ - `--write` — apply changes in place (only when every file compiles).
83
+ - `--check` — exit non-zero if any file would change; write nothing.
84
+ - `--bump-pragma` — rewrite the pragma to the target so output compiles against the target compiler instead of preserving the original range.
85
+ - `--aggressive` — enable rewrites that change behavior or are not provably safe (e.g. `enum` → `flag`).
86
+ - `--select` / `--ignore` — comma-separated rule codes to include or exclude.
87
+ - `--report-json PATH` — write a JSON report of fixes, diagnostics, and validation results.
88
+ - `--format mamushi` — run `mamushi` over written files to reformat them.
89
+ - `--test-command CMD` — run a test command after a successful write and record its result.
90
+ - `--enable-decimals` — treat decimals as enabled when reasoning about `0.4.x` rules.
91
+ - `--source-vyper` / `--target-vyper` — pin the exact compiler version for each side.
92
+ - `--source-python` / `--target-python` — pin the Python interpreter for each compiler subprocess.
93
+ - `--compiler-search-paths` — extra import search paths for the compiler.
94
+ - `--config PATH` — read configuration from a specific `pyproject.toml`.
95
+
96
+ ### Configuration
97
+
98
+ Defaults can live in `pyproject.toml` under `[tool.vyupgrade]`. Command-line
99
+ flags take precedence.
100
+
101
+ ```toml
102
+ [tool.vyupgrade]
103
+ paths = ["contracts/"]
104
+ target-version = "0.4.3"
105
+ source-version = "infer"
106
+ report-json = "vyupgrade-report.json"
107
+ aggressive = false
108
+ format = "none"
109
+ ```
110
+
111
+ ### Exit codes
112
+
113
+ - `0` — success.
114
+ - `1` — `--check` found files that would change.
115
+ - `2` — a file failed to compile under the target compiler.
116
+ - `3` — a file failed to compile under the source compiler.
117
+ - `4` — usage error (no paths, or conflicting flags).
118
+ - `5` — an error-severity diagnostic was raised.
119
+
120
+ ## Coverage
121
+
122
+ Rewrites carry a `VY###` code and diagnostics a `VYD###` code. Where the source
123
+ intent cannot be proven safe, the change is reported as a manual-review
124
+ diagnostic instead of being applied.
125
+
126
+ - [docs/migration-coverage.md](docs/migration-coverage.md) — every syntax change
127
+ mapped to a rule, diagnostic, or explicit no-op.
128
+ - [docs/vyper-syntax-history.md](docs/vyper-syntax-history.md) — the versioned
129
+ Vyper syntax history from `0.4.3` back to `0.2.1`, with PR links and
130
+ before/after examples.
131
+ - [CHANGELOG.md](CHANGELOG.md) — release notes.
132
+ - [DEVELOPMENT.md](DEVELOPMENT.md) — maintainer validation and release workflow.
@@ -0,0 +1,53 @@
1
+ [build-system]
2
+ requires = ["uv_build>=0.11.16,<0.12"]
3
+ build-backend = "uv_build"
4
+
5
+ [project]
6
+ name = "vyupgrade"
7
+ version = "0.1.0"
8
+ description = "Compiler-backed tool for upgrading Vyper contracts."
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = { file = "LICENSE" }
12
+ authors = [{ name = "banteg" }]
13
+ keywords = ["codemod", "migration", "smart-contracts", "vyper"]
14
+ classifiers = [
15
+ "Development Status :: 3 - Alpha",
16
+ "Environment :: Console",
17
+ "Intended Audience :: Developers",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.11",
21
+ "Topic :: Software Development :: Compilers",
22
+ "Topic :: Software Development :: Quality Assurance",
23
+ ]
24
+ dependencies = ["rich>=13.0.0", "uv>=0.8.0"]
25
+
26
+ [project.urls]
27
+ Homepage = "https://github.com/banteg/vyupgrade"
28
+ Repository = "https://github.com/banteg/vyupgrade"
29
+ Issues = "https://github.com/banteg/vyupgrade/issues"
30
+ Changelog = "https://github.com/banteg/vyupgrade/blob/master/CHANGELOG.md"
31
+
32
+ [project.scripts]
33
+ vyupgrade = "vyupgrade.cli:main"
34
+
35
+ [dependency-groups]
36
+ dev = [
37
+ "polars>=1.30",
38
+ "pytest>=8",
39
+ "ruff>=0.13.0",
40
+ ]
41
+
42
+ [tool.pytest.ini_options]
43
+ testpaths = ["tests"]
44
+
45
+ [tool.uv]
46
+ exclude-newer = "2026-05-27T14:26:03.814034Z"
47
+
48
+ [tool.uv.build-backend]
49
+ source-exclude = [".DS_Store"]
50
+
51
+ [tool.ruff]
52
+ line-length = 100
53
+ target-version = "py311"
@@ -0,0 +1,8 @@
1
+ """Vyper source upgrader."""
2
+
3
+ from importlib.metadata import PackageNotFoundError, version
4
+
5
+ try:
6
+ __version__ = version("vyupgrade")
7
+ except PackageNotFoundError:
8
+ __version__ = "0.0.0"