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.

Files changed (102) hide show
  1. omlish/__about__.py +2 -2
  2. omlish/argparse.py +4 -4
  3. omlish/asyncs/anyio.py +62 -1
  4. omlish/asyncs/futures.py +6 -6
  5. omlish/c3.py +4 -4
  6. omlish/check.py +6 -6
  7. omlish/collections/__init__.py +98 -63
  8. omlish/collections/cache/descriptor.py +5 -5
  9. omlish/collections/cache/impl.py +4 -4
  10. omlish/collections/coerce.py +43 -43
  11. omlish/collections/frozen.py +3 -3
  12. omlish/collections/identity.py +1 -1
  13. omlish/collections/mappings.py +3 -3
  14. omlish/collections/ordered.py +1 -1
  15. omlish/collections/skiplist.py +6 -6
  16. omlish/collections/sorted.py +3 -3
  17. omlish/collections/treap.py +17 -17
  18. omlish/collections/treapmap.py +2 -2
  19. omlish/collections/unmodifiable.py +28 -27
  20. omlish/configs/flattening.py +1 -1
  21. omlish/configs/props.py +1 -1
  22. omlish/dataclasses/impl/__init__.py +2 -0
  23. omlish/dataclasses/impl/api.py +5 -13
  24. omlish/dataclasses/impl/fields.py +1 -1
  25. omlish/dataclasses/impl/init.py +1 -1
  26. omlish/dataclasses/impl/internals.py +15 -0
  27. omlish/dataclasses/impl/main.py +4 -4
  28. omlish/dataclasses/impl/metaclass.py +1 -1
  29. omlish/dataclasses/impl/metadata.py +1 -1
  30. omlish/dataclasses/impl/order.py +1 -1
  31. omlish/dataclasses/impl/params.py +4 -38
  32. omlish/dataclasses/impl/reflect.py +1 -7
  33. omlish/dataclasses/impl/repr.py +23 -5
  34. omlish/dataclasses/impl/simple.py +2 -2
  35. omlish/dataclasses/impl/slots.py +2 -2
  36. omlish/dataclasses/impl/utils.py +4 -4
  37. omlish/dispatch/dispatch.py +9 -8
  38. omlish/dispatch/methods.py +2 -2
  39. omlish/docker.py +8 -6
  40. omlish/dynamic.py +5 -5
  41. omlish/graphs/dot/items.py +1 -1
  42. omlish/graphs/trees.py +15 -21
  43. omlish/inject/elements.py +1 -1
  44. omlish/inject/exceptions.py +1 -1
  45. omlish/inject/impl/injector.py +1 -1
  46. omlish/inject/impl/inspect.py +1 -1
  47. omlish/inject/injector.py +1 -1
  48. omlish/inject/providers.py +2 -2
  49. omlish/iterators.py +43 -2
  50. omlish/lang/__init__.py +167 -112
  51. omlish/lang/cached.py +13 -5
  52. omlish/lang/classes/__init__.py +35 -24
  53. omlish/lang/classes/abstract.py +1 -1
  54. omlish/lang/classes/simple.py +1 -1
  55. omlish/lang/clsdct.py +1 -1
  56. omlish/lang/contextmanagers.py +23 -15
  57. omlish/lang/datetimes.py +1 -1
  58. omlish/lang/descriptors.py +35 -2
  59. omlish/lang/exceptions.py +2 -0
  60. omlish/lang/functions.py +43 -13
  61. omlish/lang/imports.py +8 -8
  62. omlish/lang/iterables.py +1 -1
  63. omlish/lang/maybes.py +1 -1
  64. omlish/lang/objects.py +2 -2
  65. omlish/lang/timeouts.py +53 -0
  66. omlish/lang/typing.py +2 -2
  67. omlish/libc.py +6 -6
  68. omlish/marshal/base.py +6 -6
  69. omlish/marshal/dataclasses.py +2 -2
  70. omlish/marshal/enums.py +2 -2
  71. omlish/marshal/factories.py +10 -10
  72. omlish/marshal/iterables.py +2 -2
  73. omlish/marshal/mappings.py +2 -2
  74. omlish/marshal/optionals.py +4 -4
  75. omlish/marshal/polymorphism.py +4 -4
  76. omlish/marshal/standard.py +6 -6
  77. omlish/marshal/utils.py +1 -1
  78. omlish/os.py +13 -4
  79. omlish/procfs.py +336 -0
  80. omlish/reflect.py +2 -12
  81. omlish/replserver/console.py +9 -9
  82. omlish/replserver/server.py +4 -4
  83. omlish/sql/__init__.py +0 -0
  84. omlish/sql/_abcs.py +65 -0
  85. omlish/sql/dbs.py +90 -0
  86. omlish/stats.py +3 -3
  87. omlish/testing/pydevd.py +4 -6
  88. omlish/testing/pytest/inject/__init__.py +7 -0
  89. omlish/testing/pytest/inject/harness.py +23 -1
  90. omlish/testing/pytest/plugins/__init__.py +1 -1
  91. omlish/testing/pytest/plugins/pydevd.py +12 -0
  92. omlish/testing/pytest/plugins/switches.py +2 -2
  93. omlish/testing/testing.py +5 -5
  94. omlish/text/parts.py +3 -3
  95. omlish-0.0.0.dev2.dist-info/METADATA +31 -0
  96. omlish-0.0.0.dev2.dist-info/RECORD +193 -0
  97. {omlish-0.0.0.dev1.dist-info → omlish-0.0.0.dev2.dist-info}/WHEEL +1 -1
  98. omlish/testing/pytest/plugins/pycharm.py +0 -54
  99. omlish-0.0.0.dev1.dist-info/METADATA +0 -17
  100. omlish-0.0.0.dev1.dist-info/RECORD +0 -187
  101. {omlish-0.0.0.dev1.dist-info → omlish-0.0.0.dev2.dist-info}/LICENSE +0 -0
  102. {omlish-0.0.0.dev1.dist-info → omlish-0.0.0.dev2.dist-info}/top_level.txt +0 -0
