SecretMonad¶
secret_type.SecretMonad
¶
Provides a monad-like interface for Secret objects.
These methods are all also available on the Secret class.
Source code in secret_type/monad.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
wrap(o: Union[T, Secret[T]]) -> Secret[T]
classmethod
¶
Wraps a value in the appropriate Secret container.
If the value is already a Secret, it is returned as-is.
| ATTRIBUTE | DESCRIPTION |
|---|---|
o |
The value to wrap. |
Example:
secret = SecretMonad.wrap(42)
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If |
Source code in secret_type/monad.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
unwrap(o: Union[Secret[T], R]) -> Union[T, R]
classmethod
¶
Unwraps a Secret into it's underlying value.
If the value is not a Secret, it is returned as-is.
| ATTRIBUTE | DESCRIPTION |
|---|---|
o |
The value to unwrap. |
Example:
assert 42 == SecretMonad.unwrap(secret)
Source code in secret_type/monad.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |