Resilient-result – Rust-style errors in Python
Resilient-result – Rust-style errors in Python
I built `resilient-result` after getting tired of try/catch blocks scattered everywhere in production Python code. It's a zero-dependency library that brings Rust-style Result types to Python with a clean decorator API and seamless async support. Key features: - @resilient decorator converts any sync or async function to return Result[T, E] instead of raising exceptions - Rust-style Ok() and Err() constructors for familiarity - Guard clause patterns for clean early returns - Full generic typing support for IDEs and type-checkers - Zero dependencies, Python 3.8+ Example: from resilient_result import Result, resilient @resilient def divide(a: int, b: int) -> int: return a // b result = divide(10, 0) # Returns Result.fail("division by zero") if result.success: print(f"Result: {result.data}") else: print(f"Error: {result.error}") The guard clause pattern shines in multi-step processes: def multi_step_process(data: str) -> Result[str, str]: step1_result = process_step1(data) if not step1_result.success: return step1_result # Early return on failure step2_result = process_step2(step1_result.data) if not step2_result.success: return step2_result return Result.ok(step2_result.data + "_complete") PyPI: https://pypi.org/project/resilient-result/ GitHub: https://github.com/iteebz/resilient-result Would love feedback from the community! Is this a pattern you'd use in production Python?
Share cardActual performance
Launch Intel predictions
Analyze your own launch →Correct prediction on native model
Similar products
Rust (PyO3) deserializer callable from Python
FlashText with Rust for Python
Cargo-pup – ArchUnit-style linting for rust
Rust-Like Traits in Python
(29x faster)Rapidvalidators - Python's validators lib rewritten in Rust
Aiochan – Golang-Style Concurrency for Python
Genotype: language that compiles to idiomatic TS, Rust and Python
Kana.rs: A Tiny Rust NeuralNet for Python
Performant Rust Streaming Algorithms from Python
Cannoli – A compiler for a subset of Python written in Rust