omlish 0.0.0.dev330__py3-none-any.whl → 0.0.0.dev331__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/typedvalues/collection.py +51 -66
- omlish/typedvalues/marshal.py +8 -0
- {omlish-0.0.0.dev330.dist-info → omlish-0.0.0.dev331.dist-info}/METADATA +1 -1
- {omlish-0.0.0.dev330.dist-info → omlish-0.0.0.dev331.dist-info}/RECORD +9 -9
- {omlish-0.0.0.dev330.dist-info → omlish-0.0.0.dev331.dist-info}/WHEEL +0 -0
- {omlish-0.0.0.dev330.dist-info → omlish-0.0.0.dev331.dist-info}/entry_points.txt +0 -0
- {omlish-0.0.0.dev330.dist-info → omlish-0.0.0.dev331.dist-info}/licenses/LICENSE +0 -0
- {omlish-0.0.0.dev330.dist-info → omlish-0.0.0.dev331.dist-info}/top_level.txt +0 -0
omlish/__about__.py
CHANGED
omlish/typedvalues/collection.py
CHANGED
@@ -35,74 +35,62 @@ class TypedValues(
|
|
35
35
|
override: bool = False,
|
36
36
|
check_type: type | tuple[type, ...] | None = None,
|
37
37
|
) -> None:
|
38
|
-
if hasattr(self, '_tup'):
|
39
|
-
# When __new__ returns the empty singleton __init__ will still be called.
|
40
|
-
if self is not self._EMPTY:
|
41
|
-
raise RuntimeError
|
42
|
-
return
|
43
|
-
|
44
38
|
super().__init__()
|
45
39
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
40
|
+
if tvs:
|
41
|
+
tmp: list = []
|
42
|
+
udct: dict = {}
|
43
|
+
for tv in tvs:
|
44
|
+
if check_type is not None:
|
45
|
+
check.isinstance(tv, check_type)
|
46
|
+
if isinstance(tv, UniqueTypedValue):
|
47
|
+
utvc = tv._unique_typed_value_cls # noqa
|
48
|
+
if not override:
|
49
|
+
try:
|
50
|
+
exu = udct[utvc]
|
51
|
+
except KeyError:
|
52
|
+
pass
|
53
|
+
else:
|
54
|
+
raise DuplicateUniqueTypedValueError(utvc, tv, check.single(exu))
|
55
|
+
ulst = udct.setdefault(utvc, [])
|
56
|
+
ulst.append(tv)
|
57
|
+
tmp.append((utvc, tv, ulst, len(ulst)))
|
58
|
+
elif isinstance(tv, TypedValue):
|
59
|
+
tmp.append(tv)
|
60
|
+
else:
|
61
|
+
raise TypeError(tv)
|
62
|
+
|
63
|
+
lst: list = []
|
64
|
+
dct: dict = {}
|
65
|
+
for obj in tmp:
|
66
|
+
if isinstance(obj, tuple):
|
67
|
+
utvc, tv, ulst, idx = obj
|
68
|
+
if idx == len(ulst):
|
69
|
+
lst.append(tv)
|
70
|
+
dct[utvc] = tv
|
71
|
+
else:
|
72
|
+
tv = obj
|
74
73
|
lst.append(tv)
|
75
|
-
dct[
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
self._dct2: dict[type[TypedValueT], TypedValueT | tuple[TypedValueT, ...]] = {
|
87
|
-
**self._dct,
|
88
|
-
**{type(v): v for v in self._dct.values() if isinstance(v, UniqueTypedValue)}, # type: ignore[misc]
|
89
|
-
}
|
90
|
-
|
91
|
-
#
|
92
|
-
|
93
|
-
_EMPTY: ta.ClassVar['TypedValues']
|
74
|
+
dct.setdefault(type(tv), []).append(tv)
|
75
|
+
|
76
|
+
tup = tuple(lst)
|
77
|
+
dct = {
|
78
|
+
k: tuple(v) if isinstance(v, list) else v
|
79
|
+
for k, v in dct.items()
|
80
|
+
}
|
81
|
+
dct2 = {
|
82
|
+
**dct,
|
83
|
+
**{type(v): v for v in dct.values() if isinstance(v, UniqueTypedValue)},
|
84
|
+
}
|
94
85
|
|
95
|
-
|
96
|
-
|
97
|
-
|
86
|
+
else:
|
87
|
+
tup = ()
|
88
|
+
dct = {}
|
89
|
+
dct2 = {}
|
98
90
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
return cls._EMPTY
|
103
|
-
except AttributeError:
|
104
|
-
pass
|
105
|
-
return super().__new__(cls)
|
91
|
+
self._tup: tuple[TypedValueT, ...] = tup
|
92
|
+
self._dct: dict[type[TypedValueT], TypedValueT | tuple[TypedValueT, ...]] = dct
|
93
|
+
self._dct2: dict[type[TypedValueT], TypedValueT | tuple[TypedValueT, ...]] = dct2
|
106
94
|
|
107
95
|
#
|
108
96
|
|
@@ -216,6 +204,3 @@ class TypedValues(
|
|
216
204
|
ret = tuple(tv for tv in self if isinstance(tv, cls))
|
217
205
|
any_dct[cls] = ret
|
218
206
|
return ret
|
219
|
-
|
220
|
-
|
221
|
-
TypedValues._EMPTY = TypedValues() # noqa
|
omlish/typedvalues/marshal.py
CHANGED
@@ -106,6 +106,10 @@ class TypedValuesMarshalerFactory(msh.MarshalerFactoryMatchClass):
|
|
106
106
|
)
|
107
107
|
return msh.IterableMarshaler(tv_m)
|
108
108
|
|
109
|
+
@mfs.simple(lambda _, ctx, rty: rty is TypedValues)
|
110
|
+
def _build_concrete(self, ctx: msh.MarshalContext, rty: rfl.Type) -> msh.Marshaler:
|
111
|
+
raise NotImplementedError
|
112
|
+
|
109
113
|
|
110
114
|
class TypedValuesUnmarshalerFactory(msh.UnmarshalerFactoryMatchClass):
|
111
115
|
@mfs.simple(lambda _, ctx, rty: isinstance(rty, rfl.Generic) and rty.cls is TypedValues)
|
@@ -117,6 +121,10 @@ class TypedValuesUnmarshalerFactory(msh.UnmarshalerFactoryMatchClass):
|
|
117
121
|
)
|
118
122
|
return msh.IterableUnmarshaler(lambda it: TypedValues(*it), tv_u) # noqa
|
119
123
|
|
124
|
+
@mfs.simple(lambda _, ctx, rty: rty is TypedValues)
|
125
|
+
def _build_concrete(self, ctx: msh.UnmarshalContext, rty: rfl.Type) -> msh.Unmarshaler:
|
126
|
+
raise NotImplementedError
|
127
|
+
|
120
128
|
|
121
129
|
##
|
122
130
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
omlish/.manifests.json,sha256=orgsRvtpHu8tdhaCvlP9v3P495OJopYYiHKjK68WtWg,8587
|
2
|
-
omlish/__about__.py,sha256=
|
2
|
+
omlish/__about__.py,sha256=0UbBN9lPmVwVRqut0sXZlqLeaoVAJVmIbW5gTMvKp4E,3478
|
3
3
|
omlish/__init__.py,sha256=SsyiITTuK0v74XpKV8dqNaCmjOlan1JZKrHQv5rWKPA,253
|
4
4
|
omlish/c3.py,sha256=rer-TPOFDU6fYq_AWio_AmA-ckZ8JDY5shIzQ_yXfzA,8414
|
5
5
|
omlish/cached.py,sha256=MLap_p0rdGoDIMVhXVHm1tsbcWobJF0OanoodV03Ju8,542
|
@@ -850,16 +850,16 @@ omlish/text/go/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
850
850
|
omlish/text/go/quoting.py,sha256=N9EYdnFdEX_A8fOviH-1w4jwV3XOQ7VU2WsoUNubYVY,9137
|
851
851
|
omlish/typedvalues/__init__.py,sha256=nzpnoRW_wScMPit5Xz37ky3nKBdzzkgtnQA4SfVHN8E,684
|
852
852
|
omlish/typedvalues/accessor.py,sha256=_NEGBmQ84-h_rDfYeoq7DA20fhj3dogQuvzxXKhjx54,3121
|
853
|
-
omlish/typedvalues/collection.py,sha256=
|
853
|
+
omlish/typedvalues/collection.py,sha256=TjNuEEyTXbGfbsk7nvBB_Jhgz94R5JSs0u6ocNAlj3Y,5511
|
854
854
|
omlish/typedvalues/consumer.py,sha256=peDQAgriSyBx_Hc8QHAhEgYy0oSS52qQ_7Tqdssl2AE,4375
|
855
855
|
omlish/typedvalues/generic.py,sha256=ft-x4X3k1oFirtYnDfsvrI3ZQikWM8lGLrvrOEbcGq0,742
|
856
856
|
omlish/typedvalues/holder.py,sha256=vu-umn-h1nvUqmtV5T9ZfQ_OoOYsERu8PhI2N48Ryns,1133
|
857
|
-
omlish/typedvalues/marshal.py,sha256=
|
857
|
+
omlish/typedvalues/marshal.py,sha256=pGA4qzAmpqJTeUya4sTSNEkuXoyUdg5l_XTotR8v9SU,4694
|
858
858
|
omlish/typedvalues/reflect.py,sha256=PAvKW6T4cW7u--iX80w3HWwZUS3SmIZ2_lQjT65uAyk,1026
|
859
859
|
omlish/typedvalues/values.py,sha256=ym46I-q2QJ_6l4UlERqv3yj87R-kp8nCKMRph0xQ3UA,1307
|
860
|
-
omlish-0.0.0.
|
861
|
-
omlish-0.0.0.
|
862
|
-
omlish-0.0.0.
|
863
|
-
omlish-0.0.0.
|
864
|
-
omlish-0.0.0.
|
865
|
-
omlish-0.0.0.
|
860
|
+
omlish-0.0.0.dev331.dist-info/licenses/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
|
861
|
+
omlish-0.0.0.dev331.dist-info/METADATA,sha256=LPTnC-GcKfRYBxXrfNc-5GkZGyoB76oVPWDcECXYz5A,4416
|
862
|
+
omlish-0.0.0.dev331.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
863
|
+
omlish-0.0.0.dev331.dist-info/entry_points.txt,sha256=Lt84WvRZJskWCAS7xnQGZIeVWksprtUHj0llrvVmod8,35
|
864
|
+
omlish-0.0.0.dev331.dist-info/top_level.txt,sha256=pePsKdLu7DvtUiecdYXJ78iO80uDNmBlqe-8hOzOmfs,7
|
865
|
+
omlish-0.0.0.dev331.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|