@@ -39,8 +39,8 @@ def seq(
39
39
 
40
40
 
41
41
  def opt_seq(
42
- it: ta.Optional[ta.Iterable[T]],
43
- ) -> ta.Optional[ta.Sequence[T]]:
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.Optional[ta.Iterable[T]],
52
- ) -> ta.Optional[ta.Sequence[T]]:
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.Union[ta.Callable[[T], T2], tuple],
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.Union[ta.Callable[[T], T2], tuple],
72
- ) -> ta.Callable[[ta.Optional[ta.Iterable[T]]], ta.Optional[ta.Sequence[T2]]]:
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.Union[ta.Callable[[T], T2], tuple],
85
- ) -> ta.Callable[[ta.Optional[ta.Iterable[T]]], ta.Optional[ta.Sequence[T2]]]:
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.Optional[ta.Iterable[T]],
119
- ) -> ta.Optional[ta.AbstractSet[T]]:
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.Optional[ta.Iterable[T]],
128
- ) -> ta.Optional[ta.AbstractSet[T]]:
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.Union[ta.Callable[[T], T2], tuple],
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.Union[ta.Callable[[T], T2], tuple],
148
- ) -> ta.Callable[[ta.Optional[ta.Iterable[T]]], ta.Optional[ta.AbstractSet[T2]]]:
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.Union[ta.Callable[[T], T2], tuple],
161
- ) -> ta.Callable[[ta.Optional[ta.Iterable[T]]], ta.Optional[ta.AbstractSet[T2]]]:
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.Optional[ta.Iterable[T]],
195
- ) -> ta.Optional[frozenset[T]]:
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.Optional[ta.Iterable[T]],
204
- ) -> ta.Optional[frozenset[T]]:
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.Union[ta.Callable[[T], T2], tuple],
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.Union[ta.Callable[[T], T2], tuple],
224
- ) -> ta.Callable[[ta.Optional[ta.Iterable[T]]], ta.Optional[frozenset[T2]]]:
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.Union[ta.Callable[[T], T2], tuple],
237
- ) -> ta.Callable[[ta.Optional[ta.Iterable[T]]], ta.Optional[frozenset[T2]]]:
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.Union[ta.Mapping[K, V], ta.Iterable[tuple[K, V]]],
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.Optional[ta.Union[ta.Mapping[K, V], ta.Iterable[tuple[K, V]]]],
266
- ) -> ta.Optional[ta.Mapping[K, V]]:
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.Optional[ta.Union[ta.Mapping[K, V], ta.Iterable[tuple[K, V]]]],
275
- ) -> ta.Optional[ta.Mapping[K, V]]:
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.Union[ta.Callable[[K], K2], tuple],
285
- value_fn: ta.Union[ta.Callable[[V], V2], tuple],
284
+ key_fn: ta.Callable[[K], K2] | tuple,
285
+ value_fn: ta.Callable[[V], V2] | tuple,
286
286
  ) -> ta.Callable[
287
- [ta.Union[ta.Mapping[K, V], ta.Iterable[tuple[K, V]]]],
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.Union[ta.Callable[[K], K2], tuple],
300
- value_fn: ta.Union[ta.Callable[[V], V2], tuple],
299
+ key_fn: ta.Callable[[K], K2] | tuple,
300
+ value_fn: ta.Callable[[V], V2] | tuple,
301
301
  ) -> ta.Callable[
302
- [ta.Optional[ta.Union[ta.Mapping[K, V], ta.Iterable[tuple[K, V]]]]],
303
- ta.Optional[ta.Mapping[K2, V2]],
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.Union[ta.Callable[[K], K2], tuple],
318
- value_fn: ta.Union[ta.Callable[[V], V2], tuple],
317
+ key_fn: ta.Callable[[K], K2] | tuple,
318
+ value_fn: ta.Callable[[V], V2] | tuple,
319
319
  ) -> ta.Callable[
320
- [ta.Optional[ta.Union[ta.Mapping[K, V], ta.Iterable[tuple[K, V]]]]],
321
- ta.Optional[ta.Mapping[K2, V2]],
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:
@@ -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.Optional[ta.Iterable[T]] = None) -> None:
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: ta.Optional[int] = None
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: ta.Union[int, slice]) -> 'FrozenList[T]': # type: ignore
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:
@@ -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.Optional[ta.Iterable[T]] = None) -> None:
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:
@@ -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.Union[ta.Iterable[K], K], V], *, deep: bool = False) -> dict[K, V]:
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]) -> ta.Optional[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]:
@@ -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.Optional[ta.Iterable[T]] = None) -> None:
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:
@@ -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: ta.Optional[SortedCollection.Comparator[T]] = None,
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) -> ta.Optional[_Node]:
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) -> ta.Optional[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: ta.Optional[T] = None) -> ta.Iterable[T]:
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: ta.Optional[T] = None) -> ta.Iterable[T]:
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
@@ -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) -> ta.Optional[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: ta.Optional[T] = None) -> ta.Iterable[T]:
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: ta.Optional[T] = None) -> ta.Iterable[T]:
53
+ def riter(self, base: T | None = None) -> ta.Iterable[T]:
54
54
  raise NotImplementedError
