wird 1.2.0__tar.gz → 1.2.1__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
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: wird
3
- Version: 1.2.0
3
+ Version: 1.2.1
4
4
  Summary: Basic monads for implementing pipe-styled processing
5
5
  Project-URL: Repository, https://github.com/katunilya/wird
6
6
  Project-URL: Issues, https://github.com/katunilya/wird/issues
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "wird"
7
- version = "1.2.0"
7
+ version = "1.2.1"
8
8
  description = "Basic monads for implementing pipe-styled processing"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.13"
@@ -87,6 +87,38 @@ async def test_err_unwraps() -> None:
87
87
  )
88
88
 
89
89
 
90
+ @pytest.mark.parametrize("error", [ValueError("err"), KeyboardInterrupt()])
91
+ async def test_err_unwrap_preserves_underlying_exception(error: BaseException) -> None:
92
+ try:
93
+ raise error
94
+ except BaseException:
95
+ pass
96
+
97
+ underlying_traceback = error.__traceback__
98
+ assert underlying_traceback is not None
99
+
100
+ result = Err(error)
101
+
102
+ with pytest.raises(ErrUnwrapError, match="on err") as exc_info:
103
+ result.unwrap(on_err="on err")
104
+
105
+ assert exc_info.value.__cause__ is error
106
+ assert exc_info.value.__cause__.__traceback__ is underlying_traceback
107
+
108
+ with pytest.raises(ErrUnwrapError) as future_exc_info:
109
+ await FutureResult.from_(result).unwrap()
110
+
111
+ assert future_exc_info.value.__cause__ is error
112
+ assert future_exc_info.value.__cause__.__traceback__ is underlying_traceback
113
+
114
+
115
+ def test_err_unwrap_does_not_chain_non_exception_value() -> None:
116
+ with pytest.raises(ErrUnwrapError) as exc_info:
117
+ Err("err").unwrap()
118
+
119
+ assert exc_info.value.__cause__ is None
120
+
121
+
90
122
  @pytest.mark.parametrize(
91
123
  ("result", "target"),
92
124
  [
@@ -310,7 +310,7 @@ wheels = [
310
310
 
311
311
  [[package]]
312
312
  name = "wird"
313
- version = "1.2.0"
313
+ version = "1.2.1"
314
314
  source = { editable = "." }
315
315
 
316
316
  [package.dev-dependencies]
@@ -689,7 +689,10 @@ class Err[E](Result[Any, E]):
689
689
  def unwrap(self, *, on_err: str = "expected Ok, got Err") -> Any: ...
690
690
 
691
691
  def unwrap(self, **kwargs) -> Any:
692
- raise ErrUnwrapError(kwargs.get("on_err", "expected Ok, got Err"))
692
+ error = ErrUnwrapError(kwargs.get("on_err", "expected Ok, got Err"))
693
+ if isinstance(self.internal, BaseException):
694
+ raise error from self.internal
695
+ raise error
693
696
 
694
697
  def unwrap_or[T](self, /, other: T) -> T:
695
698
  return other
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes