Add your description here
Project description
danom
API Reference
Ok
Ok.and_then
Ok.and_then(self, func: collections.abc.Callable[[~T], danom._result.Result], **kwargs: dict) -> danom._result.Result
Pipe another function that returns a monad.
>>> Ok(1).and_then(add_one) == Ok(2)
>>> Ok(1).and_then(raise_err) == Err(error=TypeError())
Ok.is_ok
Ok.is_ok(self) -> Literal[True]
Returns True if the result type is Ok.
>>> Ok().is_ok() == True
Ok.match
Ok.match(self, if_ok_func: collections.abc.Callable[[~T], danom._result.Result], _if_err_func: collections.abc.Callable[[~T], danom._result.Result]) -> danom._result.Result
Map Ok func to Ok and Err func to Err
>>> Ok(1).match(add_one, mock_get_error_type) == Ok(inner=2)
>>> Ok("ok").match(double, mock_get_error_type) == Ok(inner='okok')
>>> Err(error=TypeError()).match(double, mock_get_error_type) == Ok(inner='TypeError')
Ok.unwrap
Ok.unwrap(self) -> ~T
Unwrap the Ok monad and get the inner value.
>>> Ok().unwrap() == None
>>> Ok(1).unwrap() == 1
>>> Ok("ok").unwrap() == 'ok'
Err
Err.and_then
Err.and_then(self, _: 'Callable[[T], Result]', **_kwargs: 'dict') -> 'Self'
Pipe another function that returns a monad. For Err will return original error.
>>> Err(error=TypeError()).and_then(add_one) == Err(error=TypeError())
>>> Err(error=TypeError()).and_then(raise_value_err) == Err(error=TypeError())
Err.is_ok
Err.is_ok(self) -> 'Literal[False]'
Returns False if the result type is Err.
Err().is_ok() == False
Err.match
Err.match(self, _if_ok_func: 'Callable[[T], Result]', if_err_func: 'Callable[[T], Result]') -> 'Result'
Map Ok func to Ok and Err func to Err
>>> Ok(1).match(add_one, mock_get_error_type) == Ok(inner=2)
>>> Ok("ok").match(double, mock_get_error_type) == Ok(inner='okok')
>>> Err(error=TypeError()).match(double, mock_get_error_type) == Ok(inner='TypeError')
Err.unwrap
Err.unwrap(self) -> 'None'
Unwrap the Err monad will raise the inner error.
>>> Err(error=TypeError()).unwrap() raise TypeError(...)
safe
safe
safe(func: collections.abc.Callable[~P, ~T]) -> collections.abc.Callable[~P, danom._result.Result]
Decorator for functions that wraps the function in a try except returns Ok on success else Err.
>>> @safe
... def add_one(a: int) -> int:
... return a + 1
>>> add_one(1) == Ok(inner=2)
safe_method
safe_method
safe_method(func: collections.abc.Callable[~P, ~T]) -> collections.abc.Callable[~P, danom._result.Result]
The same as safe except it forwards on the self of the class instance to the wrapped function.
>>> class Adder:
... def __init__(self, result: int = 0) -> None:
... self.result = result
...
... @safe_method
... def add_one(self, a: int) -> int:
... return self.result + 1
>>> Adder.add_one(1) == Ok(inner=1)
::
Repo map
├── .github
│ └── workflows
│ ├── ci_tests.yaml
│ └── publish.yaml
├── dev_tools
│ ├── __init__.py
│ └── update_readme.py
├── src
│ └── danom
│ ├── __init__.py
│ ├── _err.py
│ ├── _ok.py
│ ├── _result.py
│ └── _safe.py
├── tests
│ ├── __init__.py
│ ├── test_api.py
│ ├── test_err.py
│ ├── test_ok.py
│ ├── test_result.py
│ └── test_safe.py
├── .pre-commit-config.yaml
├── README.md
├── pyproject.toml
├── ruff.toml
└── uv.lock
::
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file danom-0.1.1.tar.gz.
File metadata
- Download URL: danom-0.1.1.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1da35799034eb8a141307278ba33684970bfbba7cd41ec33ca83c49f81892515
|
|
| MD5 |
cae584d2870e796f14d4a4bee38dab37
|
|
| BLAKE2b-256 |
7dcc157977e48befa41905d483053198b3855f98ae744f60ab9f328771a8fef4
|
Provenance
The following attestation bundles were made for danom-0.1.1.tar.gz:
Publisher:
publish.yaml on second-ed/danom
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
danom-0.1.1.tar.gz -
Subject digest:
1da35799034eb8a141307278ba33684970bfbba7cd41ec33ca83c49f81892515 - Sigstore transparency entry: 731997762
- Sigstore integration time:
-
Permalink:
second-ed/danom@93eceebf5eb5dce653e6b52bb85128f5bd4c13f2 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/second-ed
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@93eceebf5eb5dce653e6b52bb85128f5bd4c13f2 -
Trigger Event:
release
-
Statement type:
File details
Details for the file danom-0.1.1-py3-none-any.whl.
File metadata
- Download URL: danom-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42e2b9f2c3203ab7814f033b3e742ce9a9705f7480c920f565038255d95d2801
|
|
| MD5 |
7ef7c9b4931a7f80d22e354e1e03d3f4
|
|
| BLAKE2b-256 |
7f54231b6b904f1999fbe63000e8f2f17ddb0b60339627eefcce805ca3eee4bf
|
Provenance
The following attestation bundles were made for danom-0.1.1-py3-none-any.whl:
Publisher:
publish.yaml on second-ed/danom
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
danom-0.1.1-py3-none-any.whl -
Subject digest:
42e2b9f2c3203ab7814f033b3e742ce9a9705f7480c920f565038255d95d2801 - Sigstore transparency entry: 731997763
- Sigstore integration time:
-
Permalink:
second-ed/danom@93eceebf5eb5dce653e6b52bb85128f5bd4c13f2 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/second-ed
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@93eceebf5eb5dce653e6b52bb85128f5bd4c13f2 -
Trigger Event:
release
-
Statement type: