omlish 0.0.0.dev416__py3-none-any.whl → 0.0.0.dev418__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.
- omlish/__about__.py +2 -2
- omlish/bootstrap/__init__.py +2 -2
- omlish/dataclasses/__init__.py +23 -13
- omlish/dataclasses/impl/configs.py +1 -1
- omlish/dataclasses/impl/processing/base.py +1 -1
- omlish/inject/__init__.py +12 -0
- omlish/marshal/__init__.py +229 -202
- omlish/marshal/base/configs.py +18 -0
- omlish/marshal/base/contexts.py +8 -7
- omlish/marshal/base/funcs.py +57 -0
- omlish/marshal/base/overrides.py +11 -6
- omlish/marshal/base/registries.py +58 -14
- omlish/marshal/base/types.py +4 -26
- omlish/marshal/factories/invalidate.py +118 -0
- omlish/marshal/factories/moduleimport/__init__.py +0 -0
- omlish/marshal/factories/moduleimport/configs.py +26 -0
- omlish/marshal/factories/moduleimport/factories.py +114 -0
- omlish/marshal/factories/typecache.py +24 -4
- omlish/marshal/globals.py +28 -13
- omlish/marshal/objects/dataclasses.py +29 -4
- omlish/marshal/polymorphism/metadata.py +2 -2
- omlish/marshal/standard.py +132 -65
- omlish/secrets/all.py +0 -9
- omlish/secrets/secrets.py +4 -6
- omlish/specs/jsonrpc/__init__.py +2 -2
- omlish/specs/jsonschema/__init__.py +2 -2
- omlish/specs/openapi/__init__.py +2 -2
- omlish/sql/queries/__init__.py +4 -2
- omlish/sql/tabledefs/__init__.py +2 -2
- omlish/text/templating.py +9 -7
- omlish/typedvalues/__init__.py +41 -34
- {omlish-0.0.0.dev416.dist-info → omlish-0.0.0.dev418.dist-info}/METADATA +1 -1
- {omlish-0.0.0.dev416.dist-info → omlish-0.0.0.dev418.dist-info}/RECORD +43 -38
- omlish/marshal/factories/func.py +0 -28
- /omlish/bootstrap/{marshal.py → _marshal.py} +0 -0
- /omlish/specs/jsonrpc/{marshal.py → _marshal.py} +0 -0
- /omlish/specs/jsonschema/{marshal.py → _marshal.py} +0 -0
- /omlish/specs/openapi/{marshal.py → _marshal.py} +0 -0
- /omlish/sql/queries/{marshal.py → _marshal.py} +0 -0
- /omlish/sql/tabledefs/{marshal.py → _marshal.py} +0 -0
- {omlish-0.0.0.dev416.dist-info → omlish-0.0.0.dev418.dist-info}/WHEEL +0 -0
- {omlish-0.0.0.dev416.dist-info → omlish-0.0.0.dev418.dist-info}/entry_points.txt +0 -0
- {omlish-0.0.0.dev416.dist-info → omlish-0.0.0.dev418.dist-info}/licenses/LICENSE +0 -0
- {omlish-0.0.0.dev416.dist-info → omlish-0.0.0.dev418.dist-info}/top_level.txt +0 -0
@@ -2,7 +2,7 @@ import dataclasses as dc
|
|
2
2
|
import typing as ta
|
3
3
|
|
4
4
|
from ... import lang
|
5
|
-
from ..base.
|
5
|
+
from ..base.configs import Config
|
6
6
|
from ..naming import Naming
|
7
7
|
from ..naming import translate_name
|
8
8
|
|
@@ -10,7 +10,7 @@ from ..naming import translate_name
|
|
10
10
|
##
|
11
11
|
|
12
12
|
|
13
|
-
class TypeTagging(
|
13
|
+
class TypeTagging(Config, lang.Abstract, lang.Sealed):
|
14
14
|
pass
|
15
15
|
|
16
16
|
|
omlish/marshal/standard.py
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
"""
|
2
|
+
FIXME:
|
3
|
+
- this is gross and temporary
|
4
|
+
- move to global registry somehow
|
5
|
+
"""
|
6
|
+
import threading
|
1
7
|
import typing as ta
|
2
8
|
|
3
9
|
from .base.types import MarshalerFactory
|
@@ -16,6 +22,10 @@ from .composite.optionals import OptionalMarshalerFactory
|
|
16
22
|
from .composite.optionals import OptionalUnmarshalerFactory
|
17
23
|
from .composite.special import SequenceNotStrMarshalerFactory
|
18
24
|
from .composite.special import SequenceNotStrUnmarshalerFactory
|
25
|
+
from .factories.invalidate import InvalidatableMarshalerFactory
|
26
|
+
from .factories.invalidate import InvalidatableUnmarshalerFactory
|
27
|
+
from .factories.moduleimport.factories import ModuleImportingMarshalerFactory
|
28
|
+
from .factories.moduleimport.factories import ModuleImportingUnmarshalerFactory
|
19
29
|
from .factories.multi import MultiMarshalerFactory
|
20
30
|
from .factories.multi import MultiUnmarshalerFactory
|
21
31
|
from .factories.recursive import RecursiveMarshalerFactory
|
@@ -45,24 +55,53 @@ from .trivial.any import ANY_UNMARSHALER_FACTORY
|
|
45
55
|
##
|
46
56
|
|
47
57
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
58
|
+
class StandardFactories(ta.NamedTuple):
|
59
|
+
marshaler_factories: ta.Sequence[MarshalerFactory]
|
60
|
+
unmarshaler_factories: ta.Sequence[UnmarshalerFactory]
|
61
|
+
|
62
|
+
|
63
|
+
DEFAULT_STANDARD_FACTORIES = StandardFactories(
|
64
|
+
(
|
65
|
+
PRIMITIVE_MARSHALER_FACTORY,
|
66
|
+
NewtypeMarshalerFactory(),
|
67
|
+
OptionalMarshalerFactory(),
|
68
|
+
PrimitiveUnionMarshalerFactory(),
|
69
|
+
DataclassMarshalerFactory(),
|
70
|
+
NamedtupleMarshalerFactory(),
|
71
|
+
EnumMarshalerFactory(),
|
72
|
+
LiteralMarshalerFactory(),
|
73
|
+
NUMBERS_MARSHALER_FACTORY,
|
74
|
+
UUID_MARSHALER_FACTORY,
|
75
|
+
DATETIME_MARSHALER_FACTORY,
|
76
|
+
MaybeMarshalerFactory(),
|
77
|
+
MappingMarshalerFactory(),
|
78
|
+
SequenceNotStrMarshalerFactory(),
|
79
|
+
IterableMarshalerFactory(),
|
80
|
+
ANY_MARSHALER_FACTORY,
|
81
|
+
),
|
82
|
+
|
83
|
+
(
|
84
|
+
PRIMITIVE_UNMARSHALER_FACTORY,
|
85
|
+
NewtypeUnmarshalerFactory(),
|
86
|
+
OptionalUnmarshalerFactory(),
|
87
|
+
PrimitiveUnionUnmarshalerFactory(),
|
88
|
+
DataclassUnmarshalerFactory(),
|
89
|
+
NamedtupleUnmarshalerFactory(),
|
90
|
+
EnumUnmarshalerFactory(),
|
91
|
+
LiteralUnmarshalerFactory(),
|
92
|
+
NUMBERS_UNMARSHALER_FACTORY,
|
93
|
+
UUID_UNMARSHALER_FACTORY,
|
94
|
+
DATETIME_UNMARSHALER_FACTORY,
|
95
|
+
MaybeUnmarshalerFactory(),
|
96
|
+
MappingUnmarshalerFactory(),
|
97
|
+
SequenceNotStrUnmarshalerFactory(),
|
98
|
+
IterableUnmarshalerFactory(),
|
99
|
+
ANY_UNMARSHALER_FACTORY,
|
100
|
+
),
|
101
|
+
)
|
102
|
+
|
103
|
+
|
104
|
+
##
|
66
105
|
|
67
106
|
|
68
107
|
def new_standard_marshaler_factory(
|
@@ -70,38 +109,32 @@ def new_standard_marshaler_factory(
|
|
70
109
|
first: ta.Iterable[MarshalerFactory] | None = None,
|
71
110
|
last: ta.Iterable[MarshalerFactory] | None = None,
|
72
111
|
) -> MarshalerFactory:
|
73
|
-
|
74
|
-
RecursiveMarshalerFactory(
|
75
|
-
MultiMarshalerFactory([
|
76
|
-
*(first if first is not None else []),
|
77
|
-
*STANDARD_MARSHALER_FACTORIES,
|
78
|
-
*(last if last is not None else []),
|
79
|
-
]),
|
80
|
-
),
|
81
|
-
)
|
112
|
+
gl: ta.Any = None
|
82
113
|
|
114
|
+
def fi_fn():
|
115
|
+
nonlocal gl
|
116
|
+
gl = DEFAULT_STANDARD_FACTORIES
|
83
117
|
|
84
|
-
|
118
|
+
fi: MarshalerFactory = MultiMarshalerFactory([
|
119
|
+
*(first if first is not None else []),
|
120
|
+
*gl.marshaler_factories,
|
121
|
+
*(last if last is not None else []),
|
122
|
+
])
|
123
|
+
|
124
|
+
fi = RecursiveMarshalerFactory(fi)
|
125
|
+
|
126
|
+
fi = TypeCacheMarshalerFactory(fi)
|
85
127
|
|
128
|
+
return fi
|
86
129
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
LiteralUnmarshalerFactory(),
|
96
|
-
NUMBERS_UNMARSHALER_FACTORY,
|
97
|
-
UUID_UNMARSHALER_FACTORY,
|
98
|
-
DATETIME_UNMARSHALER_FACTORY,
|
99
|
-
MaybeUnmarshalerFactory(),
|
100
|
-
MappingUnmarshalerFactory(),
|
101
|
-
SequenceNotStrUnmarshalerFactory(),
|
102
|
-
IterableUnmarshalerFactory(),
|
103
|
-
ANY_UNMARSHALER_FACTORY,
|
104
|
-
]
|
130
|
+
fo: MarshalerFactory = (iv := InvalidatableMarshalerFactory(
|
131
|
+
fi_fn,
|
132
|
+
lambda: DEFAULT_STANDARD_FACTORIES is not gl,
|
133
|
+
))
|
134
|
+
|
135
|
+
fo = ModuleImportingMarshalerFactory(fo, iv.invalidate)
|
136
|
+
|
137
|
+
return fo
|
105
138
|
|
106
139
|
|
107
140
|
def new_standard_unmarshaler_factory(
|
@@ -109,33 +142,67 @@ def new_standard_unmarshaler_factory(
|
|
109
142
|
first: ta.Iterable[UnmarshalerFactory] | None = None,
|
110
143
|
last: ta.Iterable[UnmarshalerFactory] | None = None,
|
111
144
|
) -> UnmarshalerFactory:
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
145
|
+
gl: ta.Any = None
|
146
|
+
|
147
|
+
def fi_fn():
|
148
|
+
nonlocal gl
|
149
|
+
gl = DEFAULT_STANDARD_FACTORIES
|
150
|
+
|
151
|
+
fi: UnmarshalerFactory = MultiUnmarshalerFactory([
|
152
|
+
*(first if first is not None else []),
|
153
|
+
*gl.unmarshaler_factories,
|
154
|
+
*(last if last is not None else []),
|
155
|
+
])
|
156
|
+
|
157
|
+
fi = RecursiveUnmarshalerFactory(fi)
|
158
|
+
|
159
|
+
fi = TypeCacheUnmarshalerFactory(fi)
|
160
|
+
|
161
|
+
return fi
|
162
|
+
|
163
|
+
fo: UnmarshalerFactory = (iv := InvalidatableUnmarshalerFactory(
|
164
|
+
fi_fn,
|
165
|
+
lambda: DEFAULT_STANDARD_FACTORIES is not gl,
|
166
|
+
))
|
167
|
+
|
168
|
+
fo = ModuleImportingUnmarshalerFactory(fo, iv.invalidate)
|
169
|
+
|
170
|
+
return fo
|
121
171
|
|
122
172
|
|
123
173
|
##
|
124
174
|
|
125
175
|
|
176
|
+
_GLOBAL_LOCK = threading.RLock()
|
177
|
+
|
178
|
+
|
126
179
|
def install_standard_factories(
|
127
180
|
*factories: MarshalerFactory | UnmarshalerFactory,
|
128
181
|
) -> None:
|
129
|
-
|
130
|
-
|
182
|
+
with _GLOBAL_LOCK:
|
183
|
+
global DEFAULT_STANDARD_FACTORIES
|
184
|
+
|
185
|
+
m_lst: list[MarshalerFactory] = list(DEFAULT_STANDARD_FACTORIES.marshaler_factories)
|
186
|
+
u_lst: list[UnmarshalerFactory] = list(DEFAULT_STANDARD_FACTORIES.unmarshaler_factories)
|
187
|
+
|
188
|
+
for f in factories:
|
189
|
+
k = False
|
190
|
+
|
191
|
+
if isinstance(f, MarshalerFactory):
|
192
|
+
m_lst[0:0] = [f]
|
193
|
+
k = True
|
194
|
+
|
195
|
+
if isinstance(f, UnmarshalerFactory):
|
196
|
+
u_lst[0:0] = [f]
|
197
|
+
k = True
|
131
198
|
|
132
|
-
|
133
|
-
|
134
|
-
k = True
|
199
|
+
if not k:
|
200
|
+
raise TypeError(f)
|
135
201
|
|
136
|
-
|
137
|
-
|
138
|
-
|
202
|
+
new = StandardFactories(
|
203
|
+
tuple(m_lst),
|
204
|
+
tuple(u_lst),
|
205
|
+
)
|
139
206
|
|
140
|
-
if
|
141
|
-
|
207
|
+
if new != DEFAULT_STANDARD_FACTORIES:
|
208
|
+
DEFAULT_STANDARD_FACTORIES = new
|
omlish/secrets/all.py
CHANGED
omlish/secrets/secrets.py
CHANGED
@@ -20,6 +20,10 @@ import typing as ta
|
|
20
20
|
|
21
21
|
from .. import dataclasses as dc
|
22
22
|
from .. import lang
|
23
|
+
from .. import marshal as msh
|
24
|
+
|
25
|
+
|
26
|
+
msh.register_global_module_import('.marshal', __package__)
|
23
27
|
|
24
28
|
|
25
29
|
log = logging.getLogger(__name__)
|
@@ -341,9 +345,3 @@ class EnvVarSecrets(Secrets):
|
|
341
345
|
return dct.pop(ekey)
|
342
346
|
else:
|
343
347
|
return dct[ekey]
|
344
|
-
|
345
|
-
|
346
|
-
##
|
347
|
-
|
348
|
-
|
349
|
-
lang.register_conditional_import('..marshal', '.marshal', __package__)
|
omlish/specs/jsonrpc/__init__.py
CHANGED
omlish/specs/openapi/__init__.py
CHANGED
omlish/sql/queries/__init__.py
CHANGED
@@ -112,8 +112,10 @@ Q = StdBuilder()
|
|
112
112
|
##
|
113
113
|
|
114
114
|
|
115
|
-
from ... import
|
115
|
+
from ... import marshal as _msh # noqa
|
116
|
+
|
117
|
+
_msh.register_global_module_import('._marshal', __package__)
|
116
118
|
|
117
|
-
|
119
|
+
from ... import lang as _lang # noqa
|
118
120
|
|
119
121
|
_lang.trigger_conditional_imports(__package__)
|
omlish/sql/tabledefs/__init__.py
CHANGED
omlish/text/templating.py
CHANGED
@@ -9,16 +9,18 @@ import string
|
|
9
9
|
import typing as ta
|
10
10
|
|
11
11
|
from .. import lang
|
12
|
-
from .minja import MinjaTemplate
|
13
|
-
from .minja import MinjaTemplateParam
|
14
|
-
from .minja import compile_minja_template
|
15
12
|
|
16
13
|
|
17
14
|
if ta.TYPE_CHECKING:
|
18
15
|
import jinja2
|
16
|
+
|
17
|
+
from . import minja
|
18
|
+
|
19
19
|
else:
|
20
20
|
jinja2 = lang.proxy_import('jinja2')
|
21
21
|
|
22
|
+
minja = lang.proxy_import('.minja', __package__)
|
23
|
+
|
22
24
|
|
23
25
|
##
|
24
26
|
|
@@ -97,7 +99,7 @@ pep292_templater = Pep292Templater.from_string
|
|
97
99
|
|
98
100
|
@dc.dataclass(frozen=True)
|
99
101
|
class MinjaTemplater(Templater):
|
100
|
-
tmpl: MinjaTemplate
|
102
|
+
tmpl: 'minja.MinjaTemplate'
|
101
103
|
|
102
104
|
ENV_IDENT: ta.ClassVar[str] = 'env'
|
103
105
|
|
@@ -110,12 +112,12 @@ class MinjaTemplater(Templater):
|
|
110
112
|
src: str,
|
111
113
|
**ns: ta.Any,
|
112
114
|
) -> 'MinjaTemplater':
|
113
|
-
tmpl = compile_minja_template(
|
115
|
+
tmpl = minja.compile_minja_template(
|
114
116
|
src,
|
115
117
|
[
|
116
|
-
MinjaTemplateParam(cls.ENV_IDENT),
|
118
|
+
minja.MinjaTemplateParam(cls.ENV_IDENT),
|
117
119
|
*[
|
118
|
-
MinjaTemplateParam.new(k, v)
|
120
|
+
minja.MinjaTemplateParam.new(k, v)
|
119
121
|
for k, v in ns.items()
|
120
122
|
],
|
121
123
|
],
|
omlish/typedvalues/__init__.py
CHANGED
@@ -1,54 +1,61 @@
|
|
1
|
-
from
|
2
|
-
|
3
|
-
|
1
|
+
from .. import lang as _lang
|
2
|
+
|
3
|
+
|
4
|
+
with _lang.auto_proxy_init(globals()) as _api_cap:
|
5
|
+
##
|
4
6
|
|
5
|
-
from .
|
6
|
-
|
7
|
+
from .accessor import ( # noqa
|
8
|
+
TypedValuesAccessor,
|
9
|
+
)
|
7
10
|
|
8
|
-
|
11
|
+
from .collection import ( # noqa
|
12
|
+
DuplicateUniqueTypedValueError,
|
9
13
|
|
10
|
-
|
11
|
-
as_collection,
|
12
|
-
)
|
14
|
+
TypedValues,
|
13
15
|
|
14
|
-
|
15
|
-
|
16
|
+
collect,
|
17
|
+
as_collection,
|
18
|
+
)
|
16
19
|
|
17
|
-
|
20
|
+
from .consumer import ( # noqa
|
21
|
+
UnconsumedTypedValuesError,
|
18
22
|
|
19
|
-
|
20
|
-
)
|
23
|
+
TypedValuesConsumer,
|
21
24
|
|
22
|
-
|
23
|
-
|
24
|
-
)
|
25
|
+
consume,
|
26
|
+
)
|
25
27
|
|
26
|
-
from .
|
27
|
-
|
28
|
-
)
|
28
|
+
from .generic import ( # noqa
|
29
|
+
TypedValueGeneric,
|
30
|
+
)
|
29
31
|
|
30
|
-
from .
|
31
|
-
|
32
|
-
)
|
32
|
+
from .holder import ( # noqa
|
33
|
+
TypedValueHolder,
|
34
|
+
)
|
33
35
|
|
34
|
-
from .
|
35
|
-
|
36
|
-
)
|
36
|
+
from .of_ import ( # noqa
|
37
|
+
of,
|
38
|
+
)
|
37
39
|
|
38
|
-
from .
|
39
|
-
|
40
|
+
from .reflect import ( # noqa
|
41
|
+
reflect_typed_values_impls,
|
42
|
+
)
|
40
43
|
|
41
|
-
|
44
|
+
from .values import ( # noqa
|
45
|
+
TypedValue,
|
42
46
|
|
43
|
-
|
47
|
+
UniqueTypedValue,
|
44
48
|
|
45
|
-
|
46
|
-
|
49
|
+
ScalarTypedValue,
|
50
|
+
|
51
|
+
UniqueScalarTypedValue,
|
52
|
+
)
|
47
53
|
|
48
54
|
|
49
55
|
##
|
50
56
|
|
51
57
|
|
52
|
-
from .. import
|
58
|
+
from .. import marshal as _msh
|
59
|
+
|
53
60
|
|
54
|
-
|
61
|
+
_msh.register_global_module_import('.marshal', __package__)
|