omlish 0.0.0.dev484__py3-none-any.whl → 0.0.0.dev506__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 omlish might be problematic. Click here for more details.
- omlish/CODESTYLE.md +345 -0
- omlish/README.md +199 -0
- omlish/__about__.py +12 -5
- omlish/_check.cc +209 -0
- omlish/check.py +11 -0
- omlish/dataclasses/__init__.py +4 -0
- omlish/dataclasses/impl/concerns/frozen.py +4 -1
- omlish/dataclasses/impl/generation/plans.py +2 -17
- omlish/dataclasses/impl/generation/processor.py +2 -2
- omlish/dataclasses/impl/processing/driving.py +13 -1
- omlish/dataclasses/tools/replace.py +27 -0
- omlish/diag/_pycharm/runhack.py +1 -1
- omlish/dispatch/functions.py +1 -1
- omlish/formats/json/stream/lexing.py +13 -5
- omlish/formats/json/stream/parsing.py +1 -1
- omlish/inject/README.md +430 -0
- omlish/inject/__init__.py +20 -11
- omlish/inject/_dataclasses.py +1545 -1383
- omlish/inject/binder.py +7 -4
- omlish/inject/eagers.py +2 -4
- omlish/inject/elements.py +4 -0
- omlish/inject/helpers/late.py +76 -0
- omlish/inject/{managed.py → helpers/managed.py} +37 -34
- omlish/inject/impl/elements.py +7 -4
- omlish/inject/impl/injector.py +14 -26
- omlish/inject/impl/inspect.py +0 -8
- omlish/inject/impl/origins.py +1 -0
- omlish/inject/impl/privates.py +2 -6
- omlish/inject/impl/providers.py +0 -4
- omlish/inject/impl/scopes.py +14 -18
- omlish/inject/inspect.py +10 -1
- omlish/inject/multis.py +0 -3
- omlish/inject/scopes.py +7 -5
- omlish/io/buffers.py +35 -8
- omlish/lang/__init__.py +10 -0
- omlish/lang/classes/simple.py +2 -1
- omlish/lang/iterables.py +6 -0
- omlish/lang/objects.py +13 -0
- omlish/lang/outcomes.py +1 -1
- omlish/lang/recursion.py +1 -1
- omlish/lang/sequences.py +33 -0
- omlish/lifecycles/README.md +30 -0
- omlish/lifecycles/__init__.py +87 -13
- omlish/lifecycles/_dataclasses.py +1388 -0
- omlish/lifecycles/base.py +178 -64
- omlish/lifecycles/contextmanagers.py +113 -4
- omlish/lifecycles/controller.py +150 -87
- omlish/lifecycles/injection.py +143 -0
- omlish/lifecycles/listeners.py +56 -0
- omlish/lifecycles/managed.py +142 -0
- omlish/lifecycles/manager.py +218 -93
- omlish/lifecycles/states.py +2 -0
- omlish/lifecycles/transitions.py +3 -0
- omlish/lifecycles/unwrap.py +57 -0
- omlish/lite/maybes.py +7 -0
- omlish/lite/typing.py +33 -0
- omlish/logs/_amalg.py +1 -1
- omlish/logs/all.py +36 -11
- omlish/logs/asyncs.py +73 -0
- omlish/logs/base.py +101 -12
- omlish/logs/bisync.py +99 -0
- omlish/logs/contexts.py +4 -1
- omlish/logs/lists.py +125 -0
- omlish/logs/modules.py +19 -1
- omlish/logs/std/loggers.py +6 -1
- omlish/logs/std/noisy.py +11 -9
- omlish/logs/{standard.py → std/standard.py} +3 -4
- omlish/logs/utils.py +16 -1
- omlish/marshal/_dataclasses.py +813 -813
- omlish/reflect/__init__.py +43 -26
- omlish/reflect/ops.py +10 -1
- omlish/specs/jmespath/_dataclasses.py +597 -597
- omlish/specs/jsonschema/keywords/_dataclasses.py +244 -244
- omlish/sql/__init__.py +24 -5
- omlish/sql/api/dbapi.py +1 -1
- omlish/sql/dbapi/__init__.py +15 -0
- omlish/sql/{dbapi.py → dbapi/drivers.py} +2 -2
- omlish/sql/queries/__init__.py +3 -0
- omlish/testing/pytest/plugins/asyncs/plugin.py +2 -0
- omlish/text/docwrap/cli.py +5 -0
- omlish/typedvalues/_collection.cc +500 -0
- omlish/typedvalues/collection.py +159 -62
- omlish/typedvalues/generic.py +5 -4
- omlish/typedvalues/values.py +6 -0
- {omlish-0.0.0.dev484.dist-info → omlish-0.0.0.dev506.dist-info}/METADATA +14 -9
- {omlish-0.0.0.dev484.dist-info → omlish-0.0.0.dev506.dist-info}/RECORD +92 -77
- omlish/lifecycles/abstract.py +0 -86
- /omlish/inject/{impl → helpers}/proxy.py +0 -0
- /omlish/sql/{abc.py → dbapi/abc.py} +0 -0
- {omlish-0.0.0.dev484.dist-info → omlish-0.0.0.dev506.dist-info}/WHEEL +0 -0
- {omlish-0.0.0.dev484.dist-info → omlish-0.0.0.dev506.dist-info}/entry_points.txt +0 -0
- {omlish-0.0.0.dev484.dist-info → omlish-0.0.0.dev506.dist-info}/licenses/LICENSE +0 -0
- {omlish-0.0.0.dev484.dist-info → omlish-0.0.0.dev506.dist-info}/top_level.txt +0 -0
omlish/lang/objects.py
CHANGED
|
@@ -2,6 +2,7 @@ import types
|
|
|
2
2
|
import typing as ta
|
|
3
3
|
import weakref
|
|
4
4
|
|
|
5
|
+
from ..lite.maybes import Maybe
|
|
5
6
|
from .classes.abstract import is_abstract_class
|
|
6
7
|
|
|
7
8
|
|
|
@@ -24,6 +25,18 @@ def opt_repr(obj: ta.Any) -> str | None:
|
|
|
24
25
|
return repr(obj)
|
|
25
26
|
|
|
26
27
|
|
|
28
|
+
def just_repr(obj: Maybe) -> str | None:
|
|
29
|
+
return obj.map(repr).or_none()
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def opt_or_just_repr(obj: ta.Any) -> str | None:
|
|
33
|
+
if isinstance(obj, Maybe):
|
|
34
|
+
if obj.present:
|
|
35
|
+
return repr(obj)
|
|
36
|
+
return None
|
|
37
|
+
return opt_repr(obj)
|
|
38
|
+
|
|
39
|
+
|
|
27
40
|
##
|
|
28
41
|
|
|
29
42
|
|
omlish/lang/outcomes.py
CHANGED
omlish/lang/recursion.py
CHANGED
|
@@ -65,7 +65,7 @@ def recursion_limiting_context(key: ta.Any, limit: int | None) -> ta.Iterator[in
|
|
|
65
65
|
except KeyError:
|
|
66
66
|
pd = None
|
|
67
67
|
else:
|
|
68
|
-
if not isinstance(pd, int) and pd > 0:
|
|
68
|
+
if not (isinstance(pd, int) and pd > 0):
|
|
69
69
|
raise RuntimeError
|
|
70
70
|
|
|
71
71
|
if pd is not None and pd >= limit:
|
omlish/lang/sequences.py
CHANGED
|
@@ -8,6 +8,7 @@ TODO:
|
|
|
8
8
|
- shorter repr if __len__ > some threshold
|
|
9
9
|
- use materialize()?
|
|
10
10
|
"""
|
|
11
|
+
import operator
|
|
11
12
|
import typing as ta
|
|
12
13
|
|
|
13
14
|
|
|
@@ -36,6 +37,38 @@ def iterrange(
|
|
|
36
37
|
##
|
|
37
38
|
|
|
38
39
|
|
|
40
|
+
def seqs_all(
|
|
41
|
+
fn: ta.Callable[[T, T], bool],
|
|
42
|
+
l_seq: ta.Sequence[T],
|
|
43
|
+
*r_seqs: ta.Sequence[T],
|
|
44
|
+
) -> bool:
|
|
45
|
+
if not all(len(r_seq) == len(l_seq) for r_seq in r_seqs):
|
|
46
|
+
return False
|
|
47
|
+
|
|
48
|
+
return all(
|
|
49
|
+
fn(l, r)
|
|
50
|
+
for r_seq in r_seqs
|
|
51
|
+
for l, r in zip(l_seq, r_seq, strict=True)
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def seqs_equal(
|
|
56
|
+
l_seq: ta.Sequence[T],
|
|
57
|
+
*r_seqs: ta.Sequence[T],
|
|
58
|
+
) -> bool:
|
|
59
|
+
return seqs_all(operator.eq, l_seq, *r_seqs)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def seqs_identical(
|
|
63
|
+
l_seq: ta.Sequence[T],
|
|
64
|
+
*r_seqs: ta.Sequence[T],
|
|
65
|
+
) -> bool:
|
|
66
|
+
return seqs_all(operator.is_, l_seq, *r_seqs)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
##
|
|
70
|
+
|
|
71
|
+
|
|
39
72
|
@ta.final
|
|
40
73
|
class SeqView(ta.Sequence[T]):
|
|
41
74
|
def __init__(self, data: ta.Sequence[T], slice_: slice = slice(None)) -> None:
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Lifecycle management, inspired by [governator](https://github.com/Netflix/governator/tree/master/governator-core/).
|
|
2
|
+
|
|
3
|
+
A central idea is to 'hide the guts' of a given class's lifecycle management from code interacting with it.
|
|
4
|
+
|
|
5
|
+
The main classes are as follows:
|
|
6
|
+
|
|
7
|
+
- Lifecycle / AsyncLifecycle - the code 'managed by' the rest of the lifecycle machinery. In general, user code will
|
|
8
|
+
hide its implementations of these from the code that otherwise interacts with it. Being the lowest level / unit of
|
|
9
|
+
management callbacks, it intentionally provides no additional machinery, existing solely as a skeleton of methods
|
|
10
|
+
which will be called by lifecycle internals - this is to reduce friction with more functional / less OO code. However,
|
|
11
|
+
it still chooses to be a class with multiple nullary methods, rather than a more functional-style single unary free
|
|
12
|
+
function: the operations present in each method are generally intended to have no overlap in practice, and their
|
|
13
|
+
explicit division is a conscious choice.
|
|
14
|
+
|
|
15
|
+
- LifecycleManaged / AsyncLifecycleManaged - a mixin which can be used to add lifecycle management behavior to a class.
|
|
16
|
+
This removes the need for manual subclassing of Lifecycle / AsyncLifecycle, providing private '\_lifecycle_<state>'
|
|
17
|
+
callback methods (with default no-op implementations) which subclasses may override.
|
|
18
|
+
|
|
19
|
+
- LifecycleListener / AsyncLifecycleListener - callback interfaces whose methods will be called when a lifecycle object
|
|
20
|
+
goes through a lifecycle state transition.
|
|
21
|
+
|
|
22
|
+
- LifecycleController / AsyncLifecycleController - these classes run the state machine for any single Lifecycle /
|
|
23
|
+
AsyncLifecycle instance. They are also responsible for maintaining a registry of lifecycle listeners and calling their
|
|
24
|
+
methods as necessary. Unlike user code, these classes are openly subclasses of Lifecycle / AsyncLifecycle, allowing
|
|
25
|
+
them to be called as application state dictates - they will internally ensure correct state transitions.
|
|
26
|
+
|
|
27
|
+
- LifecycleManager / AsyncLifecycleManager - these classes are responsible for construction and operation of (acyclic)
|
|
28
|
+
graphs of lifecycle objects. They will ensure that, as necessary according to registered dependencies, lifecycle
|
|
29
|
+
objects are started in the correct order, and that they are stopped in the correct order. This class is itself a
|
|
30
|
+
LifecycleManaged / AsyncLifecycleManaged. Notably, AsyncLifecycleManager can also manage sync Lifecycles.
|
omlish/lifecycles/__init__.py
CHANGED
|
@@ -1,43 +1,71 @@
|
|
|
1
|
-
from
|
|
2
|
-
AbstractLifecycle,
|
|
1
|
+
from .. import dataclasses as _dc
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
|
|
4
|
+
_dc.init_package(
|
|
5
|
+
globals(),
|
|
6
|
+
codegen=True,
|
|
5
7
|
)
|
|
6
8
|
|
|
9
|
+
|
|
10
|
+
##
|
|
11
|
+
|
|
12
|
+
|
|
7
13
|
from .base import ( # noqa
|
|
8
|
-
|
|
14
|
+
Lifecycle,
|
|
15
|
+
AsyncLifecycle,
|
|
9
16
|
AnyLifecycle,
|
|
10
|
-
|
|
17
|
+
ANY_LIFECYCLE_TYPES,
|
|
11
18
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
19
|
+
sync_to_async_lifecycle,
|
|
20
|
+
as_async_lifecycle,
|
|
21
|
+
async_to_sync_lifecycle,
|
|
22
|
+
as_sync_lifecycle,
|
|
15
23
|
|
|
16
|
-
|
|
24
|
+
CallbackLifecycle,
|
|
17
25
|
CallbackAsyncLifecycle,
|
|
18
|
-
AsyncLifecycle,
|
|
19
26
|
)
|
|
20
27
|
|
|
21
28
|
from .contextmanagers import ( # noqa
|
|
22
29
|
ContextManagerLifecycle,
|
|
30
|
+
AsyncContextManagerLifecycle,
|
|
31
|
+
|
|
23
32
|
LifecycleContextManager,
|
|
33
|
+
AsyncLifecycleContextManager,
|
|
34
|
+
|
|
35
|
+
lifecycle_context_manage,
|
|
36
|
+
async_lifecycle_context_manage,
|
|
24
37
|
)
|
|
25
38
|
|
|
26
39
|
from .controller import ( # noqa
|
|
27
|
-
|
|
40
|
+
LifecycleController,
|
|
41
|
+
AsyncLifecycleController,
|
|
28
42
|
AnyLifecycleController,
|
|
43
|
+
ANY_LIFECYCLE_CONTROLLER_TYPES,
|
|
44
|
+
)
|
|
29
45
|
|
|
30
|
-
|
|
46
|
+
from .listeners import ( # noqa
|
|
31
47
|
LifecycleListener,
|
|
48
|
+
AsyncLifecycleListener,
|
|
49
|
+
AnyLifecycleListener,
|
|
50
|
+
ANY_LIFECYCLE_LISTENER_TYPES,
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
from .managed import ( # noqa
|
|
54
|
+
LifecycleManaged,
|
|
55
|
+
AsyncLifecycleManaged,
|
|
56
|
+
AnyLifecycleManaged,
|
|
57
|
+
ANY_LIFECYCLE_MANAGED_TYPES,
|
|
32
58
|
)
|
|
33
59
|
|
|
34
60
|
from .manager import ( # noqa
|
|
61
|
+
LifecycleManagerEntry,
|
|
35
62
|
LifecycleManager,
|
|
63
|
+
AsyncLifecycleManager,
|
|
36
64
|
)
|
|
37
65
|
|
|
38
66
|
from .states import ( # noqa
|
|
39
|
-
LifecycleState,
|
|
40
67
|
LifecycleStateError,
|
|
68
|
+
LifecycleState,
|
|
41
69
|
LifecycleStates,
|
|
42
70
|
)
|
|
43
71
|
|
|
@@ -45,3 +73,49 @@ from .transitions import ( # noqa
|
|
|
45
73
|
LifecycleTransition,
|
|
46
74
|
LifecycleTransitions,
|
|
47
75
|
)
|
|
76
|
+
|
|
77
|
+
from .unwrap import ( # noqa
|
|
78
|
+
unwrap_lifecycle,
|
|
79
|
+
unwrap_async_lifecycle,
|
|
80
|
+
unwrap_any_lifecycle,
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
##
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
from .. import lang as _lang # noqa
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
with _lang.auto_proxy_init(globals()):
|
|
91
|
+
##
|
|
92
|
+
|
|
93
|
+
from .injection import ( # noqa
|
|
94
|
+
bind_lifecycle_registrar,
|
|
95
|
+
bind_async_lifecycle_registrar,
|
|
96
|
+
|
|
97
|
+
bind_managed_lifecycle_manager,
|
|
98
|
+
bind_async_managed_lifecycle_manager,
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
##
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
NEW = LifecycleStates.NEW
|
|
106
|
+
|
|
107
|
+
CONSTRUCTING = LifecycleStates.CONSTRUCTING
|
|
108
|
+
FAILED_CONSTRUCTING = LifecycleStates.FAILED_CONSTRUCTING
|
|
109
|
+
CONSTRUCTED = LifecycleStates.CONSTRUCTED
|
|
110
|
+
|
|
111
|
+
STARTING = LifecycleStates.STARTING
|
|
112
|
+
FAILED_STARTING = LifecycleStates.FAILED_STARTING
|
|
113
|
+
STARTED = LifecycleStates.STARTED
|
|
114
|
+
|
|
115
|
+
STOPPING = LifecycleStates.STOPPING
|
|
116
|
+
FAILED_STOPPING = LifecycleStates.FAILED_STOPPING
|
|
117
|
+
STOPPED = LifecycleStates.STOPPED
|
|
118
|
+
|
|
119
|
+
DESTROYING = LifecycleStates.DESTROYING
|
|
120
|
+
FAILED_DESTROYING = LifecycleStates.FAILED_DESTROYING
|
|
121
|
+
DESTROYED = LifecycleStates.DESTROYED
|