hammad-python 0.0.14__py3-none-any.whl → 0.0.15__py3-none-any.whl
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.
- hammad_python-0.0.15.dist-info/METADATA +184 -0
- hammad_python-0.0.15.dist-info/RECORD +4 -0
- hammad/__init__.py +0 -1
- hammad/ai/__init__.py +0 -1
- hammad/ai/_utils.py +0 -142
- hammad/ai/completions/__init__.py +0 -45
- hammad/ai/completions/client.py +0 -684
- hammad/ai/completions/create.py +0 -710
- hammad/ai/completions/settings.py +0 -100
- hammad/ai/completions/types.py +0 -792
- hammad/ai/completions/utils.py +0 -486
- hammad/ai/embeddings/__init__.py +0 -35
- hammad/ai/embeddings/client/__init__.py +0 -1
- hammad/ai/embeddings/client/base_embeddings_client.py +0 -26
- hammad/ai/embeddings/client/fastembed_text_embeddings_client.py +0 -200
- hammad/ai/embeddings/client/litellm_embeddings_client.py +0 -288
- hammad/ai/embeddings/create.py +0 -159
- hammad/ai/embeddings/types.py +0 -69
- hammad/cache/__init__.py +0 -40
- hammad/cache/base_cache.py +0 -181
- hammad/cache/cache.py +0 -169
- hammad/cache/decorators.py +0 -261
- hammad/cache/file_cache.py +0 -80
- hammad/cache/ttl_cache.py +0 -74
- hammad/cli/__init__.py +0 -33
- hammad/cli/animations.py +0 -573
- hammad/cli/plugins.py +0 -781
- hammad/cli/styles/__init__.py +0 -55
- hammad/cli/styles/settings.py +0 -139
- hammad/cli/styles/types.py +0 -358
- hammad/cli/styles/utils.py +0 -480
- hammad/data/__init__.py +0 -56
- hammad/data/collections/__init__.py +0 -34
- hammad/data/collections/base_collection.py +0 -58
- hammad/data/collections/collection.py +0 -452
- hammad/data/collections/searchable_collection.py +0 -556
- hammad/data/collections/vector_collection.py +0 -596
- hammad/data/configurations/__init__.py +0 -35
- hammad/data/configurations/configuration.py +0 -564
- hammad/data/databases/__init__.py +0 -21
- hammad/data/databases/database.py +0 -902
- hammad/data/models/__init__.py +0 -44
- hammad/data/models/base/__init__.py +0 -35
- hammad/data/models/base/fields.py +0 -546
- hammad/data/models/base/model.py +0 -1078
- hammad/data/models/base/utils.py +0 -280
- hammad/data/models/pydantic/__init__.py +0 -55
- hammad/data/models/pydantic/converters.py +0 -632
- hammad/data/models/pydantic/models/__init__.py +0 -28
- hammad/data/models/pydantic/models/arbitrary_model.py +0 -46
- hammad/data/models/pydantic/models/cacheable_model.py +0 -79
- hammad/data/models/pydantic/models/fast_model.py +0 -318
- hammad/data/models/pydantic/models/function_model.py +0 -176
- hammad/data/models/pydantic/models/subscriptable_model.py +0 -63
- hammad/data/types/__init__.py +0 -41
- hammad/data/types/file.py +0 -358
- hammad/data/types/multimodal/__init__.py +0 -24
- hammad/data/types/multimodal/audio.py +0 -96
- hammad/data/types/multimodal/image.py +0 -80
- hammad/data/types/text.py +0 -1066
- hammad/formatting/__init__.py +0 -38
- hammad/formatting/json/__init__.py +0 -21
- hammad/formatting/json/converters.py +0 -152
- hammad/formatting/text/__init__.py +0 -63
- hammad/formatting/text/converters.py +0 -723
- hammad/formatting/text/markdown.py +0 -131
- hammad/formatting/yaml/__init__.py +0 -26
- hammad/formatting/yaml/converters.py +0 -5
- hammad/logging/__init__.py +0 -35
- hammad/logging/decorators.py +0 -834
- hammad/logging/logger.py +0 -954
- hammad/mcp/__init__.py +0 -50
- hammad/mcp/client/__init__.py +0 -1
- hammad/mcp/client/client.py +0 -523
- hammad/mcp/client/client_service.py +0 -393
- hammad/mcp/client/settings.py +0 -178
- hammad/mcp/servers/__init__.py +0 -1
- hammad/mcp/servers/launcher.py +0 -1161
- hammad/performance/__init__.py +0 -36
- hammad/performance/imports.py +0 -231
- hammad/performance/runtime/__init__.py +0 -32
- hammad/performance/runtime/decorators.py +0 -142
- hammad/performance/runtime/run.py +0 -299
- hammad/py.typed +0 -0
- hammad/service/__init__.py +0 -49
- hammad/service/create.py +0 -532
- hammad/service/decorators.py +0 -285
- hammad/typing/__init__.py +0 -407
- hammad/web/__init__.py +0 -43
- hammad/web/http/__init__.py +0 -1
- hammad/web/http/client.py +0 -944
- hammad/web/models.py +0 -245
- hammad/web/openapi/__init__.py +0 -1
- hammad/web/openapi/client.py +0 -740
- hammad/web/search/__init__.py +0 -1
- hammad/web/search/client.py +0 -988
- hammad/web/utils.py +0 -472
- hammad_python-0.0.14.dist-info/METADATA +0 -70
- hammad_python-0.0.14.dist-info/RECORD +0 -99
- {hammad_python-0.0.14.dist-info → hammad_python-0.0.15.dist-info}/WHEEL +0 -0
- {hammad_python-0.0.14.dist-info → hammad_python-0.0.15.dist-info}/licenses/LICENSE +0 -0
hammad/performance/__init__.py
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
"""hammad.performance
|
2
|
-
|
3
|
-
Contains a collection of various utilities and resources for 'accelerating' or
|
4
|
-
optimizing different objects and operations in general Python development."""
|
5
|
-
|
6
|
-
from typing import TYPE_CHECKING
|
7
|
-
from .imports import create_getattr_importer
|
8
|
-
|
9
|
-
|
10
|
-
if TYPE_CHECKING:
|
11
|
-
from .runtime import (
|
12
|
-
sequentialize_function,
|
13
|
-
parallelize_function,
|
14
|
-
update_batch_type_hints,
|
15
|
-
run_sequentially,
|
16
|
-
run_parallel,
|
17
|
-
run_with_retry,
|
18
|
-
)
|
19
|
-
|
20
|
-
|
21
|
-
__all__ = (
|
22
|
-
# hammad.performance.runtime
|
23
|
-
"sequentialize_function",
|
24
|
-
"parallelize_function",
|
25
|
-
"update_batch_type_hints",
|
26
|
-
"run_sequentially",
|
27
|
-
"run_parallel",
|
28
|
-
"run_with_retry",
|
29
|
-
)
|
30
|
-
|
31
|
-
|
32
|
-
__getattr__ = create_getattr_importer(__all__)
|
33
|
-
|
34
|
-
|
35
|
-
def __dir__() -> list[str]:
|
36
|
-
return sorted(__all__)
|
hammad/performance/imports.py
DELETED
@@ -1,231 +0,0 @@
|
|
1
|
-
"""hammad.performance.runtime.imports"""
|
2
|
-
|
3
|
-
from typing import Any, Callable, List, Tuple, Union
|
4
|
-
import inspect
|
5
|
-
import ast
|
6
|
-
import hashlib
|
7
|
-
|
8
|
-
__all__ = ("create_getattr_importer",)
|
9
|
-
|
10
|
-
|
11
|
-
class GetAttrImporterError(Exception):
|
12
|
-
"""An error that occurs when the `create_getattr_importer` function
|
13
|
-
fails to create a lazy loader function."""
|
14
|
-
|
15
|
-
|
16
|
-
class GetAttrImporterCache:
|
17
|
-
"""Minimal cache implementation for internal use only
|
18
|
-
within the `create_getattr_importer` function."""
|
19
|
-
|
20
|
-
def __init__(self, maxsize: int = 128):
|
21
|
-
self.maxsize = maxsize
|
22
|
-
self._cache: dict[str, Any] = {}
|
23
|
-
|
24
|
-
def _make_key(self, data: str) -> str:
|
25
|
-
"""Create a simple hash key from string data."""
|
26
|
-
return hashlib.sha256(data.encode("utf-8")).hexdigest()[:16]
|
27
|
-
|
28
|
-
def get(self, key: str, default: Any = None) -> Any:
|
29
|
-
"""Get value from cache."""
|
30
|
-
return self._cache.get(key, default)
|
31
|
-
|
32
|
-
def set(self, key: str, value: Any) -> None:
|
33
|
-
"""Set value in cache with basic LRU eviction."""
|
34
|
-
if len(self._cache) >= self.maxsize and key not in self._cache:
|
35
|
-
# Simple eviction: remove oldest (first) item
|
36
|
-
oldest_key = next(iter(self._cache))
|
37
|
-
del self._cache[oldest_key]
|
38
|
-
self._cache[key] = value
|
39
|
-
|
40
|
-
def cached_call(self, func: Callable[[str], Any]) -> Callable[[str], Any]:
|
41
|
-
"""Decorator to cache function calls."""
|
42
|
-
|
43
|
-
def wrapper(arg: str) -> Any:
|
44
|
-
key = self._make_key(arg)
|
45
|
-
result = self.get(key)
|
46
|
-
if result is None:
|
47
|
-
result = func(arg)
|
48
|
-
self.set(key, result)
|
49
|
-
return result
|
50
|
-
|
51
|
-
return wrapper
|
52
|
-
|
53
|
-
|
54
|
-
# NOTE:
|
55
|
-
# SINGLETON
|
56
|
-
GETATTR_IMPORTER_PARSE_CACHE = GetAttrImporterCache(maxsize=64)
|
57
|
-
"""Library-wide singleton instance providing caching for the
|
58
|
-
`_parse_type_checking_imports` function."""
|
59
|
-
|
60
|
-
|
61
|
-
GETATTR_IMPORTER_TYPE_CHECKING_CACHE = {}
|
62
|
-
"""Cache for the `_parse_type_checking_imports` function."""
|
63
|
-
|
64
|
-
|
65
|
-
def _parse_type_checking_imports(source_code: str) -> dict[str, tuple[str, str]]:
|
66
|
-
"""Parses the TYPE_CHECKING imports from a source code file, to create
|
67
|
-
a dictionary of local names to (module_path, original_name) tuples.
|
68
|
-
|
69
|
-
This is used to create the mapping used within the `_create_getattr_importer_from_import_dict`
|
70
|
-
function.
|
71
|
-
|
72
|
-
Args:
|
73
|
-
source_code : The source code to parse
|
74
|
-
|
75
|
-
Returns:
|
76
|
-
A dictionary mapping local names to (module_path, original_name) tuples
|
77
|
-
"""
|
78
|
-
|
79
|
-
@GETATTR_IMPORTER_PARSE_CACHE.cached_call
|
80
|
-
def _exec(source_code: str) -> dict[str, tuple[str, str]]:
|
81
|
-
tree = ast.parse(source_code)
|
82
|
-
imports = {}
|
83
|
-
|
84
|
-
# Walk through the AST and find TYPE_CHECKING blocks
|
85
|
-
for node in ast.walk(tree):
|
86
|
-
if isinstance(node, ast.If):
|
87
|
-
# Check if this is a TYPE_CHECKING block
|
88
|
-
is_type_checking = False
|
89
|
-
|
90
|
-
if isinstance(node.test, ast.Name) and node.test.id == "TYPE_CHECKING":
|
91
|
-
is_type_checking = True
|
92
|
-
elif isinstance(node.test, ast.Attribute):
|
93
|
-
if (
|
94
|
-
isinstance(node.test.value, ast.Name)
|
95
|
-
and node.test.value.id == "typing"
|
96
|
-
and node.test.attr == "TYPE_CHECKING"
|
97
|
-
):
|
98
|
-
is_type_checking = True
|
99
|
-
|
100
|
-
if is_type_checking:
|
101
|
-
# Process imports in this block
|
102
|
-
for stmt in node.body:
|
103
|
-
if isinstance(stmt, ast.ImportFrom) and stmt.module:
|
104
|
-
module_path = f".{stmt.module}"
|
105
|
-
for alias in stmt.names:
|
106
|
-
original_name = alias.name
|
107
|
-
local_name = alias.asname or original_name
|
108
|
-
imports[local_name] = (module_path, original_name)
|
109
|
-
|
110
|
-
return imports
|
111
|
-
|
112
|
-
return _exec(source_code)
|
113
|
-
|
114
|
-
|
115
|
-
def _create_getattr_importer_from_import_dict(
|
116
|
-
imports_dict: dict[str, tuple[str, str]],
|
117
|
-
package: str,
|
118
|
-
all_attrs: Union[Tuple[str, ...], List[str]],
|
119
|
-
) -> Callable[[str], Any]:
|
120
|
-
"""Creates a lazy loader function for the `__getattr__` method
|
121
|
-
within `__init__.py` modules in Python packages.
|
122
|
-
|
123
|
-
Args:
|
124
|
-
imports_dict : Dictionary mapping attribute names to (module_path, original_name) tuples
|
125
|
-
package : The package name for import_module
|
126
|
-
all_attrs : List of all valid attributes for this module
|
127
|
-
|
128
|
-
Returns:
|
129
|
-
A __getattr__ function that lazily imports modules
|
130
|
-
"""
|
131
|
-
from importlib import import_module
|
132
|
-
|
133
|
-
cache = {}
|
134
|
-
|
135
|
-
def __getattr__(name: str) -> Any:
|
136
|
-
if name in cache:
|
137
|
-
return cache[name]
|
138
|
-
|
139
|
-
if name in imports_dict:
|
140
|
-
module_path, original_name = imports_dict[name]
|
141
|
-
module = import_module(module_path, package)
|
142
|
-
result = getattr(module, original_name)
|
143
|
-
cache[name] = result
|
144
|
-
return result
|
145
|
-
|
146
|
-
# Try to import as a submodule
|
147
|
-
try:
|
148
|
-
module_path = f".{name}"
|
149
|
-
module = import_module(module_path, package)
|
150
|
-
cache[name] = module
|
151
|
-
return module
|
152
|
-
except ImportError:
|
153
|
-
pass
|
154
|
-
|
155
|
-
raise GetAttrImporterError(f"module '{package}' has no attribute '{name}'")
|
156
|
-
|
157
|
-
return __getattr__
|
158
|
-
|
159
|
-
|
160
|
-
def create_getattr_importer(
|
161
|
-
all: Union[Tuple[str, ...], List[str]],
|
162
|
-
) -> Callable[[str], Any]:
|
163
|
-
"""Loader used internally within the `hammad` package to create lazy
|
164
|
-
loaders within `__init__.py` modules using the `TYPE_CHECKING` and
|
165
|
-
`all` source code within files.
|
166
|
-
|
167
|
-
This function is meant to be set as the `__getattr__` method / var
|
168
|
-
within modules to allow for direct lazy loading of attributes.
|
169
|
-
|
170
|
-
Example:
|
171
|
-
|
172
|
-
```
|
173
|
-
# Create a module that contains some imports and TYPE_CHECKING
|
174
|
-
from typing import TYPE_CHECKING
|
175
|
-
from hammad.performance.imports import create_getattr_importer
|
176
|
-
|
177
|
-
if TYPE_CHECKING:
|
178
|
-
from functools import wraps
|
179
|
-
|
180
|
-
all = ("wraps")
|
181
|
-
|
182
|
-
__getattr__ = create_getattr_importer(all)
|
183
|
-
|
184
|
-
# Now, when you import this module, the `wraps` attribute will be
|
185
|
-
# lazily loaded when it is first accessed.
|
186
|
-
```
|
187
|
-
|
188
|
-
Args:
|
189
|
-
all : The `all` tuple from the calling module
|
190
|
-
|
191
|
-
Returns:
|
192
|
-
A __getattr__ function that lazily imports modules
|
193
|
-
"""
|
194
|
-
# Get the calling module's frame
|
195
|
-
frame = inspect.currentframe()
|
196
|
-
if frame is None or frame.f_back is None:
|
197
|
-
raise RuntimeError("Cannot determine calling module")
|
198
|
-
|
199
|
-
calling_frame = frame.f_back
|
200
|
-
module_name = calling_frame.f_globals.get("__name__", "")
|
201
|
-
package = calling_frame.f_globals.get("__package__", "")
|
202
|
-
filename = calling_frame.f_globals.get("__file__", "")
|
203
|
-
|
204
|
-
# Check cache first
|
205
|
-
cache_key = (filename, tuple(all))
|
206
|
-
if cache_key in GETATTR_IMPORTER_TYPE_CHECKING_CACHE:
|
207
|
-
return GETATTR_IMPORTER_TYPE_CHECKING_CACHE[cache_key]
|
208
|
-
|
209
|
-
# Read the source file
|
210
|
-
try:
|
211
|
-
with open(filename, "r") as f:
|
212
|
-
source_code = f.read()
|
213
|
-
except (IOError, OSError):
|
214
|
-
# Fallback: try to get source from the module
|
215
|
-
import sys
|
216
|
-
|
217
|
-
module = sys.modules.get(module_name)
|
218
|
-
if module:
|
219
|
-
source_code = inspect.getsource(module)
|
220
|
-
else:
|
221
|
-
raise RuntimeError(f"Cannot read source for module {module_name}")
|
222
|
-
|
223
|
-
# Parse the source to extract TYPE_CHECKING imports
|
224
|
-
imports_map = _parse_type_checking_imports(source_code)
|
225
|
-
|
226
|
-
# Filter to only include exports that are in __all__
|
227
|
-
filtered_map = {name: path for name, path in imports_map.items() if name in all}
|
228
|
-
|
229
|
-
loader = _create_getattr_importer_from_import_dict(filtered_map, package, all)
|
230
|
-
GETATTR_IMPORTER_TYPE_CHECKING_CACHE[cache_key] = loader
|
231
|
-
return loader
|
@@ -1,32 +0,0 @@
|
|
1
|
-
"""hammad.performance.runtime"""
|
2
|
-
|
3
|
-
from typing import TYPE_CHECKING
|
4
|
-
from ..imports import create_getattr_importer
|
5
|
-
|
6
|
-
|
7
|
-
if TYPE_CHECKING:
|
8
|
-
from .decorators import (
|
9
|
-
sequentialize_function,
|
10
|
-
parallelize_function,
|
11
|
-
update_batch_type_hints,
|
12
|
-
)
|
13
|
-
from .run import run_sequentially, run_parallel, run_with_retry
|
14
|
-
|
15
|
-
|
16
|
-
__all__ = (
|
17
|
-
# hammad.performance.decorators
|
18
|
-
"sequentialize_function",
|
19
|
-
"parallelize_function",
|
20
|
-
"update_batch_type_hints",
|
21
|
-
# hammad.performance.run
|
22
|
-
"run_sequentially",
|
23
|
-
"run_parallel",
|
24
|
-
"run_with_retry",
|
25
|
-
)
|
26
|
-
|
27
|
-
|
28
|
-
__getattr__ = create_getattr_importer(__all__)
|
29
|
-
|
30
|
-
|
31
|
-
def __dir__() -> list[str]:
|
32
|
-
return list(__all__)
|
@@ -1,142 +0,0 @@
|
|
1
|
-
"""hammad.performance.runtime.decorators"""
|
2
|
-
|
3
|
-
import functools
|
4
|
-
from typing import (
|
5
|
-
Callable,
|
6
|
-
Iterable,
|
7
|
-
List,
|
8
|
-
Any,
|
9
|
-
TypeVar,
|
10
|
-
Optional,
|
11
|
-
Union,
|
12
|
-
cast,
|
13
|
-
)
|
14
|
-
|
15
|
-
|
16
|
-
__all__ = (
|
17
|
-
"sequentialize_function",
|
18
|
-
"parallelize_function",
|
19
|
-
"update_batch_type_hints",
|
20
|
-
)
|
21
|
-
|
22
|
-
|
23
|
-
Parameters = TypeVar("Parameters", bound=dict[str, Any])
|
24
|
-
Return = TypeVar("Return")
|
25
|
-
|
26
|
-
TaskParameters = TypeVar("TaskParameters", bound=dict[str, Any])
|
27
|
-
|
28
|
-
|
29
|
-
def sequentialize_function():
|
30
|
-
"""
|
31
|
-
Decorator to make a function that processes a single item (or argument set)
|
32
|
-
able to process an iterable of items (or argument sets) sequentially.
|
33
|
-
|
34
|
-
The decorated function will expect an iterable of argument sets as its
|
35
|
-
primary argument and will return a list of results. If the underlying
|
36
|
-
function raises an error, execution stops and the error propagates.
|
37
|
-
|
38
|
-
Example:
|
39
|
-
@sequentialize_function()
|
40
|
-
def process_single(data, factor):
|
41
|
-
return data * factor
|
42
|
-
|
43
|
-
# Now call it with a list of argument tuples
|
44
|
-
results = process_single([(1, 2), (3, 4)])
|
45
|
-
# results will be [2, 12]
|
46
|
-
"""
|
47
|
-
from .run import run_sequentially
|
48
|
-
|
49
|
-
def decorator(
|
50
|
-
func_to_process_single_item: Callable[..., Return],
|
51
|
-
) -> Callable[[Iterable[TaskParameters]], List[Return]]:
|
52
|
-
@functools.wraps(func_to_process_single_item)
|
53
|
-
def wrapper(args_list_for_func: Iterable[TaskParameters]) -> List[Return]:
|
54
|
-
return run_sequentially(func_to_process_single_item, args_list_for_func)
|
55
|
-
|
56
|
-
return wrapper
|
57
|
-
|
58
|
-
return decorator
|
59
|
-
|
60
|
-
|
61
|
-
def parallelize_function(
|
62
|
-
max_workers: Optional[int] = None, timeout: Optional[float] = None
|
63
|
-
):
|
64
|
-
"""
|
65
|
-
Decorator to make a function that processes a single item (or argument set)
|
66
|
-
able to process an iterable of items (or argument sets) in parallel.
|
67
|
-
|
68
|
-
The decorated function will expect an iterable of argument sets as its
|
69
|
-
primary argument and will return a list of results or exceptions,
|
70
|
-
maintaining the original order.
|
71
|
-
|
72
|
-
Args:
|
73
|
-
max_workers (Optional[int]): Max worker threads for parallel execution.
|
74
|
-
timeout (Optional[float]): Timeout for each individual task.
|
75
|
-
|
76
|
-
Example:
|
77
|
-
@parallelize_function(max_workers=4, timeout=5.0)
|
78
|
-
def fetch_url_content(url: str) -> str:
|
79
|
-
# ... implementation to fetch url ...
|
80
|
-
return "content"
|
81
|
-
|
82
|
-
# Now call it with a list of URLs
|
83
|
-
results = fetch_url_content(["http://example.com", "http://example.org"])
|
84
|
-
# results will be a list of contents or Exception objects.
|
85
|
-
"""
|
86
|
-
from .run import run_parallel
|
87
|
-
|
88
|
-
def decorator(
|
89
|
-
func_to_process_single_item: Callable[..., Return],
|
90
|
-
) -> Callable[[Iterable[TaskParameters]], List[Union[Return, Exception]]]:
|
91
|
-
@functools.wraps(func_to_process_single_item)
|
92
|
-
def wrapper(
|
93
|
-
args_list_for_func: Iterable[TaskParameters],
|
94
|
-
) -> List[Union[Return, Exception]]:
|
95
|
-
return run_parallel(
|
96
|
-
func_to_process_single_item,
|
97
|
-
args_list_for_func,
|
98
|
-
max_workers=max_workers,
|
99
|
-
timeout=timeout,
|
100
|
-
)
|
101
|
-
|
102
|
-
return wrapper
|
103
|
-
|
104
|
-
return decorator
|
105
|
-
|
106
|
-
|
107
|
-
def update_batch_type_hints():
|
108
|
-
"""
|
109
|
-
Decorator that provides better IDE type hinting for functions converted from
|
110
|
-
single-item to batch processing. This helps IDEs understand the transformation
|
111
|
-
and provide accurate autocomplete and type checking.
|
112
|
-
|
113
|
-
The decorated function maintains proper type information showing it transforms
|
114
|
-
from Callable[[T], R] to Callable[[Iterable[T]], List[R]].
|
115
|
-
|
116
|
-
Example:
|
117
|
-
@typed_batch()
|
118
|
-
def process_url(url: str) -> dict:
|
119
|
-
return {"url": url, "status": "ok"}
|
120
|
-
|
121
|
-
# IDE will now correctly understand:
|
122
|
-
# process_url: (Iterable[str]) -> List[dict]
|
123
|
-
results = process_url(["http://example.com", "http://test.com"])
|
124
|
-
"""
|
125
|
-
from .run import run_sequentially
|
126
|
-
|
127
|
-
def decorator(
|
128
|
-
func: Callable[..., Return],
|
129
|
-
) -> Callable[[Iterable[TaskParameters]], List[Return]]:
|
130
|
-
@functools.wraps(func)
|
131
|
-
def wrapper(args_list: Iterable[TaskParameters]) -> List[Return]:
|
132
|
-
return run_sequentially(func, args_list)
|
133
|
-
|
134
|
-
# Preserve original function's type info while updating signature
|
135
|
-
wrapper.__annotations__ = {
|
136
|
-
"args_list": Iterable[TaskParameters],
|
137
|
-
"return": List[Return],
|
138
|
-
}
|
139
|
-
|
140
|
-
return cast(Callable[[Iterable[TaskParameters]], List[Return]], wrapper)
|
141
|
-
|
142
|
-
return decorator
|