Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Depyler
A Python-to-Rust transpiler with semantic verification and memory safety analysis. Depyler translates annotated Python code into idiomatic Rust, preserving program semantics while providing compile-time safety guarantees.
Recent Updates (v3.18.2)
Emergency Bug Fix Sprint - Critical transpiler fixes:
- ✅ Fixed async methods missing
async
keyword in classes - ✅ Fixed variable initialization in async functions (await expressions)
- ✅ Fixed print() statements (now correctly generates
println!()
macro) - ✅ Added Assert statement support (was completely missing)
- ✅ Fixed array literal transpilation bugs
- ✅ Added CI validation to ensure all transpiled code compiles
Status: All P0 blocking issues resolved. Generated code quality significantly improved.
See CHANGELOG.md for complete details.
Installation
Requirements
- Rust 1.83.0 or later
- Python 3.8+ (for test validation)
Usage
Basic Transpilation
# Transpile a Python file to Rust
# Transpile with semantic verification
# Analyze migration complexity
Example
Input (example.py
):
return
return +
Output (example.rs
):
Library Usage
use ;
Features
Core Capabilities
- Type-directed transpilation: Uses Python type annotations to generate appropriate Rust types
- Memory safety analysis: Infers ownership and borrowing patterns
- Semantic verification: Property-based testing to verify behavioral equivalence
- Multiple backends: Generate Rust or Ruchy script code
Supported Python Features
Currently Supported:
- Functions with type annotations
- Basic types (int, float, str, bool)
- Collections (List, Dict, Tuple, Set)
- Control flow (if, while, for, match)
- List/dict/set comprehensions
- Generator expressions (NEW in v3.13.0) ✨
- Generator functions (yield statements)
- Exception handling (mapped to Result<T, E>)
- Classes and methods
- Assert statements (NEW in v3.18.2) ✨
- Async/await (functions and methods - FIXED in v3.18.2)
- Context managers (with statements)
- Iterators
- Print statements (correctly generates println! macro)
Not Supported:
- Dynamic features (eval, exec)
- Runtime reflection
- Multiple inheritance
- Monkey patching
See documentation for complete feature list.
MCP Integration
Depyler provides an MCP (Model Context Protocol) server for integration with AI assistants like Claude Code.
Setup
Add to Claude Desktop config (~/.config/Claude/claude_desktop_config.json
):
Available Tools
transpile_python
- Convert Python code to Rustanalyze_migration_complexity
- Analyze migration effortverify_transpilation
- Verify semantic equivalencepmat_quality_check
- Code quality analysis
See docs/MCP_QUICKSTART.md for detailed usage.
Architecture
Depyler uses a multi-stage compilation pipeline:
Python AST → HIR → Type Inference → Rust AST → Code Generation
Key components:
- Parser: RustPython AST parser
- HIR: High-level intermediate representation
- Type System: Conservative type inference with annotation support
- Verification: Property-based testing for semantic equivalence
- Codegen: Rust code generation via syn/quote
Quality Standards
This project follows strict quality standards enforced by CI:
- Test coverage: 70%+ (440+ passing tests in core, 600+ workspace-wide)
- Max cyclomatic complexity: ≤10 (enforced via PMAT)
- Max cognitive complexity: ≤10 (enforced via PMAT)
- Zero clippy warnings (
-D warnings
- BLOCKING) - Zero self-admitted technical debt (SATD - BLOCKING)
- TDG grade: A- minimum (≥85 points)
- NEW: CI validates all transpiled code compiles (v3.18.2)
Development
Running Tests
# Run all tests
# Run with coverage
# Run benchmarks
Quality Checks
# Lint
# Format
# Quality gates
Documentation
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option.
Contributing
Contributions are welcome. Please follow the quality standards:
- Write tests first (TDD)
- Maintain 80%+ coverage for new code
- Pass all clippy checks
- Update documentation
See CONTRIBUTING.md for details.