omlish 0.0.0.dev1__py3-none-any.whl → 0.0.0.dev2__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.
Potentially problematic release.
This version of omlish might be problematic. Click here for more details.
- omlish/__about__.py +2 -2
- omlish/argparse.py +4 -4
- omlish/asyncs/anyio.py +62 -1
- omlish/asyncs/futures.py +6 -6
- omlish/c3.py +4 -4
- omlish/check.py +6 -6
- omlish/collections/__init__.py +98 -63
- omlish/collections/cache/descriptor.py +5 -5
- omlish/collections/cache/impl.py +4 -4
- omlish/collections/coerce.py +43 -43
- omlish/collections/frozen.py +3 -3
- omlish/collections/identity.py +1 -1
- omlish/collections/mappings.py +3 -3
- omlish/collections/ordered.py +1 -1
- omlish/collections/skiplist.py +6 -6
- omlish/collections/sorted.py +3 -3
- omlish/collections/treap.py +17 -17
- omlish/collections/treapmap.py +2 -2
- omlish/collections/unmodifiable.py +28 -27
- omlish/configs/flattening.py +1 -1
- omlish/configs/props.py +1 -1
- omlish/dataclasses/impl/__init__.py +2 -0
- omlish/dataclasses/impl/api.py +5 -13
- omlish/dataclasses/impl/fields.py +1 -1
- omlish/dataclasses/impl/init.py +1 -1
- omlish/dataclasses/impl/internals.py +15 -0
- omlish/dataclasses/impl/main.py +4 -4
- omlish/dataclasses/impl/metaclass.py +1 -1
- omlish/dataclasses/impl/metadata.py +1 -1
- omlish/dataclasses/impl/order.py +1 -1
- omlish/dataclasses/impl/params.py +4 -38
- omlish/dataclasses/impl/reflect.py +1 -7
- omlish/dataclasses/impl/repr.py +23 -5
- omlish/dataclasses/impl/simple.py +2 -2
- omlish/dataclasses/impl/slots.py +2 -2
- omlish/dataclasses/impl/utils.py +4 -4
- omlish/dispatch/dispatch.py +9 -8
- omlish/dispatch/methods.py +2 -2
- omlish/docker.py +8 -6
- omlish/dynamic.py +5 -5
- omlish/graphs/dot/items.py +1 -1
- omlish/graphs/trees.py +15 -21
- omlish/inject/elements.py +1 -1
- omlish/inject/exceptions.py +1 -1
- omlish/inject/impl/injector.py +1 -1
- omlish/inject/impl/inspect.py +1 -1
- omlish/inject/injector.py +1 -1
- omlish/inject/providers.py +2 -2
- omlish/iterators.py +43 -2
- omlish/lang/__init__.py +167 -112
- omlish/lang/cached.py +13 -5
- omlish/lang/classes/__init__.py +35 -24
- omlish/lang/classes/abstract.py +1 -1
- omlish/lang/classes/simple.py +1 -1
- omlish/lang/clsdct.py +1 -1
- omlish/lang/contextmanagers.py +23 -15
- omlish/lang/datetimes.py +1 -1
- omlish/lang/descriptors.py +35 -2
- omlish/lang/exceptions.py +2 -0
- omlish/lang/functions.py +43 -13
- omlish/lang/imports.py +8 -8
- omlish/lang/iterables.py +1 -1
- omlish/lang/maybes.py +1 -1
- omlish/lang/objects.py +2 -2
- omlish/lang/timeouts.py +53 -0
- omlish/lang/typing.py +2 -2
- omlish/libc.py +6 -6
- omlish/marshal/base.py +6 -6
- omlish/marshal/dataclasses.py +2 -2
- omlish/marshal/enums.py +2 -2
- omlish/marshal/factories.py +10 -10
- omlish/marshal/iterables.py +2 -2
- omlish/marshal/mappings.py +2 -2
- omlish/marshal/optionals.py +4 -4
- omlish/marshal/polymorphism.py +4 -4
- omlish/marshal/standard.py +6 -6
- omlish/marshal/utils.py +1 -1
- omlish/os.py +13 -4
- omlish/procfs.py +336 -0
- omlish/reflect.py +2 -12
- omlish/replserver/console.py +9 -9
- omlish/replserver/server.py +4 -4
- omlish/sql/__init__.py +0 -0
- omlish/sql/_abcs.py +65 -0
- omlish/sql/dbs.py +90 -0
- omlish/stats.py +3 -3
- omlish/testing/pydevd.py +4 -6
- omlish/testing/pytest/inject/__init__.py +7 -0
- omlish/testing/pytest/inject/harness.py +23 -1
- omlish/testing/pytest/plugins/__init__.py +1 -1
- omlish/testing/pytest/plugins/pydevd.py +12 -0
- omlish/testing/pytest/plugins/switches.py +2 -2
- omlish/testing/testing.py +5 -5
- omlish/text/parts.py +3 -3
- omlish-0.0.0.dev2.dist-info/METADATA +31 -0
- omlish-0.0.0.dev2.dist-info/RECORD +193 -0
- {omlish-0.0.0.dev1.dist-info → omlish-0.0.0.dev2.dist-info}/WHEEL +1 -1
- omlish/testing/pytest/plugins/pycharm.py +0 -54
- omlish-0.0.0.dev1.dist-info/METADATA +0 -17
- omlish-0.0.0.dev1.dist-info/RECORD +0 -187
- {omlish-0.0.0.dev1.dist-info → omlish-0.0.0.dev2.dist-info}/LICENSE +0 -0
- {omlish-0.0.0.dev1.dist-info → omlish-0.0.0.dev2.dist-info}/top_level.txt +0 -0
omlish/collections/coerce.py
CHANGED
|
@@ -39,8 +39,8 @@ def seq(
|
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
def opt_seq(
|
|
42
|
-
it: ta.
|
|
43
|
-
) -> ta.
|
|
42
|
+
it: ta.Iterable[T] | None,
|
|
43
|
+
) -> ta.Sequence[T] | None:
|
|
44
44
|
if it is None:
|
|
45
45
|
return None
|
|
46
46
|
else:
|
|
@@ -48,8 +48,8 @@ def opt_seq(
|
|
|
48
48
|
|
|
49
49
|
|
|
50
50
|
def seq_or_none(
|
|
51
|
-
it: ta.
|
|
52
|
-
) -> ta.
|
|
51
|
+
it: ta.Iterable[T] | None,
|
|
52
|
+
) -> ta.Sequence[T] | None:
|
|
53
53
|
ret = opt_seq(it)
|
|
54
54
|
if ret:
|
|
55
55
|
return ret
|
|
@@ -58,7 +58,7 @@ def seq_or_none(
|
|
|
58
58
|
|
|
59
59
|
|
|
60
60
|
def seq_of(
|
|
61
|
-
fn: ta.
|
|
61
|
+
fn: ta.Callable[[T], T2] | tuple,
|
|
62
62
|
) -> ta.Callable[[ta.Iterable[T]], ta.Sequence[T2]]:
|
|
63
63
|
def inner(it):
|
|
64
64
|
return seq(fn(e) for e in it) # type: ignore
|
|
@@ -68,8 +68,8 @@ def seq_of(
|
|
|
68
68
|
|
|
69
69
|
|
|
70
70
|
def opt_seq_of(
|
|
71
|
-
fn: ta.
|
|
72
|
-
) -> ta.Callable[[ta.
|
|
71
|
+
fn: ta.Callable[[T], T2] | tuple,
|
|
72
|
+
) -> ta.Callable[[ta.Iterable[T] | None], ta.Sequence[T2] | None]:
|
|
73
73
|
def inner(it):
|
|
74
74
|
if it is None:
|
|
75
75
|
return None
|
|
@@ -81,8 +81,8 @@ def opt_seq_of(
|
|
|
81
81
|
|
|
82
82
|
|
|
83
83
|
def seq_of_or_none(
|
|
84
|
-
fn: ta.
|
|
85
|
-
) -> ta.Callable[[ta.
|
|
84
|
+
fn: ta.Callable[[T], T2] | tuple,
|
|
85
|
+
) -> ta.Callable[[ta.Iterable[T] | None], ta.Sequence[T2] | None]:
|
|
86
86
|
def inner(it):
|
|
87
87
|
if it is None:
|
|
88
88
|
return None
|
|
@@ -115,8 +115,8 @@ def abs_set(
|
|
|
115
115
|
|
|
116
116
|
|
|
117
117
|
def opt_abs_set(
|
|
118
|
-
it: ta.
|
|
119
|
-
) -> ta.
|
|
118
|
+
it: ta.Iterable[T] | None,
|
|
119
|
+
) -> ta.AbstractSet[T] | None:
|
|
120
120
|
if it is None:
|
|
121
121
|
return None
|
|
122
122
|
else:
|
|
@@ -124,8 +124,8 @@ def opt_abs_set(
|
|
|
124
124
|
|
|
125
125
|
|
|
126
126
|
def abs_set_or_none(
|
|
127
|
-
it: ta.
|
|
128
|
-
) -> ta.
|
|
127
|
+
it: ta.Iterable[T] | None,
|
|
128
|
+
) -> ta.AbstractSet[T] | None:
|
|
129
129
|
ret = opt_abs_set(it)
|
|
130
130
|
if ret:
|
|
131
131
|
return ret
|
|
@@ -134,7 +134,7 @@ def abs_set_or_none(
|
|
|
134
134
|
|
|
135
135
|
|
|
136
136
|
def abs_set_of(
|
|
137
|
-
fn: ta.
|
|
137
|
+
fn: ta.Callable[[T], T2] | tuple,
|
|
138
138
|
) -> ta.Callable[[ta.Iterable[T]], ta.AbstractSet[T2]]:
|
|
139
139
|
def inner(it):
|
|
140
140
|
return abs_set(fn(e) for e in it) # type: ignore
|
|
@@ -144,8 +144,8 @@ def abs_set_of(
|
|
|
144
144
|
|
|
145
145
|
|
|
146
146
|
def opt_abs_set_of(
|
|
147
|
-
fn: ta.
|
|
148
|
-
) -> ta.Callable[[ta.
|
|
147
|
+
fn: ta.Callable[[T], T2] | tuple,
|
|
148
|
+
) -> ta.Callable[[ta.Iterable[T] | None], ta.AbstractSet[T2] | None]:
|
|
149
149
|
def inner(it):
|
|
150
150
|
if it is None:
|
|
151
151
|
return None
|
|
@@ -157,8 +157,8 @@ def opt_abs_set_of(
|
|
|
157
157
|
|
|
158
158
|
|
|
159
159
|
def abs_set_of_or_none(
|
|
160
|
-
fn: ta.
|
|
161
|
-
) -> ta.Callable[[ta.
|
|
160
|
+
fn: ta.Callable[[T], T2] | tuple,
|
|
161
|
+
) -> ta.Callable[[ta.Iterable[T] | None], ta.AbstractSet[T2] | None]:
|
|
162
162
|
def inner(it):
|
|
163
163
|
if it is None:
|
|
164
164
|
return None
|
|
@@ -191,8 +191,8 @@ def frozenset_(
|
|
|
191
191
|
|
|
192
192
|
|
|
193
193
|
def opt_frozenset(
|
|
194
|
-
it: ta.
|
|
195
|
-
) ->
|
|
194
|
+
it: ta.Iterable[T] | None,
|
|
195
|
+
) -> frozenset[T] | None:
|
|
196
196
|
if it is None:
|
|
197
197
|
return None
|
|
198
198
|
else:
|
|
@@ -200,8 +200,8 @@ def opt_frozenset(
|
|
|
200
200
|
|
|
201
201
|
|
|
202
202
|
def frozenset_or_none(
|
|
203
|
-
it: ta.
|
|
204
|
-
) ->
|
|
203
|
+
it: ta.Iterable[T] | None,
|
|
204
|
+
) -> frozenset[T] | None:
|
|
205
205
|
ret = opt_frozenset(it)
|
|
206
206
|
if ret:
|
|
207
207
|
return ret
|
|
@@ -210,7 +210,7 @@ def frozenset_or_none(
|
|
|
210
210
|
|
|
211
211
|
|
|
212
212
|
def frozenset_of(
|
|
213
|
-
fn: ta.
|
|
213
|
+
fn: ta.Callable[[T], T2] | tuple,
|
|
214
214
|
) -> ta.Callable[[ta.Iterable[T]], frozenset[T2]]:
|
|
215
215
|
def inner(it):
|
|
216
216
|
return frozenset_(fn(e) for e in it) # type: ignore
|
|
@@ -220,8 +220,8 @@ def frozenset_of(
|
|
|
220
220
|
|
|
221
221
|
|
|
222
222
|
def opt_frozenset_of(
|
|
223
|
-
fn: ta.
|
|
224
|
-
) -> ta.Callable[[ta.
|
|
223
|
+
fn: ta.Callable[[T], T2] | tuple,
|
|
224
|
+
) -> ta.Callable[[ta.Iterable[T] | None], frozenset[T2] | None]:
|
|
225
225
|
def inner(it):
|
|
226
226
|
if it is None:
|
|
227
227
|
return None
|
|
@@ -233,8 +233,8 @@ def opt_frozenset_of(
|
|
|
233
233
|
|
|
234
234
|
|
|
235
235
|
def frozenset_of_or_none(
|
|
236
|
-
fn: ta.
|
|
237
|
-
) -> ta.Callable[[ta.
|
|
236
|
+
fn: ta.Callable[[T], T2] | tuple,
|
|
237
|
+
) -> ta.Callable[[ta.Iterable[T] | None], frozenset[T2] | None]:
|
|
238
238
|
def inner(it):
|
|
239
239
|
if it is None:
|
|
240
240
|
return None
|
|
@@ -256,14 +256,14 @@ def frozenset_of_or_none(
|
|
|
256
256
|
|
|
257
257
|
|
|
258
258
|
def map(
|
|
259
|
-
src: ta.
|
|
259
|
+
src: ta.Mapping[K, V] | ta.Iterable[tuple[K, V]],
|
|
260
260
|
) -> ta.Mapping[K, V]:
|
|
261
261
|
return FrozenDict(src)
|
|
262
262
|
|
|
263
263
|
|
|
264
264
|
def opt_map(
|
|
265
|
-
src: ta.
|
|
266
|
-
) -> ta.
|
|
265
|
+
src: ta.Mapping[K, V] | ta.Iterable[tuple[K, V]] | None,
|
|
266
|
+
) -> ta.Mapping[K, V] | None:
|
|
267
267
|
if src is None:
|
|
268
268
|
return None
|
|
269
269
|
else:
|
|
@@ -271,8 +271,8 @@ def opt_map(
|
|
|
271
271
|
|
|
272
272
|
|
|
273
273
|
def map_or_none(
|
|
274
|
-
src: ta.
|
|
275
|
-
) -> ta.
|
|
274
|
+
src: ta.Mapping[K, V] | ta.Iterable[tuple[K, V]] | None,
|
|
275
|
+
) -> ta.Mapping[K, V] | None:
|
|
276
276
|
ret = opt_map(src)
|
|
277
277
|
if ret:
|
|
278
278
|
return ret
|
|
@@ -281,10 +281,10 @@ def map_or_none(
|
|
|
281
281
|
|
|
282
282
|
|
|
283
283
|
def map_of(
|
|
284
|
-
key_fn: ta.
|
|
285
|
-
value_fn: ta.
|
|
284
|
+
key_fn: ta.Callable[[K], K2] | tuple,
|
|
285
|
+
value_fn: ta.Callable[[V], V2] | tuple,
|
|
286
286
|
) -> ta.Callable[
|
|
287
|
-
[ta.
|
|
287
|
+
[ta.Mapping[K, V] | ta.Iterable[tuple[K, V]]],
|
|
288
288
|
ta.Mapping[K2, V2],
|
|
289
289
|
]:
|
|
290
290
|
def inner(src):
|
|
@@ -296,11 +296,11 @@ def map_of(
|
|
|
296
296
|
|
|
297
297
|
|
|
298
298
|
def opt_map_of(
|
|
299
|
-
key_fn: ta.
|
|
300
|
-
value_fn: ta.
|
|
299
|
+
key_fn: ta.Callable[[K], K2] | tuple,
|
|
300
|
+
value_fn: ta.Callable[[V], V2] | tuple,
|
|
301
301
|
) -> ta.Callable[
|
|
302
|
-
[ta.
|
|
303
|
-
ta.
|
|
302
|
+
[ta.Mapping[K, V] | ta.Iterable[tuple[K, V]] | None],
|
|
303
|
+
ta.Mapping[K2, V2] | None,
|
|
304
304
|
]:
|
|
305
305
|
def inner(src):
|
|
306
306
|
if src is None:
|
|
@@ -314,11 +314,11 @@ def opt_map_of(
|
|
|
314
314
|
|
|
315
315
|
|
|
316
316
|
def map_of_or_none(
|
|
317
|
-
key_fn: ta.
|
|
318
|
-
value_fn: ta.
|
|
317
|
+
key_fn: ta.Callable[[K], K2] | tuple,
|
|
318
|
+
value_fn: ta.Callable[[V], V2] | tuple,
|
|
319
319
|
) -> ta.Callable[
|
|
320
|
-
[ta.
|
|
321
|
-
ta.
|
|
320
|
+
[ta.Mapping[K, V] | ta.Iterable[tuple[K, V]] | None],
|
|
321
|
+
ta.Mapping[K2, V2] | None,
|
|
322
322
|
]:
|
|
323
323
|
def inner(src):
|
|
324
324
|
if src is None:
|
omlish/collections/frozen.py
CHANGED
|
@@ -74,11 +74,11 @@ class FrozenDict(ta.Mapping[K, V], Frozen):
|
|
|
74
74
|
|
|
75
75
|
class FrozenList(ta.Sequence[T], Frozen):
|
|
76
76
|
|
|
77
|
-
def __init__(self, it: ta.
|
|
77
|
+
def __init__(self, it: ta.Iterable[T] | None = None) -> None:
|
|
78
78
|
super().__init__()
|
|
79
79
|
|
|
80
80
|
self._tup: tuple = tuple(it) if it is not None else ()
|
|
81
|
-
self._hash:
|
|
81
|
+
self._hash: int | None = None
|
|
82
82
|
|
|
83
83
|
@property
|
|
84
84
|
def debug(self) -> ta.Sequence[T]:
|
|
@@ -111,7 +111,7 @@ class FrozenList(ta.Sequence[T], Frozen):
|
|
|
111
111
|
self._hash = hash(self._tup)
|
|
112
112
|
return self._hash
|
|
113
113
|
|
|
114
|
-
def __getitem__(self, idx:
|
|
114
|
+
def __getitem__(self, idx: int | slice) -> 'FrozenList[T]': # type: ignore
|
|
115
115
|
if isinstance(idx, int):
|
|
116
116
|
return self._tup[idx]
|
|
117
117
|
else:
|
omlish/collections/identity.py
CHANGED
|
@@ -69,7 +69,7 @@ class IdentityKeyDict(ta.MutableMapping[K, V]):
|
|
|
69
69
|
|
|
70
70
|
class IdentitySet(ta.MutableSet[T]):
|
|
71
71
|
|
|
72
|
-
def __init__(self, init: ta.
|
|
72
|
+
def __init__(self, init: ta.Iterable[T] | None = None) -> None:
|
|
73
73
|
super().__init__()
|
|
74
74
|
self._dict: dict[int, T] = {}
|
|
75
75
|
if init is not None:
|
omlish/collections/mappings.py
CHANGED
|
@@ -8,7 +8,7 @@ K = ta.TypeVar('K')
|
|
|
8
8
|
V = ta.TypeVar('V')
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
def multikey_dict(dct: ta.Mapping[ta.
|
|
11
|
+
def multikey_dict(dct: ta.Mapping[ta.Iterable[K] | K, V], *, deep: bool = False) -> dict[K, V]:
|
|
12
12
|
ret = {}
|
|
13
13
|
for k, v in dct.items():
|
|
14
14
|
if deep and isinstance(v, dict):
|
|
@@ -23,7 +23,7 @@ def multikey_dict(dct: ta.Mapping[ta.Union[ta.Iterable[K], K], V], *, deep: bool
|
|
|
23
23
|
|
|
24
24
|
def guarded_map_update(
|
|
25
25
|
dst: ta.MutableMapping[ta.Any, ta.Any],
|
|
26
|
-
*srcs: ta.Mapping[ta.Any, ta.Any]
|
|
26
|
+
*srcs: ta.Mapping[ta.Any, ta.Any],
|
|
27
27
|
) -> ta.MutableMapping[ta.Any, ta.Any]:
|
|
28
28
|
for src in srcs:
|
|
29
29
|
for k, v in src.items():
|
|
@@ -71,7 +71,7 @@ class TypeMap(ta.Generic[T]):
|
|
|
71
71
|
def __iter__(self) -> ta.Iterable[T]:
|
|
72
72
|
return iter(self._items)
|
|
73
73
|
|
|
74
|
-
def get(self, ty: type[T]) ->
|
|
74
|
+
def get(self, ty: type[T]) -> T | None:
|
|
75
75
|
return self._dct.get(ty)
|
|
76
76
|
|
|
77
77
|
def __getitem__(self, ty: type[T]) -> ta.Sequence[T]:
|
omlish/collections/ordered.py
CHANGED
|
@@ -6,7 +6,7 @@ T = ta.TypeVar('T')
|
|
|
6
6
|
|
|
7
7
|
class OrderedSet(ta.MutableSet[T]):
|
|
8
8
|
|
|
9
|
-
def __init__(self, iterable: ta.
|
|
9
|
+
def __init__(self, iterable: ta.Iterable[T] | None = None) -> None:
|
|
10
10
|
super().__init__()
|
|
11
11
|
self._dct: dict[T, ta.Any] = {}
|
|
12
12
|
if iterable is not None:
|
omlish/collections/skiplist.py
CHANGED
|
@@ -27,7 +27,7 @@ class SkipList(SortedCollection[T]):
|
|
|
27
27
|
def __init__(
|
|
28
28
|
self,
|
|
29
29
|
value: T,
|
|
30
|
-
level: int
|
|
30
|
+
level: int,
|
|
31
31
|
) -> None:
|
|
32
32
|
super().__init__()
|
|
33
33
|
|
|
@@ -46,7 +46,7 @@ class SkipList(SortedCollection[T]):
|
|
|
46
46
|
self,
|
|
47
47
|
*,
|
|
48
48
|
max_height: int = 16,
|
|
49
|
-
comparator:
|
|
49
|
+
comparator: SortedCollection.Comparator[T] | None = None,
|
|
50
50
|
) -> None:
|
|
51
51
|
super().__init__()
|
|
52
52
|
|
|
@@ -108,7 +108,7 @@ class SkipList(SortedCollection[T]):
|
|
|
108
108
|
self._length += 1
|
|
109
109
|
return True
|
|
110
110
|
|
|
111
|
-
def _find(self, value: T) ->
|
|
111
|
+
def _find(self, value: T) -> _Node | None:
|
|
112
112
|
if value is None:
|
|
113
113
|
raise TypeError(value)
|
|
114
114
|
|
|
@@ -120,7 +120,7 @@ class SkipList(SortedCollection[T]):
|
|
|
120
120
|
|
|
121
121
|
return cur.next[0]
|
|
122
122
|
|
|
123
|
-
def find(self, value: T) ->
|
|
123
|
+
def find(self, value: T) -> T | None:
|
|
124
124
|
node = self._find(value)
|
|
125
125
|
if node is None:
|
|
126
126
|
return None
|
|
@@ -157,7 +157,7 @@ class SkipList(SortedCollection[T]):
|
|
|
157
157
|
self._length -= 1
|
|
158
158
|
return True
|
|
159
159
|
|
|
160
|
-
def iter(self, base:
|
|
160
|
+
def iter(self, base: T | None = None) -> ta.Iterable[T]:
|
|
161
161
|
if base is not None:
|
|
162
162
|
cur = self._find(base)
|
|
163
163
|
while cur is not None and self._compare(base, cur.value) > 0: # type: ignore
|
|
@@ -169,7 +169,7 @@ class SkipList(SortedCollection[T]):
|
|
|
169
169
|
yield cur.value # type: ignore
|
|
170
170
|
cur = cur.next[0]
|
|
171
171
|
|
|
172
|
-
def riter(self, base:
|
|
172
|
+
def riter(self, base: T | None = None) -> ta.Iterable[T]:
|
|
173
173
|
if base is not None:
|
|
174
174
|
cur = self._find(base)
|
|
175
175
|
while cur is not self._head and self._compare(base, cur.value) < 0: # type: ignore
|
omlish/collections/sorted.py
CHANGED
|
@@ -38,7 +38,7 @@ class SortedCollection(lang.Abstract, ta.Collection[T]):
|
|
|
38
38
|
raise NotImplementedError
|
|
39
39
|
|
|
40
40
|
@abc.abstractmethod
|
|
41
|
-
def find(self, value: T) ->
|
|
41
|
+
def find(self, value: T) -> T | None:
|
|
42
42
|
raise NotImplementedError
|
|
43
43
|
|
|
44
44
|
@abc.abstractmethod
|
|
@@ -46,11 +46,11 @@ class SortedCollection(lang.Abstract, ta.Collection[T]):
|
|
|
46
46
|
raise NotImplementedError
|
|
47
47
|
|
|
48
48
|
@abc.abstractmethod
|
|
49
|
-
def iter(self, base:
|
|
49
|
+
def iter(self, base: T | None = None) -> ta.Iterable[T]:
|
|
50
50
|
raise NotImplementedError
|
|
51
51
|
|
|
52
52
|
@abc.abstractmethod
|
|
53
|
-
def riter(self, base:
|
|
53
|
+
def riter(self, base: T | None = None) -> ta.Iterable[T]:
|
|
54
54
|
raise NotImplementedError
|
|
55
55
|
|
|
56
56
|
|
omlish/collections/treap.py
CHANGED
|
@@ -65,7 +65,7 @@ class TreapNode(ta.Generic[T]):
|
|
|
65
65
|
yield from self._right
|
|
66
66
|
|
|
67
67
|
|
|
68
|
-
def find(n:
|
|
68
|
+
def find(n: TreapNode[T] | None, v: T, c: Comparer[T]) -> TreapNode[T] | None:
|
|
69
69
|
while True:
|
|
70
70
|
if n is None:
|
|
71
71
|
return None
|
|
@@ -79,11 +79,11 @@ def find(n: ta.Optional[TreapNode[T]], v: T, c: Comparer[T]) -> ta.Optional[Trea
|
|
|
79
79
|
|
|
80
80
|
|
|
81
81
|
def union(
|
|
82
|
-
n:
|
|
83
|
-
other:
|
|
82
|
+
n: TreapNode[T] | None,
|
|
83
|
+
other: TreapNode[T] | None,
|
|
84
84
|
c: Comparer[T],
|
|
85
85
|
overwrite: bool,
|
|
86
|
-
) ->
|
|
86
|
+
) -> TreapNode[T] | None:
|
|
87
87
|
if n is None:
|
|
88
88
|
return other
|
|
89
89
|
if other is None:
|
|
@@ -100,13 +100,13 @@ def union(
|
|
|
100
100
|
|
|
101
101
|
|
|
102
102
|
def split(
|
|
103
|
-
n:
|
|
103
|
+
n: TreapNode[T] | None,
|
|
104
104
|
v: T,
|
|
105
105
|
c: Comparer[T],
|
|
106
106
|
) -> tuple[
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
107
|
+
TreapNode[T] | None,
|
|
108
|
+
TreapNode[T] | None,
|
|
109
|
+
TreapNode[T] | None,
|
|
110
110
|
]:
|
|
111
111
|
tmp: TreapNode[T] = TreapNode(_value=None, _priority=0, _left=None, _right=None) # type: ignore
|
|
112
112
|
leftp, rightp = [tmp, 'l'], [tmp, 'r']
|
|
@@ -120,7 +120,7 @@ def split(
|
|
|
120
120
|
else:
|
|
121
121
|
raise ValueError(p)
|
|
122
122
|
|
|
123
|
-
cur:
|
|
123
|
+
cur: TreapNode[T] | None = n
|
|
124
124
|
while True:
|
|
125
125
|
if cur is None:
|
|
126
126
|
setp(leftp, None)
|
|
@@ -146,10 +146,10 @@ def split(
|
|
|
146
146
|
|
|
147
147
|
|
|
148
148
|
def intersect(
|
|
149
|
-
n:
|
|
150
|
-
other:
|
|
149
|
+
n: TreapNode[T] | None,
|
|
150
|
+
other: TreapNode[T] | None,
|
|
151
151
|
c: Comparer[T],
|
|
152
|
-
) ->
|
|
152
|
+
) -> TreapNode[T] | None:
|
|
153
153
|
if n is None or other is None:
|
|
154
154
|
return None
|
|
155
155
|
|
|
@@ -167,12 +167,12 @@ def intersect(
|
|
|
167
167
|
return TreapNode(_value=n._value, _priority=n._priority, _left=left, _right=right)
|
|
168
168
|
|
|
169
169
|
|
|
170
|
-
def delete(n:
|
|
170
|
+
def delete(n: TreapNode[T] | None, v: T, c: Comparer[T]) -> TreapNode[T] | None:
|
|
171
171
|
left, _, right = split(n, v, c)
|
|
172
172
|
return _join(left, right)
|
|
173
173
|
|
|
174
174
|
|
|
175
|
-
def diff(n:
|
|
175
|
+
def diff(n: TreapNode[T] | None, other: TreapNode[T] | None, c: Comparer[T]) -> TreapNode[T] | None:
|
|
176
176
|
if n is None or other is None:
|
|
177
177
|
return n
|
|
178
178
|
|
|
@@ -190,8 +190,8 @@ def diff(n: ta.Optional[TreapNode[T]], other: ta.Optional[TreapNode[T]], c: Comp
|
|
|
190
190
|
return _join(left, right)
|
|
191
191
|
|
|
192
192
|
|
|
193
|
-
def _join(n:
|
|
194
|
-
result:
|
|
193
|
+
def _join(n: TreapNode[T] | None, other: TreapNode[T] | None) -> TreapNode[T] | None:
|
|
194
|
+
result: TreapNode[T] | None = None
|
|
195
195
|
resultp: list[ta.Any] = [None, None]
|
|
196
196
|
|
|
197
197
|
def setresultp(o):
|
|
@@ -206,7 +206,7 @@ def _join(n: ta.Optional[TreapNode[T]], other: ta.Optional[TreapNode[T]]) -> ta.
|
|
|
206
206
|
else:
|
|
207
207
|
raise ValueError(resultp)
|
|
208
208
|
|
|
209
|
-
cur:
|
|
209
|
+
cur: TreapNode[T] | None = n
|
|
210
210
|
while True:
|
|
211
211
|
if cur is None:
|
|
212
212
|
setresultp(other)
|
omlish/collections/treapmap.py
CHANGED
|
@@ -33,7 +33,7 @@ class TreapMap(PersistentMap[K, V]):
|
|
|
33
33
|
def __init__(
|
|
34
34
|
self,
|
|
35
35
|
*,
|
|
36
|
-
_n:
|
|
36
|
+
_n: treap.TreapNode[tuple[K, V]] | None,
|
|
37
37
|
_c: treap.Comparer[tuple[K, V]],
|
|
38
38
|
) -> None:
|
|
39
39
|
super().__init__()
|
|
@@ -115,7 +115,7 @@ class TreapMapIterator(ta.Generic[K, V]):
|
|
|
115
115
|
self,
|
|
116
116
|
*,
|
|
117
117
|
_st: list[treap.TreapNode[tuple[K, V]]],
|
|
118
|
-
_n:
|
|
118
|
+
_n: treap.TreapNode[tuple[K, V]] | None,
|
|
119
119
|
_b: bool,
|
|
120
120
|
) -> None:
|
|
121
121
|
super().__init__()
|
|
@@ -24,34 +24,34 @@ class UnmodifiableSequence(ta.Sequence[T], Unmodifiable, lang.Final):
|
|
|
24
24
|
def __repr__(self) -> str:
|
|
25
25
|
return '%s(%r)' % (type(self).__name__, self._target)
|
|
26
26
|
|
|
27
|
-
def __contains__(self, x:
|
|
27
|
+
def __contains__(self, x: ta.Any) -> bool:
|
|
28
28
|
return x in self._target
|
|
29
29
|
|
|
30
|
-
def __eq__(self, o:
|
|
30
|
+
def __eq__(self, o: ta.Any) -> bool:
|
|
31
31
|
return self._target == o
|
|
32
32
|
|
|
33
|
-
def __ge__(self, other:
|
|
34
|
-
return self._target >= other
|
|
33
|
+
def __ge__(self, other: ta.Any) -> bool:
|
|
34
|
+
return self._target >= other
|
|
35
35
|
|
|
36
|
-
def __getitem__(self, i:
|
|
36
|
+
def __getitem__(self, i: int | slice) -> T: # type: ignore
|
|
37
37
|
return self._target[i] # type: ignore
|
|
38
38
|
|
|
39
|
-
def __gt__(self, other:
|
|
40
|
-
return self._target > other
|
|
39
|
+
def __gt__(self, other: ta.Any) -> bool:
|
|
40
|
+
return self._target > other
|
|
41
41
|
|
|
42
42
|
def __iter__(self) -> ta.Iterator[T]:
|
|
43
43
|
return iter(self._target)
|
|
44
44
|
|
|
45
|
-
def __le__(self, other:
|
|
46
|
-
return self._target <= other
|
|
45
|
+
def __le__(self, other: ta.Any) -> bool:
|
|
46
|
+
return self._target <= other
|
|
47
47
|
|
|
48
48
|
def __len__(self) -> int:
|
|
49
49
|
return len(self._target)
|
|
50
50
|
|
|
51
|
-
def __lt__(self, other:
|
|
52
|
-
return self._target < other
|
|
51
|
+
def __lt__(self, other: ta.Any) -> bool:
|
|
52
|
+
return self._target < other
|
|
53
53
|
|
|
54
|
-
def __ne__(self, o:
|
|
54
|
+
def __ne__(self, o: ta.Any) -> bool:
|
|
55
55
|
return self._target != o
|
|
56
56
|
|
|
57
57
|
def __reversed__(self) -> ta.Iterator[T]:
|
|
@@ -79,10 +79,10 @@ class UnmodifiableSet(ta.AbstractSet[T], Unmodifiable, lang.Final):
|
|
|
79
79
|
def __and__(self, s: ta.AbstractSet[ta.Any]) -> ta.AbstractSet[T]:
|
|
80
80
|
return self._target & s
|
|
81
81
|
|
|
82
|
-
def __contains__(self, x:
|
|
82
|
+
def __contains__(self, x: ta.Any) -> bool:
|
|
83
83
|
return x in self._target
|
|
84
84
|
|
|
85
|
-
def __eq__(self, o:
|
|
85
|
+
def __eq__(self, o: ta.Any) -> bool:
|
|
86
86
|
return self._target == o
|
|
87
87
|
|
|
88
88
|
def __ge__(self, s: ta.AbstractSet[ta.Any]) -> bool:
|
|
@@ -103,7 +103,7 @@ class UnmodifiableSet(ta.AbstractSet[T], Unmodifiable, lang.Final):
|
|
|
103
103
|
def __lt__(self, s: ta.AbstractSet[ta.Any]) -> bool:
|
|
104
104
|
return self._target > s
|
|
105
105
|
|
|
106
|
-
def __ne__(self, o:
|
|
106
|
+
def __ne__(self, o: ta.Any) -> bool:
|
|
107
107
|
return self._target != o
|
|
108
108
|
|
|
109
109
|
def __or__(self, s: ta.AbstractSet[T]) -> ta.AbstractSet[T]: # type: ignore
|
|
@@ -120,6 +120,7 @@ class UnmodifiableSet(ta.AbstractSet[T], Unmodifiable, lang.Final):
|
|
|
120
120
|
|
|
121
121
|
|
|
122
122
|
class UnmodifiableMapping(ta.Mapping[K, V], Unmodifiable, lang.Final):
|
|
123
|
+
# Could be a MappingProxyType but isn't for consistency with the others.
|
|
123
124
|
|
|
124
125
|
def __init__(self, target: ta.Mapping[K, V]) -> None:
|
|
125
126
|
super().__init__()
|
|
@@ -131,37 +132,37 @@ class UnmodifiableMapping(ta.Mapping[K, V], Unmodifiable, lang.Final):
|
|
|
131
132
|
def __repr__(self) -> str:
|
|
132
133
|
return '%s(%r)' % (type(self).__name__, self._target)
|
|
133
134
|
|
|
134
|
-
def __contains__(self, o:
|
|
135
|
+
def __contains__(self, o: ta.Any) -> bool:
|
|
135
136
|
return o in self._target
|
|
136
137
|
|
|
137
|
-
def __eq__(self, o:
|
|
138
|
+
def __eq__(self, o: ta.Any) -> bool:
|
|
138
139
|
return self._target == o
|
|
139
140
|
|
|
140
|
-
def __ge__(self, other:
|
|
141
|
-
return self._target >= other
|
|
141
|
+
def __ge__(self, other: ta.Any) -> bool:
|
|
142
|
+
return self._target >= other
|
|
142
143
|
|
|
143
144
|
def __getitem__(self, k: K) -> V:
|
|
144
145
|
return self._target[k]
|
|
145
146
|
|
|
146
|
-
def __gt__(self, other:
|
|
147
|
-
return self._target > other
|
|
147
|
+
def __gt__(self, other: ta.Any) -> bool:
|
|
148
|
+
return self._target > other
|
|
148
149
|
|
|
149
150
|
def __iter__(self) -> ta.Iterator[T]:
|
|
150
151
|
return iter(self._target) # type: ignore
|
|
151
152
|
|
|
152
|
-
def __le__(self, other:
|
|
153
|
-
return self._target <= other
|
|
153
|
+
def __le__(self, other: ta.Any) -> bool:
|
|
154
|
+
return self._target <= other
|
|
154
155
|
|
|
155
156
|
def __len__(self) -> int:
|
|
156
157
|
return len(self._target)
|
|
157
158
|
|
|
158
|
-
def __lt__(self, other:
|
|
159
|
-
return self._target < other
|
|
159
|
+
def __lt__(self, other: ta.Any) -> bool:
|
|
160
|
+
return self._target < other
|
|
160
161
|
|
|
161
|
-
def __ne__(self, o:
|
|
162
|
+
def __ne__(self, o: ta.Any) -> bool:
|
|
162
163
|
return self._target != o
|
|
163
164
|
|
|
164
|
-
def get(self, k: K, default=None) ->
|
|
165
|
+
def get(self, k: K, default=None) -> V | None: # type: ignore
|
|
165
166
|
return self._target.get(k)
|
|
166
167
|
|
|
167
168
|
def items(self) -> ta.ItemsView[K, V]:
|
omlish/configs/flattening.py
CHANGED
|
@@ -119,7 +119,7 @@ class Flattening:
|
|
|
119
119
|
def unflatten(self, flattened: StrMap) -> StrMap:
|
|
120
120
|
root = Flattening.UnflattenDict()
|
|
121
121
|
|
|
122
|
-
def split_keys(fkey: str) -> ta.Iterable[
|
|
122
|
+
def split_keys(fkey: str) -> ta.Iterable[str | int]:
|
|
123
123
|
for part in fkey.split(self._delimiter):
|
|
124
124
|
if self._index_open in part:
|
|
125
125
|
check.state(part.endswith(self._index_close))
|
omlish/configs/props.py
CHANGED
|
@@ -19,7 +19,7 @@ def escape(token: str) -> str:
|
|
|
19
19
|
return _ESCAPE_PATTERN.sub(r'\\\1', token)
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
def parse_line(line: str) -> ta.
|
|
22
|
+
def parse_line(line: str) -> ta.Tuple[str, str] | None:
|
|
23
23
|
if line and not (line.startswith('#') or line.startswith('!')):
|
|
24
24
|
match = _SEPARATOR_PATTERN.search(line)
|
|
25
25
|
if match:
|