omlish 0.0.0.dev274__py3-none-any.whl → 0.0.0.dev275__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 +68 -19
- {omlish-0.0.0.dev274.dist-info → omlish-0.0.0.dev275.dist-info}/METADATA +1 -1
- {omlish-0.0.0.dev274.dist-info → omlish-0.0.0.dev275.dist-info}/RECORD +8 -8
- {omlish-0.0.0.dev274.dist-info → omlish-0.0.0.dev275.dist-info}/WHEEL +0 -0
- {omlish-0.0.0.dev274.dist-info → omlish-0.0.0.dev275.dist-info}/entry_points.txt +0 -0
- {omlish-0.0.0.dev274.dist-info → omlish-0.0.0.dev275.dist-info}/licenses/LICENSE +0 -0
- {omlish-0.0.0.dev274.dist-info → omlish-0.0.0.dev275.dist-info}/top_level.txt +0 -0
omlish/__about__.py
CHANGED
omlish/typedvalues/collection.py
CHANGED
@@ -29,8 +29,10 @@ class TypedValues(
|
|
29
29
|
ta.Generic[TypedValueT],
|
30
30
|
):
|
31
31
|
def __init__(self, *tvs: TypedValueT, override: bool = False) -> None:
|
32
|
-
if hasattr(self, '
|
32
|
+
if hasattr(self, '_tup'):
|
33
33
|
# When __new__ returns the empty singleton __init__ will still be called.
|
34
|
+
if self is not self._EMPTY:
|
35
|
+
raise RuntimeError
|
34
36
|
return
|
35
37
|
|
36
38
|
super().__init__()
|
@@ -69,10 +71,11 @@ class TypedValues(
|
|
69
71
|
lst.append(tv)
|
70
72
|
dct.setdefault(type(tv), []).append(tv)
|
71
73
|
|
72
|
-
self.
|
73
|
-
self._dct =
|
74
|
-
|
75
|
-
|
74
|
+
self._tup: tuple[TypedValueT, ...] = tuple(lst)
|
75
|
+
self._dct: dict[type[TypedValueT], TypedValueT | tuple[TypedValueT, ...]] = {
|
76
|
+
k: tuple(v) if isinstance(v, list) else v
|
77
|
+
for k, v in dct.items()
|
78
|
+
}
|
76
79
|
|
77
80
|
#
|
78
81
|
|
@@ -92,30 +95,69 @@ class TypedValues(
|
|
92
95
|
|
93
96
|
#
|
94
97
|
|
95
|
-
def with_(self, *tvs, override: bool = False) -> 'TypedValues':
|
96
|
-
return TypedValues(*self._lst, *tvs, override=override)
|
97
|
-
|
98
98
|
def without(self, *tys: type) -> ta.Iterator[TypedValueT]:
|
99
|
-
for o in self.
|
99
|
+
for o in self._tup:
|
100
100
|
if isinstance(o, tys):
|
101
101
|
continue
|
102
102
|
yield o
|
103
103
|
|
104
104
|
#
|
105
105
|
|
106
|
+
def update(self, *tvs, override: bool = False) -> 'TypedValues':
|
107
|
+
return TypedValues(*self._tup, *tvs, override=override)
|
108
|
+
|
109
|
+
def discard(self, *tys: type) -> 'TypedValues':
|
110
|
+
return TypedValues(*self.without(*tys))
|
111
|
+
|
112
|
+
#
|
113
|
+
|
106
114
|
def __repr__(self) -> str:
|
107
|
-
return f'{self.__class__.__name__}({", ".join(map(repr, self.
|
115
|
+
return f'{self.__class__.__name__}({", ".join(map(repr, self._tup))})'
|
116
|
+
|
117
|
+
#
|
118
|
+
|
119
|
+
_set: frozenset[TypedValueT]
|
120
|
+
|
121
|
+
def to_set(self) -> frozenset[TypedValueT]:
|
122
|
+
try:
|
123
|
+
return self._set
|
124
|
+
except AttributeError:
|
125
|
+
pass
|
126
|
+
s = frozenset(self._tup)
|
127
|
+
self._set = s
|
128
|
+
return s
|
129
|
+
|
130
|
+
#
|
131
|
+
|
132
|
+
_hash: int
|
133
|
+
|
134
|
+
def __hash__(self) -> int:
|
135
|
+
try:
|
136
|
+
return self._hash
|
137
|
+
except AttributeError:
|
138
|
+
pass
|
139
|
+
h = hash(self._tup)
|
140
|
+
self._hash = h
|
141
|
+
return h
|
142
|
+
|
143
|
+
def __eq__(self, other):
|
144
|
+
if not isinstance(other, type(self)):
|
145
|
+
return NotImplemented
|
146
|
+
return (
|
147
|
+
other is self or
|
148
|
+
other._tup == self._tup
|
149
|
+
)
|
108
150
|
|
109
151
|
#
|
110
152
|
|
111
153
|
def __iter__(self) -> ta.Iterator[TypedValueT]:
|
112
|
-
return iter(self.
|
154
|
+
return iter(self._tup)
|
113
155
|
|
114
156
|
def __len__(self) -> int:
|
115
|
-
return len(self.
|
157
|
+
return len(self._tup)
|
116
158
|
|
117
159
|
def __bool__(self) -> bool:
|
118
|
-
return bool(self.
|
160
|
+
return bool(self._tup)
|
119
161
|
|
120
162
|
#
|
121
163
|
|
@@ -124,7 +166,7 @@ class TypedValues(
|
|
124
166
|
|
125
167
|
def _typed_value_getitem(self, key):
|
126
168
|
if isinstance(key, int):
|
127
|
-
return self.
|
169
|
+
return self._tup[key]
|
128
170
|
elif isinstance(key, type):
|
129
171
|
return self._dct[check.issubclass(key, TypedValue)]
|
130
172
|
else:
|
@@ -138,17 +180,24 @@ class TypedValues(
|
|
138
180
|
if issubclass(key, UniqueTypedValue):
|
139
181
|
return default
|
140
182
|
elif default is not None:
|
141
|
-
return
|
183
|
+
return tuple(default)
|
142
184
|
else:
|
143
|
-
return
|
185
|
+
return ()
|
186
|
+
|
187
|
+
_any_dct: dict[type, tuple[TypedValueT, ...]]
|
144
188
|
|
145
189
|
def _typed_value_get_any(self, cls):
|
146
190
|
try:
|
147
|
-
|
191
|
+
any_dct = self._any_dct
|
192
|
+
except AttributeError:
|
193
|
+
any_dct = {}
|
194
|
+
self._any_dct = any_dct
|
195
|
+
try:
|
196
|
+
return any_dct[cls]
|
148
197
|
except KeyError:
|
149
198
|
pass
|
150
|
-
ret =
|
151
|
-
|
199
|
+
ret = tuple(tv for tv in self if isinstance(tv, cls))
|
200
|
+
any_dct[cls] = ret
|
152
201
|
return ret
|
153
202
|
|
154
203
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
omlish/.manifests.json,sha256=pjGUyLHaoWpPqRP3jz2u1fC1qoRc2lvrEcpU_Ax2tdg,8253
|
2
|
-
omlish/__about__.py,sha256=
|
2
|
+
omlish/__about__.py,sha256=lF4UMo4JKgTQYbwgQIGekUW4rRztnuwQfTy1Wa-z9kQ,3380
|
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
|
@@ -778,14 +778,14 @@ omlish/text/go/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
778
778
|
omlish/text/go/quoting.py,sha256=N9EYdnFdEX_A8fOviH-1w4jwV3XOQ7VU2WsoUNubYVY,9137
|
779
779
|
omlish/typedvalues/__init__.py,sha256=YalNleXS2vQX_3dOIMwfb4n_uBkENTT4QXHnsHatGGM,496
|
780
780
|
omlish/typedvalues/accessor.py,sha256=0k21N-CkjGaY6zCwugsRfOC_CDkqk7wNz4oxO1_6EEA,2919
|
781
|
-
omlish/typedvalues/collection.py,sha256=
|
781
|
+
omlish/typedvalues/collection.py,sha256=jsXSggmMMvGATcJgQkUXt5Guwq8aquw73_OIC-e6U0I,5300
|
782
782
|
omlish/typedvalues/generic.py,sha256=byWG_gMXhNelckUwdmOoJE9FKkL71Q4BSi4ZLyy0XZ0,788
|
783
783
|
omlish/typedvalues/holder.py,sha256=4SwRezsmuDDEO5gENGx8kTm30pblF5UktoEAu02i-Gk,1554
|
784
784
|
omlish/typedvalues/marshal.py,sha256=BuFQMoaLSDbEm32nj_hkBSClPvC0euNFU7_EhsrfBck,4487
|
785
785
|
omlish/typedvalues/values.py,sha256=Acyf6xSdNHxrkRXLXrFqJouk35YOveso1VqTbyPwQW4,1223
|
786
|
-
omlish-0.0.0.
|
787
|
-
omlish-0.0.0.
|
788
|
-
omlish-0.0.0.
|
789
|
-
omlish-0.0.0.
|
790
|
-
omlish-0.0.0.
|
791
|
-
omlish-0.0.0.
|
786
|
+
omlish-0.0.0.dev275.dist-info/licenses/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
|
787
|
+
omlish-0.0.0.dev275.dist-info/METADATA,sha256=UZAxSmm4fOzFFAc7qszP_AvnFcJB1Sp3UwcpxUQ9V6w,4198
|
788
|
+
omlish-0.0.0.dev275.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
789
|
+
omlish-0.0.0.dev275.dist-info/entry_points.txt,sha256=Lt84WvRZJskWCAS7xnQGZIeVWksprtUHj0llrvVmod8,35
|
790
|
+
omlish-0.0.0.dev275.dist-info/top_level.txt,sha256=pePsKdLu7DvtUiecdYXJ78iO80uDNmBlqe-8hOzOmfs,7
|
791
|
+
omlish-0.0.0.dev275.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|