pydocket 0.0.1__py3-none-any.whl → 0.1.0__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.

Potentially problematic release.


This version of pydocket might be problematic. Click here for more details.

docket/__init__.py CHANGED
@@ -8,7 +8,16 @@ from importlib.metadata import version
8
8
 
9
9
  __version__ = version("pydocket")
10
10
 
11
- from .dependencies import CurrentDocket, CurrentWorker, Retry
11
+ from .annotations import Logged
12
+ from .dependencies import (
13
+ CurrentDocket,
14
+ CurrentExecution,
15
+ CurrentWorker,
16
+ ExponentialRetry,
17
+ Retry,
18
+ TaskKey,
19
+ TaskLogger,
20
+ )
12
21
  from .docket import Docket
13
22
  from .execution import Execution
14
23
  from .worker import Worker
@@ -19,6 +28,11 @@ __all__ = [
19
28
  "Execution",
20
29
  "CurrentDocket",
21
30
  "CurrentWorker",
31
+ "CurrentExecution",
32
+ "TaskKey",
33
+ "TaskLogger",
22
34
  "Retry",
35
+ "ExponentialRetry",
36
+ "Logged",
23
37
  "__version__",
24
38
  ]
docket/annotations.py ADDED
@@ -0,0 +1,30 @@
1
+ import abc
2
+ import inspect
3
+ from typing import Any, Iterable, Mapping, Self
4
+
5
+
6
+ class Annotation(abc.ABC):
7
+ @classmethod
8
+ def annotated_parameters(cls, signature: inspect.Signature) -> Mapping[str, Self]:
9
+ annotated: dict[str, Self] = {}
10
+
11
+ for param_name, param in signature.parameters.items():
12
+ if param.annotation == inspect.Parameter.empty:
13
+ continue
14
+
15
+ try:
16
+ metadata: Iterable[Any] = param.annotation.__metadata__
17
+ except AttributeError:
18
+ continue
19
+
20
+ for arg_type in metadata:
21
+ if isinstance(arg_type, cls):
22
+ annotated[param_name] = arg_type
23
+ elif isinstance(arg_type, type) and issubclass(arg_type, cls):
24
+ annotated[param_name] = arg_type()
25
+
26
+ return annotated
27
+
28
+
29
+ class Logged(Annotation):
30
+ """Instructs docket to include arguments to this parameter in the log."""