python2rust 0.1.0__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.
- python2rust/__init__.py +8 -0
- python2rust/__main__.py +5 -0
- python2rust/_core.py +44 -0
- python2rust/agent/__init__.py +0 -0
- python2rust/agent/agents.py +333 -0
- python2rust/agent/apply.py +516 -0
- python2rust/agent/finish.py +295 -0
- python2rust/agent/fixers.py +229 -0
- python2rust/agent/loop.py +441 -0
- python2rust/agent/patches.py +1165 -0
- python2rust/agent/port.py +579 -0
- python2rust/agent/prompts/judge_v2.md +96 -0
- python2rust/agent/review.py +34 -0
- python2rust/agent/rustlex.py +232 -0
- python2rust/cli/__init__.py +0 -0
- python2rust/cli/doctor.py +62 -0
- python2rust/cli/inputs.py +105 -0
- python2rust/cli/main.py +1162 -0
- python2rust/cli/ops.py +642 -0
- python2rust/cli/workflow.py +178 -0
- python2rust/core/__init__.py +38 -0
- python2rust/core/config.py +263 -0
- python2rust/core/constructs.py +124 -0
- python2rust/core/diagnostics.py +280 -0
- python2rust/core/emit/__init__.py +5 -0
- python2rust/core/emit/crates.py +51 -0
- python2rust/core/emit/render.py +561 -0
- python2rust/core/emit/schema.py +168 -0
- python2rust/core/emit/translate.py +304 -0
- python2rust/core/frontend/__init__.py +1 -0
- python2rust/core/frontend/module.py +896 -0
- python2rust/core/frontend/names.py +129 -0
- python2rust/core/frontend/project.py +277 -0
- python2rust/core/frontend/project_imports.py +173 -0
- python2rust/core/frontend/symbols.py +132 -0
- python2rust/core/frontend/walrus.py +59 -0
- python2rust/core/ir/__init__.py +1 -0
- python2rust/core/ir/nodes.py +675 -0
- python2rust/core/ir/rtypes.py +122 -0
- python2rust/core/ir/types.py +326 -0
- python2rust/core/lower/__init__.py +1 -0
- python2rust/core/lower/calls.py +1125 -0
- python2rust/core/lower/context.py +223 -0
- python2rust/core/lower/exceptions.py +317 -0
- python2rust/core/lower/exprs.py +845 -0
- python2rust/core/lower/fstrings.py +141 -0
- python2rust/core/lower/funcs.py +276 -0
- python2rust/core/lower/lowerer.py +366 -0
- python2rust/core/lower/modelcalls.py +195 -0
- python2rust/core/lower/models.py +645 -0
- python2rust/core/lower/stmts.py +722 -0
- python2rust/core/lower/testing.py +601 -0
- python2rust/core/lower/validation.py +253 -0
- python2rust/core/passes/__init__.py +1 -0
- python2rust/core/passes/aliasing.py +311 -0
- python2rust/core/passes/analysis.py +207 -0
- python2rust/core/passes/devirt.py +329 -0
- python2rust/core/passes/ownership.py +259 -0
- python2rust/core/passes/raises.py +275 -0
- python2rust/core/rt_lib.rs +2071 -0
- python2rust/data/README.md +81 -0
- python2rust/data/py2many_builtins.toml +4744 -0
- python2rust/errors.py +28 -0
- python2rust/py.typed +0 -0
- python2rust/report/__init__.py +0 -0
- python2rust/report/constructs.py +31 -0
- python2rust/report/contract.py +688 -0
- python2rust/report/corpus.py +323 -0
- python2rust/report/explain.py +168 -0
- python2rust/report/schemas.py +914 -0
- python2rust/server/__init__.py +0 -0
- python2rust/server/mcp_server.py +289 -0
- python2rust/server/mcp_workflow.py +100 -0
- python2rust/skill/SKILL.md +214 -0
- python2rust/verify/__init__.py +0 -0
- python2rust/verify/check.py +1135 -0
- python2rust/verify/equiv/__init__.py +1264 -0
- python2rust/verify/equiv/compare.py +455 -0
- python2rust/verify/equiv/harness.py +505 -0
- python2rust/verify/equiv/judge.py +358 -0
- python2rust/verify/equiv/procs.py +255 -0
- python2rust/verify/equiv/runner.py +248 -0
- python2rust/verify/equiv/types.py +543 -0
- python2rust/verify/keystore.py +76 -0
- python2rust/verify/ladder.py +396 -0
- python2rust/verify/sandbox.py +370 -0
- python2rust/verify/testrun.py +280 -0
- python2rust/workflow/__init__.py +0 -0
- python2rust/workflow/brief.py +312 -0
- python2rust/workflow/interview.py +366 -0
- python2rust/workflow/layout.py +103 -0
- python2rust/workflow/planner.py +409 -0
- python2rust/workflow/project.py +134 -0
- python2rust/workflow/schemas.py +265 -0
- python2rust/workflow/state.py +392 -0
- python2rust/workflow/staticscan.py +209 -0
- python2rust-0.1.0.dist-info/METADATA +395 -0
- python2rust-0.1.0.dist-info/RECORD +102 -0
- python2rust-0.1.0.dist-info/WHEEL +4 -0
- python2rust-0.1.0.dist-info/entry_points.txt +4 -0
- python2rust-0.1.0.dist-info/licenses/LICENSE +21 -0
- python2rust-0.1.0.dist-info/licenses/NOTICE +65 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# python2rust data files
|
|
2
|
+
|
|
3
|
+
## py2many_builtins.toml
|
|
4
|
+
|
|
5
|
+
A table that maps Python builtins, methods, operators, subscripts, format specs and
|
|
6
|
+
types to Rust, mined from [py2many](https://github.com/py2many/py2many) 0.9 (MIT, see
|
|
7
|
+
`NOTICE`) and reviewed against Python semantics. It is generated, not hand-edited:
|
|
8
|
+
|
|
9
|
+
python3 tools/mine_py2many.py PATH/TO/py2many-X.Y
|
|
10
|
+
|
|
11
|
+
The script parses py2many's Rust tables with `ast` (it never imports py2many), merges
|
|
12
|
+
them with the curated review kept in the script, and writes this file. A py2many key
|
|
13
|
+
the review does not claim is written as `status = "unreviewed"`, so mining a newer
|
|
14
|
+
py2many shows up as a reviewable diff. It also checks that every Rust template parses
|
|
15
|
+
(rustfmt) and that `NOTICE` still holds py2many's license text.
|
|
16
|
+
|
|
17
|
+
### Entry schema
|
|
18
|
+
|
|
19
|
+
[[builtin]]
|
|
20
|
+
python = "str.split" # name; methods are "type.method", operators are the symbol
|
|
21
|
+
kind = "method" # function | method | operator | constant | type | format
|
|
22
|
+
# | subscript | subscript-assign | slice | statement | syntax | attribute
|
|
23
|
+
types = ["str"] # argument/receiver types this overload applies to (optional)
|
|
24
|
+
arity = "0" # "1", "2", "3+", "1+key", "2 (range-proven)" ... free text (optional)
|
|
25
|
+
rust = "$self.split_whitespace().collect::<Vec<&str>>()"
|
|
26
|
+
status = "direct" # see below
|
|
27
|
+
helper = "" # runtime helper name, required when status = needs-runtime-helper
|
|
28
|
+
imports = ["std::collections::HashSet"] # `use` paths the template needs (optional)
|
|
29
|
+
crates = ["indexmap"] # crates the template needs (optional)
|
|
30
|
+
min_rust = "1.77" # minimum Rust version, if relevant (optional)
|
|
31
|
+
origin = "py2many" # py2many = a py2many table has this key; original = it does not
|
|
32
|
+
source = "pyrs/transpiler.py:_STR_METHODS + _visit_str_method['split']"
|
|
33
|
+
py2many_emits = "..." # what py2many emits, for comparison (optional)
|
|
34
|
+
notes = "..." # caveats; "ERROR-GAP:" marks Python-raises vs Rust-returns-nan/inf
|
|
35
|
+
|
|
36
|
+
The same `python` name appears several times when the Rust differs by argument type or
|
|
37
|
+
arity. Select by `(python, types, arity)`.
|
|
38
|
+
|
|
39
|
+
Placeholders in `rust`: `$0`..`$9` positional arguments, `$self` the receiver, `$args`
|
|
40
|
+
all arguments comma-joined, `$T` the element type, any other `$name` a keyword argument
|
|
41
|
+
or a generated name. `$` avoids a clash with Rust format-string braces.
|
|
42
|
+
|
|
43
|
+
### Status values
|
|
44
|
+
|
|
45
|
+
| status | meaning |
|
|
46
|
+
|---|---|
|
|
47
|
+
| `direct` | faithful for the stated types; any remaining edge cases are in `notes` |
|
|
48
|
+
| `corrected` | py2many has a mapping, but it is wrong or lossy; `rust` is the replacement and `py2many_emits` shows the original |
|
|
49
|
+
| `needs-runtime-helper` | no faithful inline Rust exists (floor division, `%`, `round`, `str` length, slicing, float `str`, ...). `rust` calls `p2r::<helper>`; the helper is described in a `[[helper]]` table |
|
|
50
|
+
| `compile-time` | resolved while transpiling (for example `isinstance` on a statically known type) |
|
|
51
|
+
| `unsupported` | reject loudly; py2many's output is not usable |
|
|
52
|
+
| `unreviewed` | present in the mined py2many version, not yet reviewed |
|
|
53
|
+
|
|
54
|
+
### Policies baked into the table
|
|
55
|
+
|
|
56
|
+
- Python `int` maps to `i64` (py2many uses `i32`, which silently truncates). Arithmetic that
|
|
57
|
+
can overflow is `needs-runtime-helper` (checked), with a plain-operator variant marked
|
|
58
|
+
`range-proven` for use when range analysis shows no overflow.
|
|
59
|
+
- `dict` maps to `indexmap::IndexMap` (insertion order, as Python), not `HashMap`.
|
|
60
|
+
- `p2r` is a placeholder name for a runtime helper crate. No such crate exists yet; the
|
|
61
|
+
`[[helper]]` entries are its proposed signatures and semantics.
|
|
62
|
+
- Every template is syntax-checked by the mining script (rustfmt). Templates that do not
|
|
63
|
+
use `p2r::` helpers were additionally compiled by hand against sample values (rustc
|
|
64
|
+
1.100) for the common cases, but there is no compile gate in the script yet: helpers
|
|
65
|
+
and generic types referenced by the others do not exist. Claims marked "verified" in
|
|
66
|
+
`notes` were checked with rustc 1.100 and CPython 3.15 while mining.
|
|
67
|
+
- Entries with `origin = "original"` are our own recommendation, not derived from py2many.
|
|
68
|
+
|
|
69
|
+
### Other tables in the file
|
|
70
|
+
|
|
71
|
+
- `[keywords]`: Rust reserved words, the subset that can collide with Python identifiers,
|
|
72
|
+
the ones py2many escapes, and the ones it misses (`let`, `mod`, `self`, `static`,
|
|
73
|
+
`crate`, ...). `crate`, `self`, `Self`, `super` cannot use `r#` raw identifiers.
|
|
74
|
+
- `[width_rank]`: py2many's numeric widening order. Reference only.
|
|
75
|
+
- `[status_values]`, `[meta]`: legend and mining metadata.
|
|
76
|
+
|
|
77
|
+
## Test inputs
|
|
78
|
+
|
|
79
|
+
`tests/data/py2many_cases/` holds py2many's own test programs and its expected Rust,
|
|
80
|
+
with a `manifest.json` describing each (constructs used, whether it fits P0/P1, whether
|
|
81
|
+
the reference Rust parses). See `docs/FROM_PY2MANY.md`.
|