55
55
 
56
56
 
@@ -65,7 +65,7 @@ class TreapNode(ta.Generic[T]):
65
65
  yield from self._right
66
66
 
67
67
 
68
- def find(n: ta.Optional[TreapNode[T]], v: T, c: Comparer[T]) -> ta.Optional[TreapNode[T]]:
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: ta.Optional[TreapNode[T]],
83
- other: ta.Optional[TreapNode[T]],
82
+ n: TreapNode[T] | None,
83
+ other: TreapNode[T] | None,
84
84
  c: Comparer[T],
85
85
  overwrite: bool,
86
- ) -> ta.Optional[TreapNode[T]]:
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: ta.Optional[TreapNode[T]],
103
+ n: TreapNode[T] | None,
104
104
  v: T,
105
105
  c: Comparer[T],
106
106
  ) -> tuple[
107
- ta.Optional[TreapNode[T]],
108
- ta.Optional[TreapNode[T]],
109
- ta.Optional[TreapNode[T]],
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: ta.Optional[TreapNode[T]] = n
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: ta.Optional[TreapNode[T]],
150
- other: ta.Optional[TreapNode[T]],
149
+ n: TreapNode[T] | None,
150
+ other: TreapNode[T] | None,
151
151
  c: Comparer[T],
152
- ) -> ta.Optional[TreapNode[T]]:
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: ta.Optional[TreapNode[T]], v: T, c: Comparer[T]) -> ta.Optional[TreapNode[T]]:
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: ta.Optional[TreapNode[T]], other: ta.Optional[TreapNode[T]], c: Comparer[T]) -> ta.Optional[TreapNode[T]]:
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: ta.Optional[TreapNode[T]], other: ta.Optional[TreapNode[T]]) -> ta.Optional[TreapNode[T]]:
194
- result: ta.Optional[TreapNode[T]] = None
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: ta.Optional[TreapNode[T]] = n
209
+ cur: TreapNode[T] | None = n
210
210
  while True:
