omlish 0.0.0.dev416__py3-none-any.whl → 0.0.0.dev417__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.
Files changed (38) hide show
  1. omlish/__about__.py +2 -2
  2. omlish/bootstrap/__init__.py +2 -2
  3. omlish/dataclasses/__init__.py +23 -13
  4. omlish/dataclasses/impl/processing/base.py +1 -1
  5. omlish/marshal/__init__.py +224 -203
  6. omlish/marshal/base/configs.py +18 -0
  7. omlish/marshal/base/contexts.py +8 -7
  8. omlish/marshal/base/overrides.py +11 -6
  9. omlish/marshal/base/registries.py +58 -14
  10. omlish/marshal/base/types.py +5 -5
  11. omlish/marshal/factories/invalidate.py +118 -0
  12. omlish/marshal/factories/moduleimport/__init__.py +0 -0
  13. omlish/marshal/factories/moduleimport/configs.py +26 -0
  14. omlish/marshal/factories/moduleimport/factories.py +114 -0
  15. omlish/marshal/factories/typecache.py +24 -4
  16. omlish/marshal/globals.py +28 -13
  17. omlish/marshal/polymorphism/metadata.py +2 -2
  18. omlish/marshal/standard.py +132 -65
  19. omlish/secrets/all.py +0 -9
  20. omlish/secrets/secrets.py +4 -6
  21. omlish/specs/jsonrpc/__init__.py +2 -2
  22. omlish/specs/jsonschema/__init__.py +2 -2
  23. omlish/specs/openapi/__init__.py +2 -2
  24. omlish/sql/queries/__init__.py +4 -2
  25. omlish/sql/tabledefs/__init__.py +2 -2
  26. omlish/typedvalues/__init__.py +2 -2
  27. {omlish-0.0.0.dev416.dist-info → omlish-0.0.0.dev417.dist-info}/METADATA +1 -1
  28. {omlish-0.0.0.dev416.dist-info → omlish-0.0.0.dev417.dist-info}/RECORD +38 -33
  29. /omlish/bootstrap/{marshal.py → _marshal.py} +0 -0
  30. /omlish/specs/jsonrpc/{marshal.py → _marshal.py} +0 -0
  31. /omlish/specs/jsonschema/{marshal.py → _marshal.py} +0 -0
  32. /omlish/specs/openapi/{marshal.py → _marshal.py} +0 -0
  33. /omlish/sql/queries/{marshal.py → _marshal.py} +0 -0
  34. /omlish/sql/tabledefs/{marshal.py → _marshal.py} +0 -0
  35. {omlish-0.0.0.dev416.dist-info → omlish-0.0.0.dev417.dist-info}/WHEEL +0 -0
  36. {omlish-0.0.0.dev416.dist-info → omlish-0.0.0.dev417.dist-info}/entry_points.txt +0 -0
  37. {omlish-0.0.0.dev416.dist-info → omlish-0.0.0.dev417.dist-info}/licenses/LICENSE +0 -0
  38. {omlish-0.0.0.dev416.dist-info → omlish-0.0.0.dev417.dist-info}/top_level.txt +0 -0
omlish/__about__.py CHANGED
@@ -1,5 +1,5 @@
1
- __version__ = '0.0.0.dev416'
2
- __revision__ = '2ad7f56508df7d9415fc8acee12cf5eb215afbf2'
1
+ __version__ = '0.0.0.dev417'
2
+ __revision__ = 'dad70cf0d439b40c7d3457efb0b5ca0d19ce1d99'
3
3
 
4
4
 
5
5
  #
@@ -37,6 +37,6 @@ from .sys import ( # noqa
37
37
  ##
38
38
 
39
39
 
40
- from .. import lang as _lang
40
+ from .. import marshal as _msh
41
41
 
42
- _lang.register_conditional_import('..marshal', '.marshal', __package__)
42
+ _msh.register_global_module_import('._marshal', __package__)
@@ -31,18 +31,6 @@ with _lang.auto_proxy_init(globals()) as _api_cap:
31
31
  replace,
32
32
  )
33
33
 
