omlish 0.0.0.dev454__py3-none-any.whl → 0.0.0.dev455__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/lang/functions.py +2 -2
- omlish/marshal/__init__.py +4 -0
- omlish/marshal/base/contexts.py +29 -13
- omlish/marshal/base/funcs.py +4 -12
- omlish/marshal/base/options.py +8 -0
- omlish/marshal/base/types.py +25 -11
- omlish/marshal/composite/iterables.py +10 -8
- omlish/marshal/composite/literals.py +6 -4
- omlish/marshal/composite/mappings.py +10 -8
- omlish/marshal/composite/maybes.py +10 -8
- omlish/marshal/composite/newtypes.py +6 -6
- omlish/marshal/composite/optionals.py +6 -4
- omlish/marshal/composite/special.py +6 -6
- omlish/marshal/composite/unions/literals.py +6 -4
- omlish/marshal/composite/unions/primitives.py +6 -4
- omlish/marshal/factories/invalidate.py +4 -4
- omlish/marshal/factories/method.py +4 -6
- omlish/marshal/factories/moduleimport/factories.py +4 -4
- omlish/marshal/factories/multi.py +4 -4
- omlish/marshal/factories/recursive.py +4 -2
- omlish/marshal/factories/typecache.py +4 -9
- omlish/marshal/factories/typemap.py +4 -4
- omlish/marshal/objects/dataclasses.py +30 -16
- omlish/marshal/objects/marshal.py +4 -3
- omlish/marshal/objects/namedtuples.py +6 -6
- omlish/marshal/objects/unmarshal.py +4 -3
- omlish/marshal/polymorphism/marshal.py +4 -3
- omlish/marshal/polymorphism/unions.py +7 -7
- omlish/marshal/polymorphism/unmarshal.py +4 -3
- omlish/marshal/singular/enums.py +4 -2
- omlish/marshal/trivial/any.py +1 -1
- omlish/marshal/trivial/forbidden.py +4 -4
- omlish/specs/jsonrpc/_marshal.py +4 -4
- omlish/specs/openapi/_marshal.py +16 -10
- omlish/typedvalues/marshal.py +14 -14
- {omlish-0.0.0.dev454.dist-info → omlish-0.0.0.dev455.dist-info}/METADATA +1 -1
- {omlish-0.0.0.dev454.dist-info → omlish-0.0.0.dev455.dist-info}/RECORD +42 -43
- omlish/funcs/match.py +0 -229
- {omlish-0.0.0.dev454.dist-info → omlish-0.0.0.dev455.dist-info}/WHEEL +0 -0
- {omlish-0.0.0.dev454.dist-info → omlish-0.0.0.dev455.dist-info}/entry_points.txt +0 -0
- {omlish-0.0.0.dev454.dist-info → omlish-0.0.0.dev455.dist-info}/licenses/LICENSE +0 -0
- {omlish-0.0.0.dev454.dist-info → omlish-0.0.0.dev455.dist-info}/top_level.txt +0 -0
omlish/typedvalues/marshal.py
CHANGED
@@ -26,7 +26,7 @@ def _build_typed_value_poly(rty: rfl.Type) -> msh.Polymorphism:
|
|
26
26
|
|
27
27
|
class TypedValueMarshalerFactory(msh.MarshalerFactoryMethodClass):
|
28
28
|
@msh.MarshalerFactoryMethodClass.make_marshaler.register
|
29
|
-
def _make_scalar(self, ctx: msh.
|
29
|
+
def _make_scalar(self, ctx: msh.MarshalFactoryContext, rty: rfl.Type) -> ta.Callable[[], msh.Marshaler] | None:
|
30
30
|
if not (
|
31
31
|
isinstance(rty, type) and
|
32
32
|
issubclass(rty, ScalarTypedValue) and
|
@@ -37,13 +37,13 @@ class TypedValueMarshalerFactory(msh.MarshalerFactoryMethodClass):
|
|
37
37
|
def inner() -> msh.Marshaler:
|
38
38
|
dc_rfl = dc.reflect(check.isinstance(rty, type))
|
39
39
|
v_rty = check.single(dc_rfl.fields_inspection.generic_replaced_field_annotations.values())
|
40
|
-
v_m = ctx.
|
40
|
+
v_m = ctx.make_marshaler(v_rty)
|
41
41
|
return msh.WrappedMarshaler(lambda _, o: o.v, v_m)
|
42
42
|
|
43
43
|
return inner
|
44
44
|
|
45
45
|
@msh.MarshalerFactoryMethodClass.make_marshaler.register
|
46
|
-
def _make_abstract(self, ctx: msh.
|
46
|
+
def _make_abstract(self, ctx: msh.MarshalFactoryContext, rty: rfl.Type) -> ta.Callable[[], msh.Marshaler] | None:
|
47
47
|
if not (
|
48
48
|
isinstance(rty, type) and
|
49
49
|
issubclass(rty, TypedValue) and
|
@@ -60,7 +60,7 @@ class TypedValueMarshalerFactory(msh.MarshalerFactoryMethodClass):
|
|
60
60
|
|
61
61
|
class TypedValueUnmarshalerFactory(msh.UnmarshalerFactoryMethodClass):
|
62
62
|
@msh.UnmarshalerFactoryMethodClass.make_unmarshaler.register
|
63
|
-
def _make_scalar(self, ctx: msh.
|
63
|
+
def _make_scalar(self, ctx: msh.UnmarshalFactoryContext, rty: rfl.Type) -> ta.Callable[[], msh.Unmarshaler] | None:
|
64
64
|
if not (
|
65
65
|
isinstance(rty, type) and
|
66
66
|
issubclass(rty, ScalarTypedValue) and
|
@@ -71,13 +71,13 @@ class TypedValueUnmarshalerFactory(msh.UnmarshalerFactoryMethodClass):
|
|
71
71
|
def inner() -> msh.Unmarshaler:
|
72
72
|
dc_rfl = dc.reflect(rty)
|
73
73
|
v_rty = check.single(dc_rfl.fields_inspection.generic_replaced_field_annotations.values())
|
74
|
-
v_u = ctx.
|
74
|
+
v_u = ctx.make_unmarshaler(v_rty)
|
75
75
|
return msh.WrappedUnmarshaler(lambda _, v: rty(v), v_u)
|
76
76
|
|
77
77
|
return inner
|
78
78
|
|
79
79
|
@msh.UnmarshalerFactoryMethodClass.make_unmarshaler.register
|
80
|
-
def _make_abstract(self, ctx: msh.
|
80
|
+
def _make_abstract(self, ctx: msh.UnmarshalFactoryContext, rty: rfl.Type) -> ta.Callable[[], msh.Unmarshaler] | None: # noqa
|
81
81
|
if not (
|
82
82
|
isinstance(rty, type) and
|
83
83
|
issubclass(rty, TypedValue) and
|
@@ -117,7 +117,7 @@ def _build_typed_values_impls(rty: rfl.Type) -> msh.Impls:
|
|
117
117
|
#
|
118
118
|
|
119
119
|
|
120
|
-
def build_typed_values_marshaler(ctx: msh.
|
120
|
+
def build_typed_values_marshaler(ctx: msh.MarshalFactoryContext, rty: rfl.Type) -> msh.Marshaler:
|
121
121
|
tv_m = msh.make_polymorphism_marshaler(
|
122
122
|
msh.Impls(_build_typed_values_impls(rty)),
|
123
123
|
msh.WrapperTypeTagging(),
|
@@ -128,22 +128,22 @@ def build_typed_values_marshaler(ctx: msh.MarshalContext, rty: rfl.Type) -> msh.
|
|
128
128
|
|
129
129
|
class TypedValuesMarshalerFactory(msh.MarshalerFactoryMethodClass):
|
130
130
|
@msh.MarshalerFactoryMethodClass.make_marshaler.register
|
131
|
-
def _make_generic(self, ctx: msh.
|
131
|
+
def _make_generic(self, ctx: msh.MarshalFactoryContext, rty: rfl.Type) -> ta.Callable[[], msh.Marshaler] | None:
|
132
132
|
if not (isinstance(rty, rfl.Generic) and rty.cls is TypedValues):
|
133
133
|
return None
|
134
134
|
return lambda: build_typed_values_marshaler(ctx, rty)
|
135
135
|
|
136
136
|
@msh.MarshalerFactoryMethodClass.make_marshaler.register
|
137
|
-
def _make_concrete(self, ctx: msh.
|
137
|
+
def _make_concrete(self, ctx: msh.MarshalFactoryContext, rty: rfl.Type) -> ta.Callable[[], msh.Marshaler] | None:
|
138
138
|
if rty is not TypedValues:
|
139
139
|
return None
|
140
|
-
return lambda: lang.raise_(NotImplementedError
|
140
|
+
return lambda: lang.raise_(NotImplementedError)
|
141
141
|
|
142
142
|
|
143
143
|
#
|
144
144
|
|
145
145
|
|
146
|
-
def build_typed_values_unmarshaler(ctx: msh.
|
146
|
+
def build_typed_values_unmarshaler(ctx: msh.UnmarshalFactoryContext, rty: rfl.Type) -> msh.Unmarshaler:
|
147
147
|
tv_u = msh.make_polymorphism_unmarshaler(
|
148
148
|
msh.Impls(_build_typed_values_impls(rty)),
|
149
149
|
msh.WrapperTypeTagging(),
|
@@ -154,16 +154,16 @@ def build_typed_values_unmarshaler(ctx: msh.UnmarshalContext, rty: rfl.Type) ->
|
|
154
154
|
|
155
155
|
class TypedValuesUnmarshalerFactory(msh.UnmarshalerFactoryMethodClass):
|
156
156
|
@msh.UnmarshalerFactoryMethodClass.make_unmarshaler.register
|
157
|
-
def _build(self, ctx: msh.
|
157
|
+
def _build(self, ctx: msh.UnmarshalFactoryContext, rty: rfl.Type) -> ta.Callable[[], msh.Unmarshaler] | None:
|
158
158
|
if not (isinstance(rty, rfl.Generic) and rty.cls is TypedValues):
|
159
159
|
return None
|
160
160
|
return lambda: build_typed_values_unmarshaler(ctx, rty)
|
161
161
|
|
162
162
|
@msh.UnmarshalerFactoryMethodClass.make_unmarshaler.register
|
163
|
-
def _build_concrete(self, ctx: msh.
|
163
|
+
def _build_concrete(self, ctx: msh.UnmarshalFactoryContext, rty: rfl.Type) -> ta.Callable[[], msh.Unmarshaler] | None: # noqa
|
164
164
|
if rty is not TypedValues:
|
165
165
|
return None
|
166
|
-
return lambda: lang.raise_(NotImplementedError
|
166
|
+
return lambda: lang.raise_(NotImplementedError)
|
167
167
|
|
168
168
|
|
169
169
|
##
|
@@ -1,5 +1,5 @@
|
|
1
1
|
omlish/.omlish-manifests.json,sha256=FLw7xkPiSXuImZgqSP8BwrEib2R1doSzUPLUkc-QUIA,8410
|
2
|
-
omlish/__about__.py,sha256=
|
2
|
+
omlish/__about__.py,sha256=wqpHLPUSVDC5K6I55LXDB8pGFgSMoTsN383tFd6mTHc,3613
|
3
3
|
omlish/__init__.py,sha256=SsyiITTuK0v74XpKV8dqNaCmjOlan1JZKrHQv5rWKPA,253
|
4
4
|
omlish/c3.py,sha256=ZNIMl1kwg3qdei4DiUrJPQe5M81S1e76N-GuNSwLBAE,8683
|
5
5
|
omlish/cached.py,sha256=MLap_p0rdGoDIMVhXVHm1tsbcWobJF0OanoodV03Ju8,542
|
@@ -289,7 +289,6 @@ omlish/funcs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
289
289
|
omlish/funcs/builders.py,sha256=ZSBQS2xqriXp5x0t074EEZvuTmMp4Yue2YGBoTLAioo,4044
|
290
290
|
omlish/funcs/genmachine.py,sha256=BOxO1OTjxZ7ewv_WpqYkY8bwlGQIJIjwjvYMflEFa_M,2571
|
291
291
|
omlish/funcs/guard.py,sha256=OfxDQRJfnRmVrXOPK2QuUtJ3MN3dxMA_q0gIb7C8m2s,5958
|
292
|
-
omlish/funcs/match.py,sha256=cBtG7kdpWdxvHwlte5CWlBxXSoJSV48joV4bwJJC3pk,6352
|
293
292
|
omlish/funcs/pairs.py,sha256=XhYTJdqooAJKeoGZmEaiKYeFRq5-Dj2_y92IdBl_C20,4371
|
294
293
|
omlish/funcs/pipes.py,sha256=E1dQZMBmgT2qautG1vEqy5v3QBsO2Nzryv33j4YAngA,2520
|
295
294
|
omlish/graphs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -423,7 +422,7 @@ omlish/lang/datetimes.py,sha256=01tg21QOx-PWDlm-CSFTalym3vpqF0EKzeinmtcVNoU,379
|
|
423
422
|
omlish/lang/descriptors.py,sha256=sVJ1Pr4ihp26Tu9UCvDSyfSf-DhBnFGnbpYIFF32c7g,6877
|
424
423
|
omlish/lang/enums.py,sha256=F9tflHfaAoV2MpyuhZzpfX9-H55M3zNa9hCszsngEo8,111
|
425
424
|
omlish/lang/errors.py,sha256=shcS-NCnEUudF8qC_SmO2TQyjivKlS4TDjaz_faqQ0c,44
|
426
|
-
omlish/lang/functions.py,sha256=
|
425
|
+
omlish/lang/functions.py,sha256=tZL7Yi5Oy34lvzP6HhWmV5q1eg5-mk3FrWEjsmhKRhY,5707
|
427
426
|
omlish/lang/generators.py,sha256=nJiSmDpsfPiypGzJ8qlOO7-BUnCsrAeDow9mhtGgBio,5196
|
428
427
|
omlish/lang/iterables.py,sha256=5CJNkLyY4Oq43UkiM7KCgV9F6jzrlr9SLiuNx3DAvm8,3608
|
429
428
|
omlish/lang/lazyglobals.py,sha256=YfPtWgNEa0ULtbIiQIQ12pbafUwd6INQRw_PFcAabjo,2282
|
@@ -528,65 +527,65 @@ omlish/manifests/globals.py,sha256=kVqQ-fT4kc7xWzLHoI731GviitFPv2v2yqw-p7t7Exs,2
|
|
528
527
|
omlish/manifests/loading.py,sha256=s6KnhdFQCsI2i0Rus1sMU0so2v8dUBnk59BJkSnxGt8,17514
|
529
528
|
omlish/manifests/static.py,sha256=9BaPBLkuzxHmg5A-5k9BjjBFINCdmFOIu06dMFgCfz4,497
|
530
529
|
omlish/manifests/types.py,sha256=NeOGuIVrcbqjCDbQ3MnCxxHAgHnw0CkWJsBzo230PWE,453
|
531
|
-
omlish/marshal/__init__.py,sha256=
|
530
|
+
omlish/marshal/__init__.py,sha256=RC4AnLMHRFF51-Be1W9Lefcv1g9L89tM7UiPM2tP1Xg,6530
|
532
531
|
omlish/marshal/globals.py,sha256=Q6G18hcUwUDDNnpyRPnR5Tn_XZpZCSIEXo09nYSOaNU,2236
|
533
532
|
omlish/marshal/naming.py,sha256=Mk5YrbES836_KflNNRoc5Ajd96iMYLQIMERKx1KpT4g,865
|
534
533
|
omlish/marshal/standard.py,sha256=8Qy5L3qMHO-V_fu78tM62wMcGpF0kgrFrxn06IRbFXQ,6906
|
535
534
|
omlish/marshal/base/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
536
535
|
omlish/marshal/base/configs.py,sha256=y_JRghQgu8mJjPspSZcJQLhjevEuJE2kyxCdu3wGKvo,271
|
537
|
-
omlish/marshal/base/contexts.py,sha256=
|
536
|
+
omlish/marshal/base/contexts.py,sha256=5dsfjEgKn9Nt-yuzG8ZyJUc6kIQfXHuGoWGo5efIqf4,2683
|
538
537
|
omlish/marshal/base/errors.py,sha256=jmN3vl_U_hB6L0wAvuO7ORG27vXF7KEUk-1TxxK2mYA,308
|
539
|
-
omlish/marshal/base/funcs.py,sha256=
|
540
|
-
omlish/marshal/base/options.py,sha256=
|
538
|
+
omlish/marshal/base/funcs.py,sha256=UIlVHZ_vARJ8MNKsR6n5x5GnFQQ7Z0MaIZKYxHMsZaQ,1470
|
539
|
+
omlish/marshal/base/options.py,sha256=Yuk4VDeKw9N26wSHda9_mMWj1hdgQTnenJ6hPYfrFts,235
|
541
540
|
omlish/marshal/base/overrides.py,sha256=543hP4_y2JRThUOamCE0dPfgucbepVV8e_YF-_PJk6U,993
|
542
541
|
omlish/marshal/base/registries.py,sha256=NRH5X4nE_aF7vcTi4_5qqQpYbYru2Ud6aD0eKfuJ_Ws,5903
|
543
|
-
omlish/marshal/base/types.py,sha256=
|
542
|
+
omlish/marshal/base/types.py,sha256=DtyY7W-kzU0oXtQytrBKDIPzfWnh2OJW7oMHSNB-TrA,3593
|
544
543
|
omlish/marshal/base/values.py,sha256=QF6OateG5kjRPHYza08wscThhg20oryf-aVQrxjfkC0,212
|
545
544
|
omlish/marshal/composite/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
546
|
-
omlish/marshal/composite/iterables.py,sha256=
|
547
|
-
omlish/marshal/composite/literals.py,sha256=
|
548
|
-
omlish/marshal/composite/mappings.py,sha256=
|
549
|
-
omlish/marshal/composite/maybes.py,sha256=
|
550
|
-
omlish/marshal/composite/newtypes.py,sha256=
|
551
|
-
omlish/marshal/composite/optionals.py,sha256=
|
552
|
-
omlish/marshal/composite/special.py,sha256=
|
545
|
+
omlish/marshal/composite/iterables.py,sha256=zswx4nmYPWNu1Ht7myjNwy_q5a4Sq-hH7Ky7rIYBqv4,3148
|
546
|
+
omlish/marshal/composite/literals.py,sha256=KrrvPuzGZGhlcY64Nt1_kNrCRWu671JIdTkIaNQGOPk,1854
|
547
|
+
omlish/marshal/composite/mappings.py,sha256=W2RKCa-7JEOvimiCR23sexV84hlFh7j5aNVQ4p9uMeQ,3319
|
548
|
+
omlish/marshal/composite/maybes.py,sha256=JCT1ZDd-x__Y2EM8BmNANVIC2k2eNxTN2MtPf7O-K0g,2705
|
549
|
+
omlish/marshal/composite/newtypes.py,sha256=t0YL76AIYk9jCwz6g6oZburVm2mZ0_m89XTfX1T022k,973
|
550
|
+
omlish/marshal/composite/optionals.py,sha256=MfHJ6w43OzWJKcO94JOZX1b6HTCvexys5BEEoYtJrGg,1708
|
551
|
+
omlish/marshal/composite/special.py,sha256=34I0IsUrZjtTrk0qgPAcvyT-lkHNCkvAIkjgl6ulYhw,1364
|
553
552
|
omlish/marshal/composite/wrapped.py,sha256=xC8k21wJOpSkpAn7794hBTPBRw-HPC9sOF3WRlUh_BA,785
|
554
553
|
omlish/marshal/composite/unions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
555
|
-
omlish/marshal/composite/unions/literals.py,sha256=
|
556
|
-
omlish/marshal/composite/unions/primitives.py,sha256=
|
554
|
+
omlish/marshal/composite/unions/literals.py,sha256=__8oTce5sNbM-fDfQ8UhllQOdzu4fmvEIkYWcS6qr2U,2810
|
555
|
+
omlish/marshal/composite/unions/primitives.py,sha256=xP38hnQXkF0t2xaKyHilhqpAeLwCMl9K6a6ekI_VtW0,2961
|
557
556
|
omlish/marshal/factories/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
558
|
-
omlish/marshal/factories/invalidate.py,sha256=
|
559
|
-
omlish/marshal/factories/method.py,sha256=
|
560
|
-
omlish/marshal/factories/multi.py,sha256=
|
561
|
-
omlish/marshal/factories/recursive.py,sha256=
|
562
|
-
omlish/marshal/factories/typecache.py,sha256=
|
563
|
-
omlish/marshal/factories/typemap.py,sha256
|
557
|
+
omlish/marshal/factories/invalidate.py,sha256=qoI5BI6tsTmrZc1ahz5c_YjMpHKzlc0Fo-n9lCJbUeQ,1987
|
558
|
+
omlish/marshal/factories/method.py,sha256=Uk92_AGnEdH5P4CrebuFWPhONDk4ydteW7hSRfI6ZtI,884
|
559
|
+
omlish/marshal/factories/multi.py,sha256=IbsUbzPiIho55CzZtPQk2ub9eAdvwoFy2Q8XliBaK5o,1279
|
560
|
+
omlish/marshal/factories/recursive.py,sha256=spoPD0w7kyq3tiXFxlNSh2SYCFrPNzM6zPm3234sEHI,2984
|
561
|
+
omlish/marshal/factories/typecache.py,sha256=8DwgyAKEA7scdhSxndPbC3NltkFViM_C4nP8xViSUKc,1598
|
562
|
+
omlish/marshal/factories/typemap.py,sha256=-Dl3Z-MvssSP_oPj3i32_72A9nSHNM1HtpTuys7tDHg,1995
|
564
563
|
omlish/marshal/factories/moduleimport/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
565
564
|
omlish/marshal/factories/moduleimport/configs.py,sha256=8g6FSPmyo0IOYSWYp5kqfJACZxL9SvzlHzrSzucNZyg,538
|
566
|
-
omlish/marshal/factories/moduleimport/factories.py,sha256=
|
565
|
+
omlish/marshal/factories/moduleimport/factories.py,sha256=MEyTruCxPvcLvIZs0Wwa-5_8wW59Nc-Mv8U1XI8GAAc,2404
|
567
566
|
omlish/marshal/objects/__init__.py,sha256=F4wej8L_tedC8ETYxAnmKfdPR9TjsqIus9Z3nZofYuc,182
|
568
|
-
omlish/marshal/objects/dataclasses.py,sha256=
|
567
|
+
omlish/marshal/objects/dataclasses.py,sha256=wQ6s7z6zuoPJfUN4TqQSeDjxj0MzUJyH4vwYORnrxUY,10431
|
569
568
|
omlish/marshal/objects/helpers.py,sha256=hj5I1pILt3QFSVkYJNrSO3wiCaalAopEYWPL17Ip4zs,1102
|
570
|
-
omlish/marshal/objects/marshal.py,sha256=
|
569
|
+
omlish/marshal/objects/marshal.py,sha256=KhS2ZTW1X5N-mK1qYlb-qIpEqU5ZEp8TLTXLhttEoMU,2818
|
571
570
|
omlish/marshal/objects/metadata.py,sha256=maGqyQl0GE9xWK17DQjXxhZWRh3nRwH4fgklrA8XVQI,3392
|
572
|
-
omlish/marshal/objects/namedtuples.py,sha256=
|
573
|
-
omlish/marshal/objects/unmarshal.py,sha256=
|
571
|
+
omlish/marshal/objects/namedtuples.py,sha256=YohP58NraqI9SZzMtLk6s0CrWVow417fxjA2Aqq-7vA,3168
|
572
|
+
omlish/marshal/objects/unmarshal.py,sha256=91wxKiMsPaJHYYUfImGkEcsg4cycIEw8_xGsZ6QrrZQ,3812
|
574
573
|
omlish/marshal/polymorphism/__init__.py,sha256=e2UTrSL0qp7w_1vkdxDWd7sXlWhep2KPV49-BB64ma8,130
|
575
|
-
omlish/marshal/polymorphism/marshal.py,sha256=
|
574
|
+
omlish/marshal/polymorphism/marshal.py,sha256=Xsos29MvL7umwgO3ReNu7KMPYGyJ-qrgFIUJGYdmT70,2295
|
576
575
|
omlish/marshal/polymorphism/metadata.py,sha256=s5lNTzvP487niVorDUy6RFeTB7hde89ENgm-7I_MQg0,3622
|
577
576
|
omlish/marshal/polymorphism/standard.py,sha256=sfxKVjFG8tUam_U75_rFMY2-JSWw_l1_HBg2MrXjQHE,1096
|
578
|
-
omlish/marshal/polymorphism/unions.py,sha256=
|
579
|
-
omlish/marshal/polymorphism/unmarshal.py,sha256=
|
577
|
+
omlish/marshal/polymorphism/unions.py,sha256=JyXhQOV9bHbCfuHq94QU8TnHROS_eRbXycfwBvG0mzw,2141
|
578
|
+
omlish/marshal/polymorphism/unmarshal.py,sha256=v_bZe6jDH5Y04csfQe76hDTY25H-kEzTSzQZjhjsZrQ,2512
|
580
579
|
omlish/marshal/singular/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
581
580
|
omlish/marshal/singular/base64.py,sha256=OZ3Ydwy64S0M-xlktYy5MagzyzTOVYayUXblq8ZK-AE,1164
|
582
581
|
omlish/marshal/singular/datetimes.py,sha256=nzOf8LRwAB08X80N_NmWuE3rOrYG80ZgIaZO3549WnE,3784
|
583
|
-
omlish/marshal/singular/enums.py,sha256=
|
582
|
+
omlish/marshal/singular/enums.py,sha256=RzP9R9NhPfo-Yq-yF-Awg-_dnnJoqAeAlIYGZoDKz4A,1493
|
584
583
|
omlish/marshal/singular/numbers.py,sha256=32_lSiaQc796u0WsPyiYORiJoaI5qh2IZxiIfF8n360,1746
|
585
584
|
omlish/marshal/singular/primitives.py,sha256=T1mRNMin7OOBjsBkAh1xVbHa-VBmtMfL55mhCfiruIg,1360
|
586
585
|
omlish/marshal/singular/uuids.py,sha256=J6Swxzm0rFvAMCmErJb4WpSPmnQyts7qOqy43Y1BugI,984
|
587
586
|
omlish/marshal/trivial/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
588
|
-
omlish/marshal/trivial/any.py,sha256=
|
589
|
-
omlish/marshal/trivial/forbidden.py,sha256=
|
587
|
+
omlish/marshal/trivial/any.py,sha256=9SmivhlphEn8kdUNsu7qRhQITrcHfkT6JmipAtMzb1k,886
|
588
|
+
omlish/marshal/trivial/forbidden.py,sha256=_-tSgy2UpDKHERsRm8Alg1FvU7vg4YrwvKB-JI2CrRg,1222
|
590
589
|
omlish/marshal/trivial/nop.py,sha256=PDXT0B9RR-ghG6ExuK9BH2J-nHEnoTYGNdVaNAyRzSk,506
|
591
590
|
omlish/math/__init__.py,sha256=bcdEEM3l4YNPJvTY_gD-7ARa5HEBNFTfvkVDTTzaNOQ,1531
|
592
591
|
omlish/math/bits.py,sha256=pcTuWxNXXfG-CtTITNNbW3YConAkCeU8PLNcglCc43E,533
|
@@ -664,7 +663,7 @@ omlish/specs/jmespath/parser.py,sha256=uNk9_xQ9cZJC1h5naoH1HMbCs4B0WhV2jN5AvhdKT
|
|
664
663
|
omlish/specs/jmespath/scope.py,sha256=gsVjmAVF0b7s2SevWb0rBbURayiMSIuXfzO4v1ONIrY,1595
|
665
664
|
omlish/specs/jmespath/visitor.py,sha256=6OCi7oa4IsGW5fCqAeFuXYEwn-aLKuMrNMFtQKSpJWo,16951
|
666
665
|
omlish/specs/jsonrpc/__init__.py,sha256=u2kcJeo6YWEvFYf7OqDNKThszGLSmXYFNJpqXmXgm1M,504
|
667
|
-
omlish/specs/jsonrpc/_marshal.py,sha256=
|
666
|
+
omlish/specs/jsonrpc/_marshal.py,sha256=RQZC1KEmI4tbPieRZ2rAcn0QDN_a6mhSVirdB57XewA,2102
|
668
667
|
omlish/specs/jsonrpc/conns.py,sha256=zvWnBHuSoGnvbGVk72Usp4IFsLscrzPozqR2hmFjnDI,7029
|
669
668
|
omlish/specs/jsonrpc/errors.py,sha256=WxEU7k1TqeZAo_H6eU0LcrXSd-Gi_3fTvtxjXZ9qKww,712
|
670
669
|
omlish/specs/jsonrpc/types.py,sha256=Se9ecG-_k-kY_Qlt9QD2t3y26oY4sXTcskp6XZfVans,3054
|
@@ -694,7 +693,7 @@ omlish/specs/jsonschema/schemas/draft202012/vocabularies/meta-data.json,sha256=j
|
|
694
693
|
omlish/specs/jsonschema/schemas/draft202012/vocabularies/unevaluated.json,sha256=Lb-8tzmUtnCwl2SSre4f_7RsIWgnhNL1pMpWH54tDLQ,506
|
695
694
|
omlish/specs/jsonschema/schemas/draft202012/vocabularies/validation.json,sha256=cBCjHlQfMtK-ch4t40jfdcmzaHaj7TBId_wKvaHTelg,2834
|
696
695
|
omlish/specs/openapi/__init__.py,sha256=KS7OHPBlXwBeTvmsUQy0VMzKYdz2RyH3qLF3bU0NXUw,147
|
697
|
-
omlish/specs/openapi/_marshal.py,sha256=
|
696
|
+
omlish/specs/openapi/_marshal.py,sha256=DpI0ibKPIpOA1AsxrCawPHaJfPmGmexnqUjtLb64UbI,4712
|
698
697
|
omlish/specs/openapi/openapi.py,sha256=6KGY_d8HOyG7ssHIWM40MCXgIMzNLiLKHYNggTSpAYM,12027
|
699
698
|
omlish/sql/__init__.py,sha256=JjgIiP2YfiHHIANP7qgkJUG0IMIRzzvKntyhdDKeNdY,384
|
700
699
|
omlish/sql/abc.py,sha256=3hrCjB4jnPVMef_YXClCblzYUZ9l9yaxJJdd5_Nu9GM,4043
|
@@ -822,13 +821,13 @@ omlish/typedvalues/collection.py,sha256=CK4Vk9kJqAt2V8o6I4zGyv2u9DKov12uSvsGdqEd
|
|
822
821
|
omlish/typedvalues/consumer.py,sha256=lDOE-O_sgGbOvbcBg2g5ZRaV2WixnuEYxFsJBaj18oU,4690
|
823
822
|
omlish/typedvalues/generic.py,sha256=ft-x4X3k1oFirtYnDfsvrI3ZQikWM8lGLrvrOEbcGq0,742
|
824
823
|
omlish/typedvalues/holder.py,sha256=vu-umn-h1nvUqmtV5T9ZfQ_OoOYsERu8PhI2N48Ryns,1133
|
825
|
-
omlish/typedvalues/marshal.py,sha256=
|
824
|
+
omlish/typedvalues/marshal.py,sha256=2xqX6JllhtGpmeYkU7C-qzgU__0x-vd6CzYbAsocQlc,6058
|
826
825
|
omlish/typedvalues/of_.py,sha256=UXkxSj504WI2UrFlqdZJbu2hyDwBhL7XVrc2qdR02GQ,1309
|
827
826
|
omlish/typedvalues/reflect.py,sha256=PAvKW6T4cW7u--iX80w3HWwZUS3SmIZ2_lQjT65uAyk,1026
|
828
827
|
omlish/typedvalues/values.py,sha256=ym46I-q2QJ_6l4UlERqv3yj87R-kp8nCKMRph0xQ3UA,1307
|
829
|
-
omlish-0.0.0.
|
830
|
-
omlish-0.0.0.
|
831
|
-
omlish-0.0.0.
|
832
|
-
omlish-0.0.0.
|
833
|
-
omlish-0.0.0.
|
834
|
-
omlish-0.0.0.
|
828
|
+
omlish-0.0.0.dev455.dist-info/licenses/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
|
829
|
+
omlish-0.0.0.dev455.dist-info/METADATA,sha256=qPrVr-lvAsmMg6yb-y5H9a4wRc4ZzwGYiKUznIHqMIY,19003
|
830
|
+
omlish-0.0.0.dev455.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
831
|
+
omlish-0.0.0.dev455.dist-info/entry_points.txt,sha256=Lt84WvRZJskWCAS7xnQGZIeVWksprtUHj0llrvVmod8,35
|
832
|
+
omlish-0.0.0.dev455.dist-info/top_level.txt,sha256=pePsKdLu7DvtUiecdYXJ78iO80uDNmBlqe-8hOzOmfs,7
|
833
|
+
omlish-0.0.0.dev455.dist-info/RECORD,,
|
omlish/funcs/match.py
DELETED
@@ -1,229 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
Analogous to scala's partial functions ( https://www.scala-lang.org/api/current/scala/PartialFunction.html ).
|
3
|
-
|
4
|
-
TODO:
|
5
|
-
- unify MatchFnClass with dispatch.method?
|
6
|
-
- __call__ = mfs.method(); @__call__.register(lambda: ...) def _call_... ?
|
7
|
-
- not really the same thing, dispatch is unordered this is necessarily ordered
|
8
|
-
- !! well.. unify interface at least?
|
9
|
-
- guard(*a, **k) -> bool + fn(*a, **k) -> T becomes dispatch(*a, **k) -> (Callable -> T) | None
|
10
|
-
"""
|
11
|
-
import abc
|
12
|
-
import dataclasses as dc
|
13
|
-
import typing as ta
|
14
|
-
|
15
|
-
from .. import lang
|
16
|
-
|
17
|
-
|
18
|
-
T = ta.TypeVar('T')
|
19
|
-
P = ta.ParamSpec('P')
|
20
|
-
|
21
|
-
|
22
|
-
##
|
23
|
-
|
24
|
-
|
25
|
-
class MatchGuardError(Exception):
|
26
|
-
pass
|
27
|
-
|
28
|
-
|
29
|
-
class MatchFn(lang.Abstract, ta.Generic[P, T]):
|
30
|
-
@abc.abstractmethod
|
31
|
-
def guard(self, *args: P.args, **kwargs: P.kwargs) -> bool:
|
32
|
-
raise NotImplementedError
|
33
|
-
|
34
|
-
@abc.abstractmethod
|
35
|
-
def fn(self, *args: P.args, **kwargs: P.kwargs) -> T:
|
36
|
-
raise NotImplementedError
|
37
|
-
|
38
|
-
def __get__(self, instance, owner=None):
|
39
|
-
return self
|
40
|
-
|
41
|
-
@ta.final
|
42
|
-
def __call__(self, *args: P.args, **kwargs: P.kwargs) -> T:
|
43
|
-
if not self.guard(*args, **kwargs):
|
44
|
-
raise MatchGuardError(*args, **kwargs)
|
45
|
-
return self.fn(*args, **kwargs)
|
46
|
-
|
47
|
-
|
48
|
-
##
|
49
|
-
|
50
|
-
|
51
|
-
@dc.dataclass(frozen=True)
|
52
|
-
class SimpleMatchFn(MatchFn[P, T]):
|
53
|
-
_guard: ta.Callable[P, bool]
|
54
|
-
_fn: ta.Callable[P, T]
|
55
|
-
|
56
|
-
def guard(self, *args: P.args, **kwargs: P.kwargs) -> bool:
|
57
|
-
return self._guard(*args, **kwargs)
|
58
|
-
|
59
|
-
def fn(self, *args: P.args, **kwargs: P.kwargs) -> T:
|
60
|
-
return self._fn(*args, **kwargs)
|
61
|
-
|
62
|
-
def __get__(self, instance, owner=None):
|
63
|
-
return self.__class__(
|
64
|
-
self._guard.__get__(instance, owner), # noqa
|
65
|
-
self._fn.__get__(instance, owner), # noqa
|
66
|
-
)
|
67
|
-
|
68
|
-
|
69
|
-
@ta.overload
|
70
|
-
def simple(guard: ta.Callable[..., bool], fn: ta.Callable[P, T]) -> SimpleMatchFn[P, T]:
|
71
|
-
...
|
72
|
-
|
73
|
-
|
74
|
-
@ta.overload
|
75
|
-
def simple(guard: ta.Callable[..., bool]) -> ta.Callable[[ta.Callable[P, T]], SimpleMatchFn[P, T]]:
|
76
|
-
...
|
77
|
-
|
78
|
-
|
79
|
-
def simple(guard, fn=None):
|
80
|
-
def inner(fn): # noqa
|
81
|
-
return SimpleMatchFn(guard, fn)
|
82
|
-
if fn is not None:
|
83
|
-
return inner(fn)
|
84
|
-
else:
|
85
|
-
return inner
|
86
|
-
|
87
|
-
|
88
|
-
##
|
89
|
-
|
90
|
-
|
91
|
-
class AmbiguousMatchesError(Exception):
|
92
|
-
pass
|
93
|
-
|
94
|
-
|
95
|
-
@dc.dataclass(frozen=True)
|
96
|
-
class MultiMatchFn(MatchFn[P, T]):
|
97
|
-
children: ta.Sequence[MatchFn[P, T]]
|
98
|
-
strict: bool = False
|
99
|
-
|
100
|
-
def match(self, *args: P.args, **kwargs: P.kwargs) -> MatchFn[P, T] | None:
|
101
|
-
matches = []
|
102
|
-
for cur in self.children:
|
103
|
-
if cur.guard(*args, **kwargs):
|
104
|
-
if self.strict:
|
105
|
-
matches.append(cur)
|
106
|
-
else:
|
107
|
-
return cur
|
108
|
-
if not matches:
|
109
|
-
return None
|
110
|
-
elif len(matches) > 1:
|
111
|
-
raise AmbiguousMatchesError
|
112
|
-
else:
|
113
|
-
return matches[0]
|
114
|
-
|
115
|
-
def guard(self, *args: P.args, **kwargs: P.kwargs) -> bool:
|
116
|
-
return self.match(*args, **kwargs) is not None
|
117
|
-
|
118
|
-
def fn(self, *args: P.args, **kwargs: P.kwargs) -> T:
|
119
|
-
if (m := self.match(*args, **kwargs)) is None:
|
120
|
-
raise MatchGuardError(*args, **kwargs)
|
121
|
-
return m.fn(*args, **kwargs)
|
122
|
-
|
123
|
-
def __get__(self, instance, owner=None):
|
124
|
-
return self.__class__(
|
125
|
-
[c.__get__(instance, owner) for c in self.children],
|
126
|
-
strict=self.strict,
|
127
|
-
)
|
128
|
-
|
129
|
-
|
130
|
-
def multi(*children: MatchFn[P, T], strict: bool = False) -> MultiMatchFn: # MultiMatchFn[P[0], T[-1]]
|
131
|
-
return MultiMatchFn(children, strict=strict) # noqa
|
132
|
-
|
133
|
-
|
134
|
-
##
|
135
|
-
|
136
|
-
|
137
|
-
class CachedMatchFn(MatchFn[P, T]):
|
138
|
-
@staticmethod
|
139
|
-
def _default_key(*args, **kwargs):
|
140
|
-
return (args, tuple(sorted(kwargs.items(), key=lambda t: t[0])))
|
141
|
-
|
142
|
-
def __init__(
|
143
|
-
self,
|
144
|
-
f: MatchFn[P, T],
|
145
|
-
*,
|
146
|
-
key: ta.Callable[P, ta.Any] = _default_key,
|
147
|
-
lock: lang.DefaultLockable = None,
|
148
|
-
) -> None:
|
149
|
-
super().__init__()
|
150
|
-
|
151
|
-
self._f = f
|
152
|
-
self._key = key
|
153
|
-
self._lock = lock
|
154
|
-
self._lock_impl = lang.default_lock(lock)()
|
155
|
-
self._dct: dict[ta.Any, lang.Maybe[ta.Any]] = {}
|
156
|
-
|
157
|
-
def guard(self, *args: P.args, **kwargs: P.kwargs) -> bool:
|
158
|
-
with self._lock_impl:
|
159
|
-
k = self._key(*args, **kwargs)
|
160
|
-
try:
|
161
|
-
e = self._dct[k]
|
162
|
-
except KeyError:
|
163
|
-
if self._f.guard(*args, **kwargs):
|
164
|
-
return True
|
165
|
-
else:
|
166
|
-
self._dct[k] = lang.empty()
|
167
|
-
return False
|
168
|
-
else:
|
169
|
-
return e.present
|
170
|
-
|
171
|
-
def fn(self, *args: P.args, **kwargs: P.kwargs) -> T:
|
172
|
-
with self._lock_impl:
|
173
|
-
k = self._key(*args, **kwargs)
|
174
|
-
try:
|
175
|
-
e = self._dct[k]
|
176
|
-
except KeyError:
|
177
|
-
try:
|
178
|
-
ret = self._f(*args, **kwargs)
|
179
|
-
except MatchGuardError:
|
180
|
-
self._dct[k] = lang.empty()
|
181
|
-
raise
|
182
|
-
else:
|
183
|
-
self._dct[k] = lang.just(ret)
|
184
|
-
return ret
|
185
|
-
else:
|
186
|
-
if e.present:
|
187
|
-
return e.must()
|
188
|
-
else:
|
189
|
-
raise MatchGuardError(*args, **kwargs)
|
190
|
-
|
191
|
-
def __get__(self, instance, owner=None):
|
192
|
-
return self.__class__(self._f.__get__(instance, owner), key=self._key) # noqa
|
193
|
-
|
194
|
-
|
195
|
-
cached = CachedMatchFn
|
196
|
-
|
197
|
-
|
198
|
-
##
|
199
|
-
|
200
|
-
|
201
|
-
class MatchFnClass(MatchFn[P, T]):
|
202
|
-
_cls_match_fn: ta.ClassVar[MultiMatchFn]
|
203
|
-
|
204
|
-
__match_fn: MatchFn[P, T] | None = None
|
205
|
-
|
206
|
-
@property
|
207
|
-
def _match_fn(self) -> MatchFn[P, T]:
|
208
|
-
if (mf := self.__match_fn) is None:
|
209
|
-
mf = self.__match_fn = self._cls_match_fn.__get__(self)
|
210
|
-
return mf
|
211
|
-
|
212
|
-
def __init_subclass__(cls, strict: bool = False, **kwargs: ta.Any) -> None:
|
213
|
-
super().__init_subclass__(**kwargs)
|
214
|
-
|
215
|
-
if '_cls_match_fn' in cls.__dict__:
|
216
|
-
raise AttributeError('_cls_match_fn')
|
217
|
-
|
218
|
-
d = {}
|
219
|
-
for c in cls.__mro__:
|
220
|
-
for a, o in c.__dict__.items():
|
221
|
-
if isinstance(o, MatchFn) and a not in d:
|
222
|
-
d[a] = o
|
223
|
-
cls._cls_match_fn = MultiMatchFn(list(d.values()), strict=strict)
|
224
|
-
|
225
|
-
def guard(self, *args: P.args, **kwargs: P.kwargs) -> bool:
|
226
|
-
return self._match_fn.guard(*args, **kwargs)
|
227
|
-
|
228
|
-
def fn(self, *args: P.args, **kwargs: P.kwargs) -> T:
|
229
|
-
return self._match_fn.fn(*args, **kwargs)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|