211
211
  if cur is None:
212
212
  setresultp(other)
@@ -33,7 +33,7 @@ class TreapMap(PersistentMap[K, V]):
33
33
  def __init__(
34
34
  self,
35
35
  *,
36
- _n: ta.Optional[treap.TreapNode[tuple[K, V]]],
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: ta.Optional[treap.TreapNode[tuple[K, V]]],
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: object) -> bool:
27
+ def __contains__(self, x: ta.Any) -> bool:
28
28
  return x in self._target
29
29
 
30
- def __eq__(self, o: object) -> bool:
30
+ def __eq__(self, o: ta.Any) -> bool:
31
31
  return self._target == o
32
32
 
33
- def __ge__(self, other: object) -> bool:
34
- return self._target >= other # type: ignore
33
+ def __ge__(self, other: ta.Any) -> bool:
34
+ return self._target >= other
35
35
 
36
- def __getitem__(self, i: ta.Union[int, slice]) -> T: # type: ignore
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: object) -> bool:
40
- return self._target > other # type: ignore
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: object) -> bool:
46
- return self._target <= other # type: ignore
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: object) -> bool:
52
- return self._target < other # type: ignore
51
+ def __lt__(self, other: ta.Any) -> bool:
52
+ return self._target < other
53
53
 
54
- def __ne__(self, o: object) -> bool:
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: object) -> bool:
82
+ def __contains__(self, x: ta.Any) -> bool:
83
83
  return x in self._target
84
84
 
85
- def __eq__(self, o: object) -> bool:
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: object) -> bool:
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: object) -> bool:
135
+ def __contains__(self, o: ta.Any) -> bool:
135
136
  return o in self._target
136
137
 
137
- def __eq__(self, o: object) -> bool:
138
+ def __eq__(self, o: ta.Any) -> bool:
138
139
  return self._target == o
139
140
 
140
- def __ge__(self, other: object) -> bool:
141
- return self._target >= other # type: ignore
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: object) -> bool:
147
- return self._target > other # type: ignore
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: object) -> bool:
153
- return self._target <= other # type: ignore
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: object) -> bool:
159
- return self._target < other # type: ignore
159
+ def __lt__(self, other: ta.Any) -> bool:
160
+ return self._target < other
160
161
 
161
- def __ne__(self, o: object) -> bool:
162
+ def __ne__(self, o: ta.Any) -> bool:
162
163
  return self._target != o
163
164
 
164
- def get(self, k: K, default=None) -> ta.Optional[V]: # type: ignore
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]:
@@ -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[ta.Union[str, int]]:
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.Optional[ta.Tuple[str, str]]:
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:
@@ -3,4 +3,6 @@ TODO:
3
3
  - metaclass:
4
4
  - cleanup confer
5
5
  - descriptors - check_type/validators don't handle setters lol
6
+ - deep_frozen?
7
+ - repr='redact', 'if_not_none', 'if_truthy', dc.if_(lambda v: ...)? just a lambda returning str | None?
6
8
  """