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.
- {wird-1.2.0 → wird-1.2.1}/PKG-INFO +2 -2
- {wird-1.2.0 → wird-1.2.1}/pyproject.toml +1 -1
- {wird-1.2.0 → wird-1.2.1}/tests/test_result.py +32 -0
- {wird-1.2.0 → wird-1.2.1}/uv.lock +1 -1
- {wird-1.2.0 → wird-1.2.1}/wird/_result.py +4 -1
- {wird-1.2.0 → wird-1.2.1}/.github/workflows/check.yml +0 -0
- {wird-1.2.0 → wird-1.2.1}/.github/workflows/publish.yml +0 -0
- {wird-1.2.0 → wird-1.2.1}/.gitignore +0 -0
- {wird-1.2.0 → wird-1.2.1}/.python-version +0 -0
- {wird-1.2.0 → wird-1.2.1}/Makefile +0 -0
- {wird-1.2.0 → wird-1.2.1}/README.md +0 -0
- {wird-1.2.0 → wird-1.2.1}/tests/__init__.py +0 -0
- {wird-1.2.0 → wird-1.2.1}/tests/test_future.py +0 -0
- {wird-1.2.0 → wird-1.2.1}/tests/test_maybe.py +0 -0
- {wird-1.2.0 → wird-1.2.1}/tests/test_value.py +0 -0
- {wird-1.2.0 → wird-1.2.1}/wird/__init__.py +0 -0
- {wird-1.2.0 → wird-1.2.1}/wird/_future.py +0 -0
- {wird-1.2.0 → wird-1.2.1}/wird/_maybe.py +0 -0
- {wird-1.2.0 → wird-1.2.1}/wird/_value.py +0 -0
- {wird-1.2.0 → wird-1.2.1}/wird/future_maybe.py +0 -0
- {wird-1.2.0 → wird-1.2.1}/wird/future_result.py +0 -0
- {wird-1.2.0 → wird-1.2.1}/wird/maybe.py +0 -0
- {wird-1.2.0 → wird-1.2.1}/wird/py.typed +0 -0
- {wird-1.2.0 → wird-1.2.1}/wird/result.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: wird
|
|
3
|
-
Version: 1.2.
|
|
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
|
|
@@ -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
|
[
|
|
@@ -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
|
-
|
|
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
|