34
- from .impl.api import ( # noqa
35
- dataclass as xdataclass,
36
-
37
- make_dataclass as xmake_dataclass,
38
-
39
- field as xfield,
40
- )
41
-
42
- from .impl.concerns.replace import ( # noqa
43
- replace as xreplace,
44
- )
45
-
46
34
  from .tools.as_ import ( # noqa
47
35
  asdict,
48
36
  astuple,
@@ -51,19 +39,41 @@ with _lang.auto_proxy_init(globals()) as _api_cap:
51
39
  ##
52
40
  # additional interface
53
41
 
54
- from .impl.api import ( # noqa
42
+ from .impl.api.classes.decorator import ( # noqa
43
+ dataclass as xdataclass,
44
+ )
45
+
46
+ from .impl.api.classes.make import ( # noqa
47
+ make_dataclass as xmake_dataclass,
48
+ )
49
+
50
+ from .impl.api.classes.metadata import ( # noqa
55
51
  append_class_metadata,
56
52
  extra_class_params,
57
53
  init,
58
54
  metadata,
59
55
  validate,
56
+ )
60
57
 
58
+ from .impl.api.fields.metadata import ( # noqa
61
59
  extra_field_params,
62
60
  set_field_metadata,
63
61
  update_extra_field_params,
64
62
  with_extra_field_params,
65
63
  )
66
64
 
65
+ from .impl.api.fields.constructor import ( # noqa
66
+ field as xfield,
67
+ )
68
+
69
+ from .impl.concerns.replace import ( # noqa
70
+ replace as xreplace,
71
+ )
72
+
73
+ from .impl.configs import ( # noqa
74
+ init_package,
75
+ )
76
+
67
77
  from .errors import ( # noqa
68
78
  FieldFnValidationError,
69
79
  FieldTypeValidationError,
@@ -1,6 +1,6 @@
1
1
  """
2
2
  TODO:
3
- - Configurable? class Config crtc?
3
+ - Configurable? class Config crtp?
4
4
  - all config on specs? prob not desirable purity, prob want ~some~ global config if only defaults
5
5
  - ProcessorConfigSpecProviderFactoryThingy?
6
6
  - FIXME: for now these are processor ctor kwargs that are never overridden
@@ -1,3 +1,4 @@
1
+ # ruff: noqa: I001
1
2
  """
2
3
  TODO:
3
4
  - redacted
@@ -15,211 +16,231 @@ See:
15
16
  - https://github.com/Fatal1ty/mashumaro
16
17
  - https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/serializers.md#custom-serializers
17
18
  """
19
+ from .. import lang as _lang
18
20
 
19
21
 
20
- from .base.contexts import ( # noqa
21
- BaseContext,
22
- MarshalContext,
23
- UnmarshalContext,
24
- )
25
-
26
- from .base.errors import ( # noqa
27
- ForbiddenTypeError,
28
- MarshalError,
29
- UnhandledTypeError,
30
- )
31
-
32
- from .base.options import ( # noqa
33
- Option,
34
- )
35
-
36
- from .base.overrides import ( # noqa
37
- Override,
38
- ReflectOverride,
39
- )
40
-
41
- from .base.registries import ( # noqa
42
- Registry,
43
- )
44
-
45
- from .base.types import ( # noqa
46
- Marshaler,
47
- Unmarshaler,
48
-
49
- MarshalerMaker,
50
- UnmarshalerMaker,
51
-
52
- MarshalerFactory,
53
- UnmarshalerFactory,
54
-
55
- MarshalerFactory_,
56
- UnmarshalerFactory_,
57
- )
58
-
59
- from .base.values import ( # noqa
60
- Value,
61
- )
62
-
63
- from .composite.iterables import ( # noqa
64
- IterableMarshaler,
65
- IterableUnmarshaler,
66
- )
67
-
68
- from .composite.wrapped import ( # noqa
69
- WrappedMarshaler,
70
- WrappedUnmarshaler,
71
- )
72
-
73
- from .factories.simple import ( # noqa
74
- SimpleMarshalerFactory,
75
- SimpleUnmarshalerFactory,
76
- )
77
-
78
- from .factories.match import ( # noqa
79
- MarshalerFactoryMatchClass,
80
- UnmarshalerFactoryMatchClass,
81
- )
82
-
83
- from .factories.multi import ( # noqa
84
- MultiMarshalerFactory,
85
- MultiUnmarshalerFactory,
86
- )
87
-
88
- from .factories.typemap import ( # noqa
89
- TypeMapMarshalerFactory,
90
- TypeMapUnmarshalerFactory,
91
- )
92
-
93
- from .factories.typecache import ( # noqa
94
- TypeCacheMarshalerFactory,
95
- TypeCacheUnmarshalerFactory,
96
- )
97
-
98
- from .factories.func import ( # noqa
99
- FuncMarshaler,
100
- FuncUnmarshaler,
101
- )
102
-
103
- from .factories.recursive import ( # noqa
104
- RecursiveMarshalerFactory,
105
- RecursiveUnmarshalerFactory,
106
- )
107
-
108
- from .objects.dataclasses import ( # noqa
109
- AbstractDataclassFactory,
110
- DataclassMarshalerFactory,
111
- DataclassUnmarshalerFactory,
112
- get_dataclass_field_infos,
113
- get_dataclass_metadata,
114
- )
115
-
116
- from .objects.helpers import ( # noqa
117
- update_fields_metadata,
118
- update_object_metadata,
119
- with_field_metadata,
120
- )
121
-
122
- from .objects.marshal import ( # noqa
123
- ObjectMarshaler,
124
- SimpleObjectMarshalerFactory,
125
- )
126
-
127
- from .objects.metadata import ( # noqa
128
- FieldInfo,
129
- FieldInfos,
130
- FieldMetadata,
131
- FieldOptions,
132
- ObjectMetadata,
133
- ObjectSpecials,
134
- )
135
-
136
- from .objects.unmarshal import ( # noqa
137
- ObjectUnmarshaler,
138
- SimpleObjectUnmarshalerFactory,
139
- )
140
-
141
- from .polymorphism.marshal import ( # noqa
142
- PolymorphismMarshaler,
143
- PolymorphismMarshalerFactory,
144
- make_polymorphism_marshaler,
145
- )
146
-
147
- from .polymorphism.metadata import ( # noqa
148
- FieldTypeTagging,
149
- Impl,
150
- Impls,
151
- Polymorphism,
152
- TypeTagging,
153
- WrapperTypeTagging,
154
- polymorphism_from_impls,
155
- polymorphism_from_subclasses,
156
- )
157
-
158
- from .polymorphism.standard import ( # noqa
159
- standard_polymorphism_factories,
160
- )
161
-
162
- from .polymorphism.unions import ( # noqa
163
- PRIMITIVE_UNION_TYPES,
164
- PolymorphismUnionMarshalerFactory,
165
- PolymorphismUnionUnmarshalerFactory,
166
- PrimitiveUnionMarshaler,
167
- PrimitiveUnionMarshalerFactory,
168
- PrimitiveUnionUnmarshaler,
169
- PrimitiveUnionUnmarshalerFactory,
170
- )
171
-
172
- from .polymorphism.unmarshal import ( # noqa
173
- PolymorphismUnmarshaler,
174
- PolymorphismUnmarshalerFactory,
175
- make_polymorphism_unmarshaler,
176
- )
177
-
178
- from .singular.base64 import ( # noqa
179
- BASE64_MARSHALER_FACTORY,
180
- BASE64_UNMARSHALER_FACTORY,
181
- )
182
-
183
- from .singular.primitives import ( # noqa
184
- PRIMITIVE_TYPES,
185
- )
186
-
187
- from .trivial.forbidden import ( # noqa
188
- ForbiddenTypeMarshalerFactory,
189
- ForbiddenTypeUnmarshalerFactory,
190
- )
191
-
192
- from .trivial.nop import ( # noqa
193
- NOP_MARSHALER_UNMARSHALER,
194
- NopMarshalerUnmarshaler,
195
- )
196
-
197
- from .globals import ( # noqa
198
- global_registry,
199
- global_marshaler_factory,
200
- global_unmarshaler_factory,
201
- global_marshaling,
202
-
203
- marshal,
204
- unmarshal,
205
-
206
- register_global,
207
- )
208
-
209
- from .naming import ( # noqa
210
- Naming,
211
- translate_name,
212
- )
213
-
214
- from .standard import ( # noqa
215
- STANDARD_MARSHALER_FACTORIES,
216
- new_standard_marshaler_factory,
217
-
218
- STANDARD_UNMARSHALER_FACTORIES,
219
- new_standard_unmarshaler_factory,
220
-
221
- install_standard_factories,
222
- )
22
+ with _lang.auto_proxy_init(globals()) as _api_cap:
23
+ ##
24
+
25
+ from .base.configs import ( # noqa
26
+ Config,
27
+ ConfigRegistry,
28
+ )
29
+
30
+ from .base.contexts import ( # noqa
31
+ BaseContext,
32
+ MarshalContext,
33
+ UnmarshalContext,
34
+ )
35
+
36
+ from .base.errors import ( # noqa
37
+ ForbiddenTypeError,
38
+ MarshalError,
39
+ UnhandledTypeError,
40
+ )
41
+
42
+ from .base.options import ( # noqa
43
+ Option,
44
+ )
45
+
46
+ from .base.overrides import ( # noqa
47
+ Override,
48
+ ReflectOverride,
49
+ )
50
+
51
+ from .base.registries import ( # noqa
52
+ RegistrySealedError,
53
+ Registry,
54
+ )
55
+
56
+ from .base.types import ( # noqa
57
+ Marshaler,
58
+ Unmarshaler,
59
+
60
+ MarshalerMaker,
61
+ UnmarshalerMaker,
62
+
63
+ MarshalerFactory,
64
+ UnmarshalerFactory,
65
+
66
+ MarshalerFactory_,
67
+ UnmarshalerFactory_,
68
+ )
69
+
70
+ from .base.values import ( # noqa
71
+ Value,
72
+ )
73
+
74
+ from .composite.iterables import ( # noqa
75
+ IterableMarshaler,
76
+ IterableUnmarshaler,
77
+ )
78
+
79
+ from .composite.wrapped import ( # noqa
80
+ WrappedMarshaler,
81
+ WrappedUnmarshaler,
82
+ )
83
+
84
+ from .factories.simple import ( # noqa
85
+ SimpleMarshalerFactory,
86
+ SimpleUnmarshalerFactory,
87
+ )
88
+
89
+ from .factories.match import ( # noqa
90
+ MarshalerFactoryMatchClass,
91
+ UnmarshalerFactoryMatchClass,
92
+ )
93
+
94
+ from .factories.moduleimport.configs import ( # noqa
95
+ ModuleImport,
96
+ )
97
+
98
+ from .factories.moduleimport.factories import ( # noqa
99
+ ModuleImportingMarshalerFactory,
100
+ ModuleImportingUnmarshalerFactory,
101
+ )
102
+
103
+ from .factories.multi import ( # noqa
104
+ MultiMarshalerFactory,
105
+ MultiUnmarshalerFactory,
106
+ )
107
+
108
+ from .factories.typemap import ( # noqa
109
+ TypeMapMarshalerFactory,
110
+ TypeMapUnmarshalerFactory,
111
+ )
112
+
113
+ from .factories.typecache import ( # noqa
114
+ TypeCacheMarshalerFactory,
115
+ TypeCacheUnmarshalerFactory,
116
+ )
117
+
118
+ from .factories.func import ( # noqa
119
+ FuncMarshaler,
120
+ FuncUnmarshaler,
121
+ )
122
+
123
+ from .factories.recursive import ( # noqa
124
+ RecursiveMarshalerFactory,
125
+ RecursiveUnmarshalerFactory,
126
+ )
127
+
128
+ from .objects.dataclasses import ( # noqa
129
+ AbstractDataclassFactory,
130
+ DataclassMarshalerFactory,
131
+ DataclassUnmarshalerFactory,
132
+ get_dataclass_field_infos,
133
+ get_dataclass_metadata,
134
+ )
135
+
136
+ from .objects.helpers import ( # noqa
137
+ update_fields_metadata,
138
+ update_object_metadata,
139
+ with_field_metadata,
140
+ )
141
+
142
+ from .objects.marshal import ( # noqa
143
+ ObjectMarshaler,
144
+ SimpleObjectMarshalerFactory,
145
+ )
146
+
147
+ from .objects.metadata import ( # noqa
148
+ FieldInfo,
149
+ FieldInfos,
150
+ FieldMetadata,
151
+ FieldOptions,
152
+ ObjectMetadata,
153
+ ObjectSpecials,
154
+ )
155
+
156
+ from .objects.unmarshal import ( # noqa
157
+ ObjectUnmarshaler,
158
+ SimpleObjectUnmarshalerFactory,
159
+ )
160
+
161
+ from .polymorphism.marshal import ( # noqa
162
+ PolymorphismMarshaler,
163
+ PolymorphismMarshalerFactory,
164
+ make_polymorphism_marshaler,
165
+ )
166
+
167
+ from .polymorphism.metadata import ( # noqa
168
+ FieldTypeTagging,
169
+ Impl,
170
+ Impls,
171
+ Polymorphism,
172
+ TypeTagging,
173
+ WrapperTypeTagging,
174
+ polymorphism_from_impls,
175
+ polymorphism_from_subclasses,
176
+ )
177
+
178
+ from .polymorphism.standard import ( # noqa
179
+ standard_polymorphism_factories,
180
+ )
181
+
182
+ from .polymorphism.unions import ( # noqa
183
+ PRIMITIVE_UNION_TYPES,
184
+ PolymorphismUnionMarshalerFactory,
185
+ PolymorphismUnionUnmarshalerFactory,
186
+ PrimitiveUnionMarshaler,
187
+ PrimitiveUnionMarshalerFactory,
188
+ PrimitiveUnionUnmarshaler,
189
+ PrimitiveUnionUnmarshalerFactory,
190
+ )
191
+
192
+ from .polymorphism.unmarshal import ( # noqa
193
+ PolymorphismUnmarshaler,
194
+ PolymorphismUnmarshalerFactory,
195
+ make_polymorphism_unmarshaler,
196
+ )
197
+
198
+ from .singular.base64 import ( # noqa
199
+ BASE64_MARSHALER_FACTORY,
200
+ BASE64_UNMARSHALER_FACTORY,
201
+ )
202
+
203
+ from .singular.primitives import ( # noqa
204
+ PRIMITIVE_TYPES,
205
+ )
206
+
207
+ from .trivial.forbidden import ( # noqa
208
+ ForbiddenTypeMarshalerFactory,
209
+ ForbiddenTypeUnmarshalerFactory,
210
+ )
211
+
212
+ from .trivial.nop import ( # noqa
213
+ NOP_MARSHALER_UNMARSHALER,
214
+ NopMarshalerUnmarshaler,
215
+ )
216
+
217
+ from .globals import ( # noqa
218
+ global_config_registry,
219
+ global_marshaler_factory,
220
+ global_unmarshaler_factory,
221
+ global_marshaling,
222
+
223
+ marshal,
224
+ unmarshal,
225
+
226
+ register_global_config,
227
+ register_global_module_import,
228
+ )
229
+
230
+ from .naming import ( # noqa
231
+ Naming,
232
+ translate_name,
233
+ )
234
+
235
+ from .standard import ( # noqa
236
+ StandardFactories,
237
+ DEFAULT_STANDARD_FACTORIES,
238
+
239
+ new_standard_marshaler_factory,
240
+ new_standard_unmarshaler_factory,
241
+
242
+ install_standard_factories,
243
+ )
223
244
 
224
245
 
225
246
  ##
@@ -0,0 +1,18 @@
1
+ import typing as ta
2
+
3
+ from ... import lang
4
+ from .registries import Registry
5
+ from .registries import RegistryItem
6
+
7
+
8
+ ##
9
+
10
+
11
+ class Config(RegistryItem, lang.Abstract):
12
+ pass
13
+
14
+
15
+ ConfigRegistry: ta.TypeAlias = Registry[Config]
16
+
17
+
18
+ EMPTY_CONFIG_REGISTRY = ConfigRegistry().seal()
@@ -1,18 +1,19 @@
1
+ import dataclasses as dc
1
2
  import typing as ta
2
3
 
3
4
  from ... import check
4
5
  from ... import collections as col
5
- from ... import dataclasses as dc
6
6
  from ... import lang
7
7
  from ... import reflect as rfl
8
8
  from ...funcs import match as mfs
9
+ from .configs import EMPTY_CONFIG_REGISTRY
10
+ from .configs import ConfigRegistry
9
11
  from .errors import UnhandledTypeError
10
12
  from .options import Option
11
13
  from .overrides import ReflectOverride
12
14
 
13
15
 
14
16
  if ta.TYPE_CHECKING:
15
- from .registries import Registry
16
17
  from .types import Marshaler
17
18
  from .types import MarshalerFactory
18
19
  from .types import Unmarshaler
@@ -26,21 +27,21 @@ T = ta.TypeVar('T')
26
27
  ##
27
28
 
28
29
 
29
- @dc.dataclass(frozen=True)
30
+ @dc.dataclass(frozen=True, kw_only=True)
30
31
  class BaseContext(lang.Abstract):
31
- registry: 'Registry'
32
+ config_registry: ConfigRegistry = EMPTY_CONFIG_REGISTRY
32
33
  options: col.TypeMap[Option] = col.TypeMap()
33
34
 
34
35
  def _reflect(self, o: ta.Any) -> rfl.Type:
35
36
  def override(o):
36
- if (ovr := self.registry.get_of(o, ReflectOverride)):
37
+ if (ovr := self.config_registry.get_of(o, ReflectOverride)):
37
38
  return ovr[-1].rty
38
39
  return None
39
40
 
40
41
  return rfl.Reflector(override=override).type(o)
41
42
 
42
43
 
43
- @dc.dataclass(frozen=True)
44
+ @dc.dataclass(frozen=True, kw_only=True)
44
45
  class MarshalContext(BaseContext, lang.Final):
45
46
  factory: ta.Optional['MarshalerFactory'] = None
46
47
 
@@ -55,7 +56,7 @@ class MarshalContext(BaseContext, lang.Final):
55
56
  return self.make(ty if ty is not None else type(obj)).marshal(self, obj)
56
57
 
57
58
 
58
- @dc.dataclass(frozen=True)
59
+ @dc.dataclass(frozen=True, kw_only=True)
59
60
  class UnmarshalContext(BaseContext, lang.Final):
60
61
  factory: ta.Optional['UnmarshalerFactory'] = None
61
62
 
@@ -1,9 +1,10 @@
1
+ import dataclasses as dc
1
2
  import typing as ta
2
3
 
3
- from ... import dataclasses as dc
4
+ from ... import check
4
5
  from ... import lang
5
6
  from ... import reflect as rfl
6
- from .registries import RegistryItem
7
+ from .configs import Config
7
8
 
8
9
 
9
10
  if ta.TYPE_CHECKING:
@@ -21,14 +22,18 @@ else:
21
22
 
22
23
 
23
24
  @dc.dataclass(frozen=True, kw_only=True)
24
- class Override(RegistryItem, lang.Final):
25
- marshaler: ta.Optional['Marshaler'] = dc.xfield(None, validate=lambda v: isinstance(v, (_types.Marshaler, type(None)))) # noqa
25
+ class Override(Config, lang.Final):
26
+ marshaler: ta.Optional['Marshaler'] = None
26
27
  marshaler_factory: ta.Optional['MarshalerFactory'] = None
27
28
 
28
- unmarshaler: ta.Optional['Unmarshaler'] = dc.xfield(None, validate=lambda v: isinstance(v, (_types.Unmarshaler, type(None)))) # noqa
29
+ unmarshaler: ta.Optional['Unmarshaler'] = None
29
30
  unmarshaler_factory: ta.Optional['UnmarshalerFactory'] = None
30
31
 
32
+ def __post_init__(self) -> None:
33
+ check.isinstance(self.marshaler, (_types.Marshaler, None))
34
+ check.isinstance(self.unmarshaler, (_types.Unmarshaler, None))
35
+
31
36
 
32
37
  @dc.dataclass(frozen=True)
33
- class ReflectOverride(RegistryItem, lang.Final):
38
+ class ReflectOverride(Config, lang.Final):
34
39
  rty: rfl.Type