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
python2rust/errors.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""Exit codes and the two error types the CLI maps onto them."""
|
|
2
|
+
|
|
3
|
+
EXIT_OK = 0 # success: nothing left to do
|
|
4
|
+
EXIT_FINDINGS = 1 # translated, but TODOs / error diagnostics remain, or it could not be verified
|
|
5
|
+
EXIT_USAGE = 2 # bad arguments, missing paths, invalid config, unknown TODO id
|
|
6
|
+
EXIT_INTERNAL = 3 # python2rust itself failed (a bug, a missing core or optional dependency)
|
|
7
|
+
EXIT_COMPILE = 4 # the Rust does not verify: compile errors, failing clippy/test rung, rejected fix
|
|
8
|
+
|
|
9
|
+
SCHEMA_VERSION = 1
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class UsageError(Exception):
|
|
13
|
+
"""The caller asked for something invalid (exit 2)."""
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class InternalError(Exception):
|
|
17
|
+
"""python2rust cannot do what was asked because of its own environment or a bug (exit 3).
|
|
18
|
+
|
|
19
|
+
`kind` is the error document's `error.kind`: internal | missing_dependency | missing_core.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
def __init__(self, message: str, kind: str = "internal"):
|
|
23
|
+
super().__init__(message)
|
|
24
|
+
self.kind = kind
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class RustSideError(Exception):
|
|
28
|
+
"""The Rust side could not produce what was asked of it (e.g. its OpenAPI hook failed): exit 4."""
|
python2rust/py.typed
ADDED
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""`constructs`: which Python constructs the translator handles, as reported by the core.
|
|
2
|
+
|
|
3
|
+
The core owns this truth: it exports `CONSTRUCTS`, rows of `{id, name, status, phase, codes}`
|
|
4
|
+
generated from its own lowering tables, so the list cannot drift from what the translator does.
|
|
5
|
+
python2rust makes no support claims of its own and passes the rows through unchanged.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from collections import Counter
|
|
11
|
+
from typing import Any
|
|
12
|
+
|
|
13
|
+
from python2rust._core import get_core
|
|
14
|
+
from python2rust.cli.ops import envelope
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def constructs_doc() -> dict[str, Any]:
|
|
18
|
+
return envelope("constructs", constructs=[dict(r) for r in get_core().CONSTRUCTS])
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def constructs_text(doc: dict[str, Any]) -> str:
|
|
22
|
+
rows = doc["constructs"]
|
|
23
|
+
w = max((len(r["id"]) for r in rows), default=0)
|
|
24
|
+
lines = [
|
|
25
|
+
f"{r['id']:<{w}} {r['status']:<9} {r['phase']:<4} {r['name']}"
|
|
26
|
+
+ (f" [{', '.join(r['codes'])}]" if r["codes"] else "")
|
|
27
|
+
for r in rows
|
|
28
|
+
]
|
|
29
|
+
counts = Counter(r["status"] for r in rows)
|
|
30
|
+
lines += ["", ", ".join(f"{n} {s}" for s, n in sorted(counts.items()))]
|
|
31
|
+
return "\n".join(lines) + "\n"
|