evilutils 0.1.0__tar.gz → 0.1.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.
- {evilutils-0.1.0/src/evilutils.egg-info → evilutils-0.1.1}/PKG-INFO +1 -1
- {evilutils-0.1.0 → evilutils-0.1.1}/src/evilfunctools/__init__.py +1 -2
- evilutils-0.1.1/src/evilfunctools/decorators.py +23 -0
- {evilutils-0.1.0 → evilutils-0.1.1}/src/evilutils/info.py +1 -1
- {evilutils-0.1.0 → evilutils-0.1.1/src/evilutils.egg-info}/PKG-INFO +1 -1
- evilutils-0.1.0/src/evilfunctools/decorators.py +0 -44
- {evilutils-0.1.0 → evilutils-0.1.1}/LICENSE +0 -0
- {evilutils-0.1.0 → evilutils-0.1.1}/MANIFEST.in +0 -0
- {evilutils-0.1.0 → evilutils-0.1.1}/README.md +0 -0
- {evilutils-0.1.0 → evilutils-0.1.1}/pyproject.toml +0 -0
- {evilutils-0.1.0 → evilutils-0.1.1}/requirements.txt +0 -0
- {evilutils-0.1.0 → evilutils-0.1.1}/setup.cfg +0 -0
- {evilutils-0.1.0 → evilutils-0.1.1}/src/evilfunctools/compose.py +0 -0
- {evilutils-0.1.0 → evilutils-0.1.1}/src/evilfunctools/py.typed +0 -0
- {evilutils-0.1.0 → evilutils-0.1.1}/src/evilutils/__init__.py +0 -0
- {evilutils-0.1.0 → evilutils-0.1.1}/src/evilutils/__main__.py +0 -0
- {evilutils-0.1.0 → evilutils-0.1.1}/src/evilutils/py.typed +0 -0
- {evilutils-0.1.0 → evilutils-0.1.1}/src/evilutils.egg-info/SOURCES.txt +0 -0
- {evilutils-0.1.0 → evilutils-0.1.1}/src/evilutils.egg-info/dependency_links.txt +0 -0
- {evilutils-0.1.0 → evilutils-0.1.1}/src/evilutils.egg-info/requires.txt +0 -0
- {evilutils-0.1.0 → evilutils-0.1.1}/src/evilutils.egg-info/top_level.txt +0 -0
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
from functools import cache, cached_property, partial, partialmethod, wraps
|
|
4
4
|
|
|
5
5
|
from .compose import compose
|
|
6
|
-
from .decorators import immediate
|
|
6
|
+
from .decorators import immediate
|
|
7
7
|
|
|
8
8
|
__all__ = [
|
|
9
9
|
"partial",
|
|
@@ -13,5 +13,4 @@ __all__ = [
|
|
|
13
13
|
"compose",
|
|
14
14
|
"wraps",
|
|
15
15
|
"immediate",
|
|
16
|
-
"map_result",
|
|
17
16
|
]
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from collections.abc import Callable
|
|
2
|
+
from typing import ParamSpec, TypeVar
|
|
3
|
+
|
|
4
|
+
__all__ = ["immediate"]
|
|
5
|
+
|
|
6
|
+
P = ParamSpec("P")
|
|
7
|
+
RT = TypeVar("RT")
|
|
8
|
+
MT = TypeVar("MT")
|
|
9
|
+
|
|
10
|
+
TT = TypeVar("TT", bound=type)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def immediate(func: Callable[[], RT]) -> RT:
|
|
14
|
+
"""Immediately evaluate the given function, returning its output.
|
|
15
|
+
|
|
16
|
+
>>> @immediate
|
|
17
|
+
... def VALUES():
|
|
18
|
+
... return (0, 1)
|
|
19
|
+
>>>
|
|
20
|
+
>>> VALUES
|
|
21
|
+
(0, 1)
|
|
22
|
+
"""
|
|
23
|
+
return func()
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
from collections.abc import Callable
|
|
2
|
-
from functools import partial
|
|
3
|
-
from typing import ParamSpec, TypeVar
|
|
4
|
-
|
|
5
|
-
from .compose import compose
|
|
6
|
-
|
|
7
|
-
__all__ = ["immediate", "map_result"]
|
|
8
|
-
|
|
9
|
-
P = ParamSpec("P")
|
|
10
|
-
RT = TypeVar("RT")
|
|
11
|
-
MT = TypeVar("MT")
|
|
12
|
-
|
|
13
|
-
TT = TypeVar("TT", bound=type)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def immediate(func: Callable[[], RT]) -> RT:
|
|
17
|
-
"""Immediately evaluate the given function, returning its output.
|
|
18
|
-
|
|
19
|
-
>>> @immediate
|
|
20
|
-
... def VALUES():
|
|
21
|
-
... return (0, 1)
|
|
22
|
-
>>>
|
|
23
|
-
>>> VALUES
|
|
24
|
-
(0, 1)
|
|
25
|
-
"""
|
|
26
|
-
return func()
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
def map_result(
|
|
30
|
-
mapper: Callable[[RT], MT],
|
|
31
|
-
) -> Callable[[Callable[P, RT]], Callable[P, MT]]:
|
|
32
|
-
"""Map the returned value of a function using another function.
|
|
33
|
-
|
|
34
|
-
This is especially designed with generators in mind, though one
|
|
35
|
-
could easily find other uses.
|
|
36
|
-
|
|
37
|
-
>>> @map_result(tuple)
|
|
38
|
-
... def __generate_values(a: int):
|
|
39
|
-
... yield from (a, 1)
|
|
40
|
-
>>>
|
|
41
|
-
>>> __generate_values(0)
|
|
42
|
-
(0, 1)
|
|
43
|
-
"""
|
|
44
|
-
return partial(compose, mapper)
|
|
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
|