stdlibx-compose 0.1.0__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Lucino772
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,25 @@
1
+ Metadata-Version: 2.4
2
+ Name: stdlibx-compose
3
+ Version: 0.1.0
4
+ Summary: stdlibx-compose
5
+ Author: Lucino772
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ Requires-Dist: typing-extensions>=4.10.0,<5
9
+ Requires-Python: >=3.9
10
+ Project-URL: Documentation, http://stdlibx.lucapalmi.com/
11
+ Project-URL: Repository, https://github.com/Lucino772/stdlibx
12
+ Description-Content-Type: text/markdown
13
+
14
+ [![docs](https://github.com/Lucino772/stdlibx/actions/workflows/deploy-docs.yaml/badge.svg?branch=main)](https://github.com/Lucino772/stdlibx/actions/workflows/deploy-docs.yaml)
15
+
16
+ # stdlibx
17
+ **stdlibx** is a collection of small, focused Python utilities that simplify common programming patterns and help you write clearer, more composable code.
18
+
19
+ It provides practical tools for handling optional values, explicit error management, cancellation, composition, configuration, pattern matching, and reactive flows.
20
+
21
+ ## Documentation
22
+ Checkout the [documentation](http://stdlibx.lucapalmi.com/)
23
+
24
+ ## Licence
25
+ This project uses a **MIT** Licence [view](https://github.com/Lucino772/stdlibx/blob/main/LICENSE)
@@ -0,0 +1,12 @@
1
+ [![docs](https://github.com/Lucino772/stdlibx/actions/workflows/deploy-docs.yaml/badge.svg?branch=main)](https://github.com/Lucino772/stdlibx/actions/workflows/deploy-docs.yaml)
2
+
3
+ # stdlibx
4
+ **stdlibx** is a collection of small, focused Python utilities that simplify common programming patterns and help you write clearer, more composable code.
5
+
6
+ It provides practical tools for handling optional values, explicit error management, cancellation, composition, configuration, pattern matching, and reactive flows.
7
+
8
+ ## Documentation
9
+ Checkout the [documentation](http://stdlibx.lucapalmi.com/)
10
+
11
+ ## Licence
12
+ This project uses a **MIT** Licence [view](https://github.com/Lucino772/stdlibx/blob/main/LICENSE)
@@ -0,0 +1,25 @@
1
+ [project]
2
+ name = "stdlibx-compose"
3
+ version = "0.1.0"
4
+ description = "stdlibx-compose"
5
+ license = "MIT"
6
+ license-files = ["LICEN[CS]E*"]
7
+ readme = "README.md"
8
+ authors = [
9
+ { name = "Lucino772" }
10
+ ]
11
+ requires-python = ">=3.9"
12
+ dependencies = [
13
+ "typing_extensions>=4.10.0,<5"
14
+ ]
15
+
16
+ [project.urls]
17
+ Documentation = "http://stdlibx.lucapalmi.com/"
18
+ Repository = "https://github.com/Lucino772/stdlibx"
19
+
20
+ [tool.uv.build-backend]
21
+ module-name = "stdlibx.compose"
22
+
23
+ [build-system]
24
+ requires = ["uv_build>=0.9.28,<0.10.0"]
25
+ build-backend = "uv_build"
@@ -0,0 +1,4 @@
1
+ from stdlibx.compose._flow import flow
2
+ from stdlibx.compose._pipe import pipe
3
+
4
+ __all__ = ["flow", "pipe"]
@@ -0,0 +1,100 @@
1
+ from __future__ import annotations
2
+
3
+ import functools
4
+ from typing import TYPE_CHECKING, Any, TypeVar, overload
5
+
6
+ if TYPE_CHECKING:
7
+ from stdlibx.compose._types import Operation
8
+
9
+ T1 = TypeVar("T1")
10
+ T2 = TypeVar("T2")
11
+ T3 = TypeVar("T3")
12
+ T4 = TypeVar("T4")
13
+ T5 = TypeVar("T5")
14
+ T6 = TypeVar("T6")
15
+ T7 = TypeVar("T7")
16
+ T8 = TypeVar("T8")
17
+ T9 = TypeVar("T9")
18
+
19
+
20
+ @overload
21
+ def flow(source: T1, a: Operation[T1, T2], /) -> T2: ...
22
+
23
+
24
+ @overload
25
+ def flow(source: T1, a: Operation[T1, T2], b: Operation[T2, T3], /) -> T3: ...
26
+
27
+
28
+ @overload
29
+ def flow(
30
+ source: T1, a: Operation[T1, T2], b: Operation[T2, T3], c: Operation[T3, T4], /
31
+ ) -> T4: ...
32
+
33
+
34
+ @overload
35
+ def flow(
36
+ source: T1,
37
+ a: Operation[T1, T2],
38
+ b: Operation[T2, T3],
39
+ c: Operation[T3, T4],
40
+ d: Operation[T4, T5],
41
+ /,
42
+ ) -> T5: ...
43
+
44
+
45
+ @overload
46
+ def flow(
47
+ source: T1,
48
+ a: Operation[T1, T2],
49
+ b: Operation[T2, T3],
50
+ c: Operation[T3, T4],
51
+ d: Operation[T4, T5],
52
+ e: Operation[T5, T6],
53
+ /,
54
+ ) -> T6: ...
55
+
56
+
57
+ @overload
58
+ def flow(
59
+ source: T1,
60
+ a: Operation[T1, T2],
61
+ b: Operation[T2, T3],
62
+ c: Operation[T3, T4],
63
+ d: Operation[T4, T5],
64
+ e: Operation[T5, T6],
65
+ f: Operation[T6, T7],
66
+ /,
67
+ ) -> T7: ...
68
+
69
+
70
+ @overload
71
+ def flow(
72
+ source: T1,
73
+ a: Operation[T1, T2],
74
+ b: Operation[T2, T3],
75
+ c: Operation[T3, T4],
76
+ d: Operation[T4, T5],
77
+ e: Operation[T5, T6],
78
+ f: Operation[T6, T7],
79
+ g: Operation[T7, T8],
80
+ /,
81
+ ) -> T8: ...
82
+
83
+
84
+ @overload
85
+ def flow(
86
+ source: T1,
87
+ a: Operation[T1, T2],
88
+ b: Operation[T2, T3],
89
+ c: Operation[T3, T4],
90
+ d: Operation[T4, T5],
91
+ e: Operation[T5, T6],
92
+ f: Operation[T6, T7],
93
+ g: Operation[T7, T8],
94
+ h: Operation[T8, T9],
95
+ /,
96
+ ) -> T9: ...
97
+
98
+
99
+ def flow(source: Any, *operations: Operation[Any, Any]) -> Any:
100
+ return functools.reduce(lambda val, operator: operator(val), operations, source)
@@ -0,0 +1,101 @@
1
+ from __future__ import annotations
2
+
3
+ import functools
4
+ from typing import TYPE_CHECKING, Any, TypeVar, overload
5
+
6
+ if TYPE_CHECKING:
7
+ from stdlibx.compose._types import Operation
8
+
9
+ T1 = TypeVar("T1")
10
+ T2 = TypeVar("T2")
11
+ T3 = TypeVar("T3")
12
+ T4 = TypeVar("T4")
13
+ T5 = TypeVar("T5")
14
+ T6 = TypeVar("T6")
15
+ T7 = TypeVar("T7")
16
+ T8 = TypeVar("T8")
17
+ T9 = TypeVar("T9")
18
+
19
+
20
+ @overload
21
+ def pipe(a: Operation[T1, T2], b: Operation[T2, T3], /) -> Operation[T1, T3]: ...
22
+
23
+
24
+ @overload
25
+ def pipe(
26
+ a: Operation[T1, T2], b: Operation[T2, T3], c: Operation[T3, T4], /
27
+ ) -> Operation[T1, T4]: ...
28
+
29
+
30
+ @overload
31
+ def pipe(
32
+ a: Operation[T1, T2],
33
+ b: Operation[T2, T3],
34
+ c: Operation[T3, T4],
35
+ d: Operation[T4, T5],
36
+ /,
37
+ ) -> Operation[T1, T5]: ...
38
+
39
+
40
+ @overload
41
+ def pipe(
42
+ a: Operation[T1, T2],
43
+ b: Operation[T2, T3],
44
+ c: Operation[T3, T4],
45
+ d: Operation[T4, T5],
46
+ e: Operation[T5, T6],
47
+ /,
48
+ ) -> Operation[T1, T6]: ...
49
+
50
+
51
+ @overload
52
+ def pipe(
53
+ a: Operation[T1, T2],
54
+ b: Operation[T2, T3],
55
+ c: Operation[T3, T4],
56
+ d: Operation[T4, T5],
57
+ e: Operation[T5, T6],
58
+ f: Operation[T6, T7],
59
+ /,
60
+ ) -> Operation[T1, T7]: ...
61
+
62
+
63
+ @overload
64
+ def pipe(
65
+ a: Operation[T1, T2],
66
+ b: Operation[T2, T3],
67
+ c: Operation[T3, T4],
68
+ d: Operation[T4, T5],
69
+ e: Operation[T5, T6],
70
+ f: Operation[T6, T7],
71
+ g: Operation[T7, T8],
72
+ /,
73
+ ) -> Operation[T1, T8]: ...
74
+
75
+
76
+ @overload
77
+ def pipe(
78
+ a: Operation[T1, T2],
79
+ b: Operation[T2, T3],
80
+ c: Operation[T3, T4],
81
+ d: Operation[T4, T5],
82
+ e: Operation[T5, T6],
83
+ f: Operation[T6, T7],
84
+ g: Operation[T7, T8],
85
+ h: Operation[T9, T9],
86
+ /,
87
+ ) -> Operation[T1, T9]: ...
88
+
89
+
90
+ def pipe(
91
+ first: Operation[Any, Any],
92
+ *others: Operation[Any, Any],
93
+ ) -> Operation[Any, Any]:
94
+ def _apply(value: Any) -> Any:
95
+ return functools.reduce(
96
+ lambda val, operation: operation(val),
97
+ (first, *others),
98
+ value,
99
+ )
100
+
101
+ return _apply
@@ -0,0 +1,10 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Callable, TypeVar
4
+
5
+ from typing_extensions import TypeAlias
6
+
7
+ T = TypeVar("T")
8
+ U = TypeVar("U")
9
+
10
+ Operation: TypeAlias = Callable[[T], U]
File without changes