StructResult 0.8.3__tar.gz → 0.8.4__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: StructResult
3
- Version: 0.8.3
3
+ Version: 0.8.4
4
4
  Summary: structural result with ExceptionGroup
5
5
  Author-email: Serj Kotilevski <youserj@outlook.com>
6
6
  Project-URL: Source, https://github.com/youserj/Result_prj
@@ -9,7 +9,7 @@ where = ["src"]
9
9
 
10
10
  [project]
11
11
  name = "StructResult"
12
- version = "0.8.3"
12
+ version = "0.8.4"
13
13
  requires-python = ">= 3.12"
14
14
  authors = [
15
15
  {name="Serj Kotilevski", email="youserj@outlook.com"}
@@ -1,5 +1,5 @@
1
1
  from dataclasses import dataclass, field
2
- from typing import Optional, Self, Protocol, Iterator, Any
2
+ from typing import Optional, Self, Protocol, Iterator, Any, Never
3
3
 
4
4
  """
5
5
  Functional error handling system with:
@@ -19,6 +19,9 @@ class Result(Protocol):
19
19
  def is_ok(self) -> bool:
20
20
  """Returns True if successful (no errors)"""
21
21
 
22
+ def unwrap(self) -> Any:
23
+ """Returns value or raises exception if errors exist"""
24
+
22
25
 
23
26
  class Ok(Result):
24
27
  """Singleton success marker without value"""
@@ -32,6 +35,10 @@ class Ok(Result):
32
35
  def value(self) -> "Ok":
33
36
  return OK
34
37
 
38
+ def unwrap(self) -> "Ok":
39
+ """Always return OK"""
40
+ return OK
41
+
35
42
 
36
43
  OK = Ok()
37
44
 
@@ -92,6 +99,10 @@ class Error(ErrorPropagator):
92
99
  """
93
100
  return Error(err=ExceptionGroup(msg, (self.err,)))
94
101
 
102
+ def unwrap(self) -> Never:
103
+ """Always raises exception"""
104
+ raise self.err
105
+
95
106
 
96
107
  @dataclass(slots=True)
97
108
  class ErrorAccumulator(ErrorPropagator):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: StructResult
3
- Version: 0.8.3
3
+ Version: 0.8.4
4
4
  Summary: structural result with ExceptionGroup
5
5
  Author-email: Serj Kotilevski <youserj@outlook.com>
6
6
  Project-URL: Source, https://github.com/youserj/Result_prj
File without changes
File without changes