aletk 0.1.5__tar.gz → 0.1.6__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.
- {aletk-0.1.5 → aletk-0.1.6}/PKG-INFO +2 -2
- {aletk-0.1.5 → aletk-0.1.6}/prototypes/pipe.py +7 -4
- {aletk-0.1.5 → aletk-0.1.6}/src/aletk/ResultMonad.py +7 -1
- {aletk-0.1.5 → aletk-0.1.6}/src/aletk/_version.py +9 -4
- {aletk-0.1.5 → aletk-0.1.6}/src/aletk.egg-info/PKG-INFO +2 -2
- {aletk-0.1.5 → aletk-0.1.6}/.gitignore +0 -0
- {aletk-0.1.5 → aletk-0.1.6}/.gitlab-ci.yml +0 -0
- {aletk-0.1.5 → aletk-0.1.6}/.python-version +0 -0
- {aletk-0.1.5 → aletk-0.1.6}/LICENSE +0 -0
- {aletk-0.1.5 → aletk-0.1.6}/README.md +0 -0
- {aletk-0.1.5 → aletk-0.1.6}/prototypes/MaybeMonad.py +0 -0
- {aletk-0.1.5 → aletk-0.1.6}/prototypes/pipe.ipynb +0 -0
- {aletk-0.1.5 → aletk-0.1.6}/pyproject.toml +0 -0
- {aletk-0.1.5 → aletk-0.1.6}/setup.cfg +0 -0
- {aletk-0.1.5 → aletk-0.1.6}/src/aletk/__init__.py +0 -0
- {aletk-0.1.5 → aletk-0.1.6}/src/aletk/adapters.py +0 -0
- {aletk-0.1.5 → aletk-0.1.6}/src/aletk/py.typed +0 -0
- {aletk-0.1.5 → aletk-0.1.6}/src/aletk/utils.py +0 -0
- {aletk-0.1.5 → aletk-0.1.6}/src/aletk.egg-info/SOURCES.txt +0 -0
- {aletk-0.1.5 → aletk-0.1.6}/src/aletk.egg-info/dependency_links.txt +0 -0
- {aletk-0.1.5 → aletk-0.1.6}/src/aletk.egg-info/requires.txt +0 -0
- {aletk-0.1.5 → aletk-0.1.6}/src/aletk.egg-info/top_level.txt +0 -0
- {aletk-0.1.5 → aletk-0.1.6}/tests/.gitkeep +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
### TO DELETE IF THIS EVER GETS IMPLEMENTED IN THE MAIN LIBRARY ###
|
|
2
2
|
import sys
|
|
3
|
+
|
|
3
4
|
sys.path.append('..')
|
|
4
5
|
### ###
|
|
5
6
|
|
|
@@ -7,6 +8,7 @@ from typing import Callable
|
|
|
7
8
|
|
|
8
9
|
from src.aletk.ResultMonad import Err, Ok
|
|
9
10
|
|
|
11
|
+
|
|
10
12
|
class pipe[T]:
|
|
11
13
|
"""
|
|
12
14
|
A pipe object that can be used to chain functions together with the `>>` operator.
|
|
@@ -21,11 +23,12 @@ class pipe[T]:
|
|
|
21
23
|
|
|
22
24
|
def multiply_by_two(x: int) -> int:
|
|
23
25
|
return x * 2
|
|
24
|
-
|
|
26
|
+
|
|
25
27
|
result = pipe(1) >> add_one >> multiply_by_two
|
|
26
28
|
print(result.output) # 4
|
|
27
29
|
``
|
|
28
30
|
"""
|
|
31
|
+
|
|
29
32
|
def __init__(self, value: T):
|
|
30
33
|
self.value = value
|
|
31
34
|
|
|
@@ -33,9 +36,9 @@ class pipe[T]:
|
|
|
33
36
|
def output(self) -> T:
|
|
34
37
|
return self.value
|
|
35
38
|
|
|
36
|
-
def __rshift__[
|
|
37
|
-
|
|
38
|
-
) -> 'pipe[U]' | U | 'pipe[T]' | Err | 'pipe[Err]' | Ok[U]:
|
|
39
|
+
def __rshift__[
|
|
40
|
+
U
|
|
41
|
+
](self, func: Callable[[T | 'pipe[T]'], U | Ok[U]]) -> 'pipe[U]' | U | 'pipe[T]' | Err | 'pipe[Err]' | Ok[U]:
|
|
39
42
|
if func is pipe_out:
|
|
40
43
|
# If the function is `pipe_out`, call it directly on `self`
|
|
41
44
|
return func(self)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from dataclasses import dataclass
|
|
2
2
|
from logging import Logger
|
|
3
|
-
from typing import Any, Callable
|
|
3
|
+
from typing import Any, Callable
|
|
4
4
|
from functools import wraps
|
|
5
5
|
|
|
6
6
|
|
|
@@ -29,10 +29,16 @@ class Err:
|
|
|
29
29
|
A message describing the error.
|
|
30
30
|
code : int
|
|
31
31
|
A code that can be used to handle different error cases.
|
|
32
|
+
error_type : str, optional
|
|
33
|
+
A string describing the type of error that occurred.
|
|
34
|
+
error_trace : str, optional
|
|
35
|
+
A string describing the trace of the error that occurred.
|
|
32
36
|
"""
|
|
33
37
|
|
|
34
38
|
message: str
|
|
35
39
|
code: int
|
|
40
|
+
error_type: str | None = None
|
|
41
|
+
error_trace: str | None = None
|
|
36
42
|
|
|
37
43
|
|
|
38
44
|
type TResult[T] = Ok[T] | Err
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
# file generated by
|
|
1
|
+
# file generated by setuptools-scm
|
|
2
2
|
# don't change, don't track in version control
|
|
3
|
+
|
|
4
|
+
__all__ = ["__version__", "__version_tuple__", "version", "version_tuple"]
|
|
5
|
+
|
|
3
6
|
TYPE_CHECKING = False
|
|
4
7
|
if TYPE_CHECKING:
|
|
5
|
-
from typing import Tuple
|
|
8
|
+
from typing import Tuple
|
|
9
|
+
from typing import Union
|
|
10
|
+
|
|
6
11
|
VERSION_TUPLE = Tuple[Union[int, str], ...]
|
|
7
12
|
else:
|
|
8
13
|
VERSION_TUPLE = object
|
|
@@ -12,5 +17,5 @@ __version__: str
|
|
|
12
17
|
__version_tuple__: VERSION_TUPLE
|
|
13
18
|
version_tuple: VERSION_TUPLE
|
|
14
19
|
|
|
15
|
-
__version__ = version = '0.1.
|
|
16
|
-
__version_tuple__ = version_tuple = (0, 1,
|
|
20
|
+
__version__ = version = '0.1.6'
|
|
21
|
+
__version_tuple__ = version_tuple = (0, 1, 6)
|
|
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
|