Skip to content

Commit 103025d

Browse files
committed
chore: update license and readme.md
1 parent 427a57b commit 103025d

2 files changed

Lines changed: 36 additions & 25 deletions

File tree

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2024 Scott E. Boyce
3+
Copyright (c) 2025 Scott E. Boyce
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,51 @@
55
</p>
66

77

8-
ResultContainer is a python module with a `Result` class that mimics the [Result Result Enum](https://doc.rust-lang.org/std/result/enum.Result.html). The Result Enum is used for situations when errors are expected and are easily handled, or you do not want to have lots of try/except clauses. The Result enum wraps a value in an `Ok` variant, until there is an exception or error raised, and then it is converted to the `Err` variant. The `Err` variant is a `ResultErr` object stored in the `Result` that contains the error messages and traceback information. The `Result` object includes similar methods to the Result Result Enum for inquiry about the state, mapping functions, and passing attributes/methods to the containing `value`.
8+
The `ResultContainer` module simplifies complex error handling into clean, readable, and maintainable code structures. Error handling in Python can often become unwieldy, with deeply nested `try/except` blocks and scattered error management. The `ResultContainer` is used for situations when errors are expected and are easily handled. Inspired by [Rust’s Result<Ok, Err>](https://doc.rust-lang.org/std/result/enum.Result.html) enum, `ResultContainer` introduces a clean and Pythonic way to encapsulate success (`Ok`) and failure (`Err`) outcomes.
99

10-
#### `Result` Variants
10+
The `ResultContainer.Result` enum wraps a value in an `Ok` variant, until there is an exception or error raised, and then it is converted to the `Err` variant. The `Err` variant wraps a `ResultContainer.ResultErr` object that contains the error messages and traceback information. The `Result` object includes similar methods to the Rust Result Enum for inquiry about the state, mapping functions, and passing attributes/methods to the containing `value`.
11+
12+
The `ResultContainer` is designed to streamline error propagation and improve code readability, `ResultContainer` is ideal for developers seeking a robust, maintainable approach to handling errors in data pipelines, API integrations, or asynchronous operations.
13+
14+
## Features
15+
16+
- **Variants for Success and Failure**: Two variants represented in a Result instance, `Ok(value)` for successful outcomes, and `Err(e)` for errors that have resulted. Provides a flexible mechanism for chaining operations on the `Ok` value while propagating errors through `Err`.
17+
- **Attribute and Method Transparency**: Automatically passes attributes, methods, indices, and math operations to the value contained within an `Ok`, otherwise propagates the `Err(e)`.
18+
- **Utility Methods**: Implements helper methods for error propagation, transformation, and querying (e.g., `.map()`, `.apply()`, `.unwrap_or()`, `.expect()`, `.raises()`) for concise and readable handling of success and error cases.
19+
20+
## Installation
21+
To install the module
22+
23+
```bash
24+
pip install --upgrade git+https://github.com/ScottBoyce-Python/ResultContainer.git
25+
```
26+
27+
or you can clone the respository with
28+
```bash
29+
git clone https://github.com/ScottBoyce-Python/ResultContainer.git
30+
```
31+
then rename the file `ResultContainer/__init__.py` to `ResultContainer/ResultContainer.py` and move `ResultContainer.py` to wherever you want to use it.
32+
33+
## `Result` Variants
34+
35+
```python
36+
# Result is the main class and Ok and Err are constructors.
37+
from ResultContainer import Result, Ok, Err
38+
```
1139

1240
- `Ok(value)`
1341
- `value` is wrapped within an `Ok`.
1442
- Constructor: `Result.as_Ok(value)`
43+
- `Result.Ok` attribute returns the wrapped `value`
1544
- `Err(e)`
1645
- `e` is a `ResultErr` object wrapped within an `Err`.
1746
- Constructor: `Result.as_Err(error_msg)`
47+
- `Result.Err` attribute returns the wrapped `e`.
1848

1949

20-
#### Properties of the `Result` Variants
50+
### Properties of the `Result` Variants
2151

22-
##### `Ok(value)`
52+
#### `Ok(value)`
2353

2454
- Represents success (non-error state).
2555
The `value` is wrapped within the `Ok()`.
@@ -42,7 +72,7 @@ ResultContainer is a python module with a `Result` class that mimics the [Result
4272
- `Err(e1) < Err(e2) ` &nbsp;&nbsp; `False`
4373
- `Err(e1) <= Err(e2) ` &nbsp;&nbsp; `True`
4474

45-
##### `Err(e)`:
75+
#### `Err(e)`:
4676

4777
- Represents a failure (error-state) and contains `e` as a `ResultErr` object
4878
that stores error messages and traceback information.
@@ -54,25 +84,6 @@ ResultContainer is a python module with a `Result` class that mimics the [Result
5484

5585
There are methods built into `Result` to check if an error has been raised, or the unwrap the value/error to get its contents.
5686

57-
## Features
58-
59-
- **Variants for Success and Failure**: Two variants, `Ok(value)` for successful outcomes, and `Err(e)` for errors that have resulted. Provides a flexible mechanism for chaining operations on the `Ok` value while propagating errors through `Err`.
60-
- **Attribute and Method Transparency**: Automatically passes attributes, methods, and math operations to the value contained within an `Ok`, otherwise propagates the `Err(e)`.
61-
- **Utility Methods**: Implements helper methods for error propagation, transformation, and querying (e.g., `.map()`, `.apply()`, `.unwrap_or()`, `.expect()`, `.raises()`) for concise and readable handling of success and error cases.
62-
63-
## Installation
64-
To install the module
65-
66-
```bash
67-
pip install --upgrade git+https://github.com/ScottBoyce-Python/ResultContainer.git
68-
```
69-
70-
or you can clone the respository with
71-
```bash
72-
git clone https://github.com/ScottBoyce-Python/ResultContainer.git
73-
```
74-
then rename the file `ResultContainer/__init__.py` to `ResultContainer/ResultContainer.py` and move `ResultContainer.py` to wherever you want to use it.
75-
7687
## Result Initialization
7788

7889
```python

0 commit comments

Comments
 (0)