datahold 4.0.0.dev21__tar.gz → 4.0.0.dev22__tar.gz
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.
- {datahold-4.0.0.dev21 → datahold-4.0.0.dev22}/PKG-INFO +2 -1
- {datahold-4.0.0.dev21 → datahold-4.0.0.dev22}/pyproject.toml +3 -2
- {datahold-4.0.0.dev21 → datahold-4.0.0.dev22}/src/datahold/__init__.py +280 -46
- {datahold-4.0.0.dev21 → datahold-4.0.0.dev22}/src/datahold.egg-info/PKG-INFO +2 -1
- datahold-4.0.0.dev22/src/datahold.egg-info/requires.txt +2 -0
- {datahold-4.0.0.dev21 → datahold-4.0.0.dev22}/tests/testdata.toml +35 -6
- datahold-4.0.0.dev21/src/datahold.egg-info/requires.txt +0 -1
- {datahold-4.0.0.dev21 → datahold-4.0.0.dev22}/LICENSE.txt +0 -0
- {datahold-4.0.0.dev21 → datahold-4.0.0.dev22}/MANIFEST.in +0 -0
- {datahold-4.0.0.dev21 → datahold-4.0.0.dev22}/README.rst +0 -0
- {datahold-4.0.0.dev21 → datahold-4.0.0.dev22}/docs/v1.1.rst +0 -0
- {datahold-4.0.0.dev21 → datahold-4.0.0.dev22}/docs/v1.2.rst +0 -0
- {datahold-4.0.0.dev21 → datahold-4.0.0.dev22}/docs/v2.0.rst +0 -0
- {datahold-4.0.0.dev21 → datahold-4.0.0.dev22}/docs/v2.1.rst +0 -0
- {datahold-4.0.0.dev21 → datahold-4.0.0.dev22}/docs/v2.2.rst +0 -0
- {datahold-4.0.0.dev21 → datahold-4.0.0.dev22}/docs/v2.3.rst +0 -0
- {datahold-4.0.0.dev21 → datahold-4.0.0.dev22}/docs/v3.0.rst +0 -0
- {datahold-4.0.0.dev21 → datahold-4.0.0.dev22}/docs/v4.0.rst +0 -0
- {datahold-4.0.0.dev21 → datahold-4.0.0.dev22}/run_tests.py +0 -0
- {datahold-4.0.0.dev21 → datahold-4.0.0.dev22}/setup.cfg +0 -0
- {datahold-4.0.0.dev21 → datahold-4.0.0.dev22}/src/datahold/py.typed +0 -0
- {datahold-4.0.0.dev21 → datahold-4.0.0.dev22}/src/datahold.egg-info/SOURCES.txt +0 -0
- {datahold-4.0.0.dev21 → datahold-4.0.0.dev22}/src/datahold.egg-info/dependency_links.txt +0 -0
- {datahold-4.0.0.dev21 → datahold-4.0.0.dev22}/src/datahold.egg-info/top_level.txt +0 -0
- {datahold-4.0.0.dev21 → datahold-4.0.0.dev22}/tests/test_FrozenListSlot.py +0 -0
- {datahold-4.0.0.dev21 → datahold-4.0.0.dev22}/tests/test_MutableListHold.py +0 -0
- {datahold-4.0.0.dev21 → datahold-4.0.0.dev22}/tests/test_abstractmethods.py +0 -0
- {datahold-4.0.0.dev21 → datahold-4.0.0.dev22}/tests/test_all.py +0 -0
- {datahold-4.0.0.dev21 → datahold-4.0.0.dev22}/tests/test_attributes.py +0 -0
- {datahold-4.0.0.dev21 → datahold-4.0.0.dev22}/tests/test_docs.py +0 -0
- {datahold-4.0.0.dev21 → datahold-4.0.0.dev22}/tests/test_generic.py +0 -0
- {datahold-4.0.0.dev21 → datahold-4.0.0.dev22}/tests/test_internal_comparison.py +0 -0
- {datahold-4.0.0.dev21 → datahold-4.0.0.dev22}/tests/test_issubclass.py +0 -0
- {datahold-4.0.0.dev21 → datahold-4.0.0.dev22}/tests/test_nested.py +0 -0
- {datahold-4.0.0.dev21 → datahold-4.0.0.dev22}/tests/test_prefix.py +0 -0
- {datahold-4.0.0.dev21 → datahold-4.0.0.dev22}/tests/test_sorted.py +0 -0
- {datahold-4.0.0.dev21 → datahold-4.0.0.dev22}/tests/test_variance.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: datahold
|
|
3
|
-
Version: 4.0.0.
|
|
3
|
+
Version: 4.0.0.dev22
|
|
4
4
|
Summary: This project wraps common mutable datastructures for inheritance with modification.
|
|
5
5
|
Author-email: Johannes <johannes.programming@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -19,6 +19,7 @@ Classifier: Typing :: Typed
|
|
|
19
19
|
Requires-Python: >=3.11
|
|
20
20
|
Description-Content-Type: text/x-rst
|
|
21
21
|
License-File: LICENSE.txt
|
|
22
|
+
Requires-Dist: frozendict<3,>=2.4.7
|
|
22
23
|
Requires-Dist: setdoc<2,>=1.3.24
|
|
23
24
|
Dynamic: license-file
|
|
24
25
|
|
|
@@ -19,6 +19,7 @@ classifiers = [
|
|
|
19
19
|
"Typing :: Typed",
|
|
20
20
|
]
|
|
21
21
|
dependencies = [
|
|
22
|
+
"frozendict>=2.4.7,<3",
|
|
22
23
|
"setdoc>=1.3.24,<2",
|
|
23
24
|
]
|
|
24
25
|
description = "This project wraps common mutable datastructures for inheritance with modification."
|
|
@@ -30,7 +31,7 @@ license-files = [
|
|
|
30
31
|
name = "datahold"
|
|
31
32
|
readme = "README.rst"
|
|
32
33
|
requires-python = ">=3.11"
|
|
33
|
-
version = "4.0.0.
|
|
34
|
+
version = "4.0.0.dev22"
|
|
34
35
|
|
|
35
36
|
[project.urls]
|
|
36
37
|
Download = "https://pypi.org/project/datahold/#files"
|
|
@@ -42,5 +43,5 @@ Website = "http://datahold.johannes-programming.online/"
|
|
|
42
43
|
files = [
|
|
43
44
|
".",
|
|
44
45
|
]
|
|
45
|
-
python_version = "3.
|
|
46
|
+
python_version = "3.12"
|
|
46
47
|
strict = true
|
|
@@ -4,14 +4,22 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
__all__: list[str] = [
|
|
6
6
|
"Collection",
|
|
7
|
+
"DictLike",
|
|
8
|
+
"DictSlot",
|
|
9
|
+
"FrozenDictLike",
|
|
10
|
+
"FrozenDictSlot",
|
|
7
11
|
"FrozenListLike",
|
|
8
12
|
"FrozenListSlot",
|
|
9
13
|
"FrozenSetLike",
|
|
10
14
|
"FrozenSetSlot",
|
|
11
15
|
"ListLike",
|
|
12
16
|
"ListSlot",
|
|
17
|
+
"Mapping",
|
|
18
|
+
"MutableDictLike",
|
|
19
|
+
"MutableDictSlot",
|
|
13
20
|
"MutableListLike",
|
|
14
21
|
"MutableListSlot",
|
|
22
|
+
"MutableMapping",
|
|
15
23
|
"MutableSequence",
|
|
16
24
|
"MutableSet",
|
|
17
25
|
"MutableSetLike",
|
|
@@ -37,6 +45,7 @@ from typing import (
|
|
|
37
45
|
)
|
|
38
46
|
|
|
39
47
|
import setdoc
|
|
48
|
+
from frozendict import frozendict
|
|
40
49
|
|
|
41
50
|
### UTILS ###
|
|
42
51
|
|
|
@@ -57,6 +66,20 @@ class ContextManager[Enter](Protocol):
|
|
|
57
66
|
) -> object: ...
|
|
58
67
|
|
|
59
68
|
|
|
69
|
+
class SupportsKeysAndGetitem[Key, Value](Protocol):
|
|
70
|
+
"""Provide protocol supporting keys and __getitem__."""
|
|
71
|
+
|
|
72
|
+
@setdoc.basic
|
|
73
|
+
def __getitem__(self: Self, key: Key, /) -> Value: ...
|
|
74
|
+
@setdoc.basic
|
|
75
|
+
def keys(self: Self, /) -> abc.Iterable[Key]: ...
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
type DictInit[Key, Value] = (
|
|
79
|
+
SupportsKeysAndGetitem[Key | str, Optional[Value]]
|
|
80
|
+
| abc.Iterable[tuple[Key | str, Optional[Value]]]
|
|
81
|
+
)
|
|
82
|
+
|
|
60
83
|
type Slice[Index] = slice[Optional[Index], Optional[Index], Optional[Index]]
|
|
61
84
|
|
|
62
85
|
|
|
@@ -68,12 +91,12 @@ class Collection[Item](
|
|
|
68
91
|
abc.Iterable[Item],
|
|
69
92
|
abc.Container[object],
|
|
70
93
|
):
|
|
71
|
-
"""Provide abc for custom
|
|
94
|
+
"""Provide abc for custom collection."""
|
|
72
95
|
|
|
73
96
|
@setdoc.basic
|
|
74
|
-
class __Frozen__[
|
|
97
|
+
class __Frozen__[Item_](
|
|
75
98
|
abc.Sized,
|
|
76
|
-
abc.Iterable[
|
|
99
|
+
abc.Iterable[Item_],
|
|
77
100
|
Protocol,
|
|
78
101
|
):
|
|
79
102
|
@setdoc.basic
|
|
@@ -114,9 +137,9 @@ class MutableSet[Item: abc.Hashable](Set[Item], abc.MutableSet[Item]):
|
|
|
114
137
|
__slots__ = ()
|
|
115
138
|
|
|
116
139
|
@setdoc.basic
|
|
117
|
-
class __Mutable__[
|
|
140
|
+
class __Mutable__[Item_: abc.Hashable](Protocol):
|
|
118
141
|
@setdoc.basic
|
|
119
|
-
def add(self: Self, item:
|
|
142
|
+
def add(self: Self, item: Item_, /) -> object: ...
|
|
120
143
|
@setdoc.basic
|
|
121
144
|
def discard(self: Self, item: abc.Hashable, /) -> object: ...
|
|
122
145
|
@abstractmethod
|
|
@@ -140,15 +163,14 @@ class SetLike[Item: abc.Hashable](Set[Item]):
|
|
|
140
163
|
"""Provide abc for custom set-like."""
|
|
141
164
|
|
|
142
165
|
__slots__ = ()
|
|
143
|
-
type __Frozen__[
|
|
144
|
-
type Init[FrozenItem] = abc.Iterable[FrozenItem]
|
|
166
|
+
type __Frozen__[Item_] = frozenset[Item_]
|
|
145
167
|
|
|
146
168
|
@abstractmethod
|
|
147
169
|
@setdoc.basic
|
|
148
170
|
def __frozen__(self: Self, /) -> __Frozen__[Item]: ...
|
|
149
171
|
@abstractmethod
|
|
150
172
|
@setdoc.basic
|
|
151
|
-
def __init__(self: Self, data:
|
|
173
|
+
def __init__(self: Self, data: abc.Iterable[Item] = (), /) -> None: ...
|
|
152
174
|
@setdoc.basic
|
|
153
175
|
def difference(self: Self, /, *others: abc.Iterable[abc.Hashable]) -> Self:
|
|
154
176
|
return type(self)(self.__frozen__().difference(*others))
|
|
@@ -190,8 +212,7 @@ class MutableSetLike[Item: abc.Hashable](SetLike[Item], MutableSet[Item]):
|
|
|
190
212
|
"""Provide abc for custom mutable set-like."""
|
|
191
213
|
|
|
192
214
|
__slots__ = ()
|
|
193
|
-
|
|
194
|
-
type __Mutable__[MutableItem] = set[MutableItem]
|
|
215
|
+
type __Mutable__[Item_] = set[Item_]
|
|
195
216
|
|
|
196
217
|
@setdoc.basic
|
|
197
218
|
def __frozen__(self: Self, /) -> MutableSetLike.__Frozen__[Item]:
|
|
@@ -200,7 +221,7 @@ class MutableSetLike[Item: abc.Hashable](SetLike[Item], MutableSet[Item]):
|
|
|
200
221
|
|
|
201
222
|
@abstractmethod
|
|
202
223
|
@setdoc.basic
|
|
203
|
-
def __init__(self: Self, data:
|
|
224
|
+
def __init__(self: Self, data: abc.Iterable[Item] = (), /) -> None:
|
|
204
225
|
with self.__mutate__() as mutable:
|
|
205
226
|
mutable.update(data)
|
|
206
227
|
|
|
@@ -255,7 +276,7 @@ class FrozenSetSlot[Item](SetSlot[Item], FrozenSetLike[Item]):
|
|
|
255
276
|
__slots__ = ()
|
|
256
277
|
|
|
257
278
|
@setdoc.basic
|
|
258
|
-
def __init__(self: Self, data:
|
|
279
|
+
def __init__(self: Self, data: abc.Iterable[Item] = (), /) -> None:
|
|
259
280
|
self._slot = frozenset(data)
|
|
260
281
|
|
|
261
282
|
|
|
@@ -272,38 +293,260 @@ class MutableSetSlot[Item](SetSlot[Item], MutableSetLike[Item]):
|
|
|
272
293
|
self._slot = frozenset(slot)
|
|
273
294
|
|
|
274
295
|
|
|
296
|
+
### MAPPING ###
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
class Mapping[Key: abc.Hashable, Value](
|
|
300
|
+
Collection[Key],
|
|
301
|
+
abc.Mapping[Key, Value],
|
|
302
|
+
):
|
|
303
|
+
"""Provide abc for custom mapping."""
|
|
304
|
+
|
|
305
|
+
__slots__ = ()
|
|
306
|
+
|
|
307
|
+
@setdoc.basic
|
|
308
|
+
class __Frozen__[FrozenKey, FrozenValue](
|
|
309
|
+
Collection.__Frozen__[FrozenKey], Protocol
|
|
310
|
+
):
|
|
311
|
+
@setdoc.basic
|
|
312
|
+
def __getitem__(self: Self, key: abc.Hashable, /) -> FrozenValue: ...
|
|
313
|
+
@abstractmethod
|
|
314
|
+
@setdoc.basic
|
|
315
|
+
def __frozen__(self: Self, /) -> __Frozen__[Key, Value]: ...
|
|
316
|
+
@setdoc.basic
|
|
317
|
+
def __getitem__(self: Self, key: abc.Hashable, /) -> Value:
|
|
318
|
+
return self.__frozen__()[key]
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
class MutableMapping[Key: abc.Hashable, Value](
|
|
322
|
+
Mapping[Key, Value],
|
|
323
|
+
abc.MutableMapping[Key | str, Optional[Value]],
|
|
324
|
+
):
|
|
325
|
+
"""Provide abc for custom mutable mapping."""
|
|
326
|
+
|
|
327
|
+
__slots__ = ()
|
|
328
|
+
|
|
329
|
+
@setdoc.basic
|
|
330
|
+
class __Mutable__[Key_, Value_](
|
|
331
|
+
Protocol,
|
|
332
|
+
):
|
|
333
|
+
@setdoc.basic
|
|
334
|
+
def __delitem__(self: Self, key: Key_ | str, /) -> object: ...
|
|
335
|
+
@setdoc.basic
|
|
336
|
+
def __setitem__(
|
|
337
|
+
self: Self, key: Key_ | str, value: Optional[Value_], /
|
|
338
|
+
) -> object: ...
|
|
339
|
+
|
|
340
|
+
@setdoc.basic
|
|
341
|
+
def __delitem__(self: Self, key: Key | str, /) -> None:
|
|
342
|
+
with self.__mutate__() as mutable:
|
|
343
|
+
del mutable[key]
|
|
344
|
+
|
|
345
|
+
@abstractmethod
|
|
346
|
+
@setdoc.basic
|
|
347
|
+
def __mutate__(self: Self) -> ContextManager[__Mutable__[Key, Value]]: ...
|
|
348
|
+
@setdoc.basic
|
|
349
|
+
def __setitem__(
|
|
350
|
+
self: Self, key: Key | str, value: Optional[Value], /
|
|
351
|
+
) -> None:
|
|
352
|
+
self[key] = value
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
### DICT-LIKE ###
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
class DictLike[Key: abc.Hashable, Value](
|
|
359
|
+
Mapping[Key | str, Optional[Value]],
|
|
360
|
+
):
|
|
361
|
+
"""Provide abc for custom dict-like."""
|
|
362
|
+
|
|
363
|
+
__slots__ = ()
|
|
364
|
+
type __Frozen__[FrozenKey, FrozenValue] = frozendict[
|
|
365
|
+
FrozenKey | str, Optional[FrozenValue]
|
|
366
|
+
]
|
|
367
|
+
|
|
368
|
+
@abstractmethod
|
|
369
|
+
@setdoc.basic
|
|
370
|
+
def __frozen__(self: Self, /) -> __Frozen__[Key, Value]: ... # type: ignore[override]
|
|
371
|
+
@abstractmethod
|
|
372
|
+
@setdoc.basic
|
|
373
|
+
def __init__(
|
|
374
|
+
self: Self,
|
|
375
|
+
data: DictInit[Key, Value] = (),
|
|
376
|
+
/,
|
|
377
|
+
**kwargs: Value,
|
|
378
|
+
): ...
|
|
379
|
+
@setdoc.basic
|
|
380
|
+
def __or__[Key_, Value_](
|
|
381
|
+
self: Self,
|
|
382
|
+
other: DictInit[Key_, Value_],
|
|
383
|
+
/,
|
|
384
|
+
) -> DictLike[Key | Key_, Value | Value_]:
|
|
385
|
+
data: DictLike.__Frozen__[Key_, Value_]
|
|
386
|
+
try:
|
|
387
|
+
data = frozendict(other) # type: ignore[arg-type]
|
|
388
|
+
except TypeError:
|
|
389
|
+
return NotImplemented
|
|
390
|
+
return type(self)( # type: ignore[return-value]
|
|
391
|
+
self.__frozen__() | data # type: ignore[operator]
|
|
392
|
+
)
|
|
393
|
+
|
|
394
|
+
@classmethod
|
|
395
|
+
@setdoc.basic
|
|
396
|
+
def fromkeys(
|
|
397
|
+
cls: type[Self],
|
|
398
|
+
iterable: abc.Iterable[Key | str],
|
|
399
|
+
value: Optional[Value],
|
|
400
|
+
/,
|
|
401
|
+
) -> Self:
|
|
402
|
+
return cls(dict.fromkeys(iterable, value))
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
class FrozenDictLike[Key: abc.Hashable, Value](
|
|
406
|
+
DictLike[Key, Value],
|
|
407
|
+
abc.Hashable,
|
|
408
|
+
):
|
|
409
|
+
"""Provide abc for custom frozen dict-like."""
|
|
410
|
+
|
|
411
|
+
__slots__ = ()
|
|
412
|
+
|
|
413
|
+
@setdoc.basic
|
|
414
|
+
def __hash__(self: Self, /) -> int:
|
|
415
|
+
return hash(self.__frozen__())
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
class MutableDictLike[Key: abc.Hashable, Value](
|
|
419
|
+
DictLike[Key, Value],
|
|
420
|
+
MutableMapping[Key, Value],
|
|
421
|
+
):
|
|
422
|
+
"""Provide abc for custom mutable dict-like."""
|
|
423
|
+
|
|
424
|
+
__slots__ = ()
|
|
425
|
+
type __Mutable__[Key_: abc.Hashable, Value_] = dict[
|
|
426
|
+
Key_ | str, Optional[Value_]
|
|
427
|
+
]
|
|
428
|
+
|
|
429
|
+
@setdoc.basic
|
|
430
|
+
def __frozen__( # type: ignore[override]
|
|
431
|
+
self: Self,
|
|
432
|
+
/,
|
|
433
|
+
) -> MutableDictLike.__Frozen__[Key, Value]:
|
|
434
|
+
with self.__mutate__() as mutable:
|
|
435
|
+
return frozendict(mutable)
|
|
436
|
+
|
|
437
|
+
@setdoc.basic
|
|
438
|
+
def __init__(
|
|
439
|
+
self: Self,
|
|
440
|
+
data: DictInit[Key, Value] = (),
|
|
441
|
+
/,
|
|
442
|
+
**kwargs: Optional[Value],
|
|
443
|
+
):
|
|
444
|
+
self.update(data, **kwargs)
|
|
445
|
+
|
|
446
|
+
@setdoc.basic
|
|
447
|
+
def __ior__( # type: ignore[override]
|
|
448
|
+
self: Self,
|
|
449
|
+
other: DictInit[Key, Value],
|
|
450
|
+
/,
|
|
451
|
+
) -> Self:
|
|
452
|
+
with self.__mutate__() as mutable:
|
|
453
|
+
mutable |= other
|
|
454
|
+
return self
|
|
455
|
+
|
|
456
|
+
@abstractmethod
|
|
457
|
+
@setdoc.basic
|
|
458
|
+
def __mutate__(
|
|
459
|
+
self: Self, /
|
|
460
|
+
) -> ContextManager[__Mutable__[Key, Value]]: ...
|
|
461
|
+
@setdoc.basic
|
|
462
|
+
def copy(self: Self, /) -> Self:
|
|
463
|
+
return type(self)(self)
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
### DICT-SLOT ###
|
|
467
|
+
|
|
468
|
+
|
|
469
|
+
class DictSlot[Key: abc.Hashable, Value](DictLike[Key, Value]):
|
|
470
|
+
"""Provide slotted dict-like."""
|
|
471
|
+
|
|
472
|
+
__slots__ = ("_slot",)
|
|
473
|
+
_slot: DictSlot.__Frozen__[Key, Value]
|
|
474
|
+
|
|
475
|
+
@setdoc.basic
|
|
476
|
+
def __frozen__( # type: ignore[override]
|
|
477
|
+
self: Self,
|
|
478
|
+
) -> DictSlot.__Frozen__[Key, Value]:
|
|
479
|
+
return self._slot
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
class FrozenDictSlot[Key: abc.Hashable, Value](
|
|
483
|
+
DictSlot[Key, Value],
|
|
484
|
+
FrozenDictLike[Key, Value],
|
|
485
|
+
):
|
|
486
|
+
"""Provide slotted frozen dict-like."""
|
|
487
|
+
|
|
488
|
+
__slots__ = ()
|
|
489
|
+
|
|
490
|
+
@setdoc.basic
|
|
491
|
+
def __init__(
|
|
492
|
+
self: Self,
|
|
493
|
+
data: DictInit[Key, Value] = (),
|
|
494
|
+
/,
|
|
495
|
+
**kwargs: Optional[Value],
|
|
496
|
+
) -> None:
|
|
497
|
+
self._slot = frozendict(data) # type: ignore[arg-type]
|
|
498
|
+
|
|
499
|
+
|
|
500
|
+
class MutableDictSlot[Key: abc.Hashable, Value](
|
|
501
|
+
DictSlot[Key, Value],
|
|
502
|
+
MutableDictLike[Key, Value],
|
|
503
|
+
):
|
|
504
|
+
"""Provide slotted mutable dict-like."""
|
|
505
|
+
|
|
506
|
+
__slots__ = ()
|
|
507
|
+
|
|
508
|
+
@contextmanager
|
|
509
|
+
@setdoc.basic
|
|
510
|
+
def __mutate__(
|
|
511
|
+
self: Self,
|
|
512
|
+
/,
|
|
513
|
+
) -> abc.Generator[MutableDictSlot.__Mutable__[Key, Value], None, None]:
|
|
514
|
+
slot: MutableDictSlot.__Mutable__[Key, Value]
|
|
515
|
+
slot = dict(getattr(self, "_slot", ()))
|
|
516
|
+
yield slot
|
|
517
|
+
self._slot = frozendict(slot)
|
|
518
|
+
|
|
519
|
+
|
|
275
520
|
### SEQUENCE ###
|
|
276
521
|
|
|
277
522
|
|
|
278
523
|
class Sequence[Item](Collection[Item], abc.Sequence[Item]):
|
|
279
|
-
"""Provide
|
|
524
|
+
"""Provide abc for customized sequence."""
|
|
280
525
|
|
|
281
526
|
__slots__ = ()
|
|
282
527
|
|
|
283
528
|
@setdoc.basic
|
|
284
|
-
class __Frozen__[
|
|
285
|
-
Collection.__Frozen__[
|
|
529
|
+
class __Frozen__[Item_](
|
|
530
|
+
Collection.__Frozen__[Item_],
|
|
286
531
|
Protocol,
|
|
287
532
|
):
|
|
288
533
|
@overload
|
|
289
534
|
@setdoc.basic
|
|
290
|
-
def __getitem__(self: Self, key: int, /) ->
|
|
535
|
+
def __getitem__(self: Self, key: int, /) -> Item_: ...
|
|
291
536
|
@overload
|
|
292
537
|
@setdoc.basic
|
|
293
538
|
def __getitem__(
|
|
294
539
|
self: Self, key: Slice[int], /
|
|
295
|
-
) -> abc.Sequence[
|
|
540
|
+
) -> abc.Sequence[Item_]: ...
|
|
296
541
|
@setdoc.basic
|
|
297
542
|
def __getitem__(
|
|
298
543
|
self: Self,
|
|
299
544
|
key: int | Slice[int],
|
|
300
545
|
/,
|
|
301
|
-
) ->
|
|
302
|
-
|
|
546
|
+
) -> Item_ | abc.Sequence[Item_]: ...
|
|
303
547
|
@abstractmethod
|
|
304
548
|
@setdoc.basic
|
|
305
549
|
def __frozen__(self: Self, /) -> __Frozen__[Item]: ...
|
|
306
|
-
|
|
307
550
|
@overload
|
|
308
551
|
@setdoc.basic
|
|
309
552
|
def __getitem__(self: Self, key: int, /) -> Item: ...
|
|
@@ -318,13 +561,12 @@ class Sequence[Item](Collection[Item], abc.Sequence[Item]):
|
|
|
318
561
|
|
|
319
562
|
|
|
320
563
|
class MutableSequence[Item](Sequence[Item], abc.MutableSequence[Item]):
|
|
321
|
-
"""Provide
|
|
564
|
+
"""Provide abc for custom mutable sequence."""
|
|
322
565
|
|
|
323
566
|
__slots__ = ()
|
|
324
567
|
|
|
325
568
|
@setdoc.basic
|
|
326
|
-
class __Mutable__[
|
|
327
|
-
|
|
569
|
+
class __Mutable__[Item_](Protocol):
|
|
328
570
|
@overload
|
|
329
571
|
@setdoc.basic
|
|
330
572
|
def __delitem__(self: Self, key: SupportsIndex, /) -> None: ...
|
|
@@ -335,42 +577,37 @@ class MutableSequence[Item](Sequence[Item], abc.MutableSequence[Item]):
|
|
|
335
577
|
def __delitem__(
|
|
336
578
|
self: Self, key: SupportsIndex | Slice[SupportsIndex], /
|
|
337
579
|
) -> None: ...
|
|
338
|
-
|
|
339
580
|
@overload
|
|
340
581
|
@setdoc.basic
|
|
341
|
-
def __getitem__(self: Self, key: int, /) ->
|
|
582
|
+
def __getitem__(self: Self, key: int, /) -> Item_: ...
|
|
342
583
|
@overload
|
|
343
584
|
@setdoc.basic
|
|
344
585
|
def __getitem__(
|
|
345
586
|
self: Self, key: Slice[int], /
|
|
346
|
-
) -> abc.MutableSequence[
|
|
587
|
+
) -> abc.MutableSequence[Item_]: ...
|
|
347
588
|
@setdoc.basic
|
|
348
589
|
def __getitem__(
|
|
349
590
|
self: Self,
|
|
350
591
|
key: int | Slice[int],
|
|
351
592
|
/,
|
|
352
|
-
) ->
|
|
353
|
-
|
|
593
|
+
) -> Item_ | abc.MutableSequence[Item_]: ...
|
|
354
594
|
@overload
|
|
355
595
|
@setdoc.basic
|
|
356
|
-
def __setitem__(
|
|
357
|
-
self: Self, key: int, value: MutableItem, /
|
|
358
|
-
) -> None: ...
|
|
596
|
+
def __setitem__(self: Self, key: int, value: Item_, /) -> None: ...
|
|
359
597
|
@overload
|
|
360
598
|
@setdoc.basic
|
|
361
599
|
def __setitem__(
|
|
362
|
-
self: Self, key: Slice[int], value: abc.Iterable[
|
|
600
|
+
self: Self, key: Slice[int], value: abc.Iterable[Item_], /
|
|
363
601
|
) -> None: ...
|
|
364
602
|
@setdoc.basic
|
|
365
603
|
def __setitem__(
|
|
366
604
|
self: Self,
|
|
367
605
|
key: int | Slice[int],
|
|
368
|
-
value:
|
|
606
|
+
value: Item_ | abc.Iterable[Item_],
|
|
369
607
|
/,
|
|
370
608
|
) -> None: ...
|
|
371
|
-
|
|
372
609
|
@setdoc.basic
|
|
373
|
-
def insert(self: Self, index: int, item:
|
|
610
|
+
def insert(self: Self, index: int, item: Item_, /) -> None: ...
|
|
374
611
|
|
|
375
612
|
@overload
|
|
376
613
|
@setdoc.basic
|
|
@@ -428,15 +665,13 @@ class MutableSequence[Item](Sequence[Item], abc.MutableSequence[Item]):
|
|
|
428
665
|
|
|
429
666
|
### LIST-LIKE ###
|
|
430
667
|
class ListLike[Item](Sequence[Item]):
|
|
431
|
-
"""Provide
|
|
668
|
+
"""Provide abc for custom list-like."""
|
|
432
669
|
|
|
433
670
|
__slots__ = ()
|
|
434
671
|
|
|
435
|
-
type __Frozen__[
|
|
672
|
+
type __Frozen__[Item_] = tuple[Item_, ...]
|
|
436
673
|
# Frozen has to be tuple to allow covariance
|
|
437
674
|
|
|
438
|
-
type Init[InitItem] = abc.Iterable[InitItem]
|
|
439
|
-
|
|
440
675
|
@setdoc.basic
|
|
441
676
|
def __add__[Item_](
|
|
442
677
|
self: Self, other: ListLike[Item_], /
|
|
@@ -492,7 +727,7 @@ class ListLike[Item](Sequence[Item]):
|
|
|
492
727
|
|
|
493
728
|
@abstractmethod
|
|
494
729
|
@setdoc.basic
|
|
495
|
-
def __init__(self: Self, data:
|
|
730
|
+
def __init__(self: Self, data: abc.Iterable[Item] = (), /) -> None: ...
|
|
496
731
|
|
|
497
732
|
@setdoc.basic
|
|
498
733
|
def __le__(self: Self, other: ListLike[Any], /) -> bool:
|
|
@@ -523,7 +758,7 @@ class ListLike[Item](Sequence[Item]):
|
|
|
523
758
|
|
|
524
759
|
|
|
525
760
|
class FrozenListLike[Item](ListLike[Item], abc.Hashable):
|
|
526
|
-
"""Provide
|
|
761
|
+
"""Provide abc for custom frozen list-like."""
|
|
527
762
|
|
|
528
763
|
__slots__ = ()
|
|
529
764
|
|
|
@@ -533,11 +768,11 @@ class FrozenListLike[Item](ListLike[Item], abc.Hashable):
|
|
|
533
768
|
|
|
534
769
|
|
|
535
770
|
class MutableListLike[Item](ListLike[Item], MutableSequence[Item]):
|
|
536
|
-
"""Provide
|
|
771
|
+
"""Provide abc for custom mutable list-like."""
|
|
537
772
|
|
|
538
773
|
__slots__ = ()
|
|
539
774
|
|
|
540
|
-
type __Mutable__[
|
|
775
|
+
type __Mutable__[Item_] = list[Item_]
|
|
541
776
|
|
|
542
777
|
@overload
|
|
543
778
|
@setdoc.basic
|
|
@@ -618,7 +853,6 @@ class ListSlot[Item](ListLike[Item]):
|
|
|
618
853
|
"""Provide slotted list-like class."""
|
|
619
854
|
|
|
620
855
|
__slots__ = ("_slot",)
|
|
621
|
-
|
|
622
856
|
_slot: ListSlot.__Frozen__[Item]
|
|
623
857
|
|
|
624
858
|
@setdoc.basic
|
|
@@ -627,7 +861,7 @@ class ListSlot[Item](ListLike[Item]):
|
|
|
627
861
|
|
|
628
862
|
|
|
629
863
|
class FrozenListSlot[Item](ListSlot[Item], FrozenListLike[Item]):
|
|
630
|
-
"""Provide
|
|
864
|
+
"""Provide slotted frozen list-like."""
|
|
631
865
|
|
|
632
866
|
__slots__ = ()
|
|
633
867
|
|
|
@@ -637,7 +871,7 @@ class FrozenListSlot[Item](ListSlot[Item], FrozenListLike[Item]):
|
|
|
637
871
|
|
|
638
872
|
|
|
639
873
|
class MutableListSlot[Item](ListSlot[Item], MutableListLike[Item]):
|
|
640
|
-
"""Provide slotted mutable list-like
|
|
874
|
+
"""Provide slotted mutable list-like."""
|
|
641
875
|
|
|
642
876
|
__slots__ = ()
|
|
643
877
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: datahold
|
|
3
|
-
Version: 4.0.0.
|
|
3
|
+
Version: 4.0.0.dev22
|
|
4
4
|
Summary: This project wraps common mutable datastructures for inheritance with modification.
|
|
5
5
|
Author-email: Johannes <johannes.programming@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -19,6 +19,7 @@ Classifier: Typing :: Typed
|
|
|
19
19
|
Requires-Python: >=3.11
|
|
20
20
|
Description-Content-Type: text/x-rst
|
|
21
21
|
License-File: LICENSE.txt
|
|
22
|
+
Requires-Dist: frozendict<3,>=2.4.7
|
|
22
23
|
Requires-Dist: setdoc<2,>=1.3.24
|
|
23
24
|
Dynamic: license-file
|
|
24
25
|
|
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
[datatypes.Collection]
|
|
2
2
|
|
|
3
|
+
[datatypes.DictLike.issubclass]
|
|
4
|
+
"collections.abc.Mapping" = true
|
|
5
|
+
"datahold.Mapping" = true
|
|
6
|
+
|
|
7
|
+
[datatypes.DictSlot.issubclass]
|
|
8
|
+
"collections.abc.Mapping" = true
|
|
9
|
+
"datahold.DictLike" = true
|
|
10
|
+
|
|
11
|
+
[datatypes.FrozenDictLike.issubclass]
|
|
12
|
+
"collections.abc.Hashable" = true
|
|
13
|
+
"datahold.Mapping" = true
|
|
14
|
+
|
|
15
|
+
[datatypes.FrozenDictSlot.issubclass]
|
|
16
|
+
"collections.abc.Hashable" = true
|
|
17
|
+
"datahold.FrozenDictLike" = true
|
|
18
|
+
|
|
3
19
|
[datatypes.FrozenListLike]
|
|
4
20
|
abstractmethods = [
|
|
5
21
|
"__frozen__",
|
|
@@ -18,7 +34,6 @@ __init__ = "datahold.ListLike"
|
|
|
18
34
|
"collections.abc.Sequence" = true
|
|
19
35
|
|
|
20
36
|
[datatypes.FrozenListLike.nested]
|
|
21
|
-
Init = "collections.abc.Iterable"
|
|
22
37
|
__Frozen__ = "builtins.tuple"
|
|
23
38
|
__Mutable__ = ""
|
|
24
39
|
|
|
@@ -133,7 +148,6 @@ args = [
|
|
|
133
148
|
]
|
|
134
149
|
|
|
135
150
|
[datatypes.FrozenListSlot.nested]
|
|
136
|
-
Init = "collections.abc.Iterable"
|
|
137
151
|
__Frozen__ = "builtins.tuple"
|
|
138
152
|
__Mutable__ = ""
|
|
139
153
|
|
|
@@ -174,7 +188,6 @@ index = "collections.abc.Sequence"
|
|
|
174
188
|
"datahold.MutableSequence" = false
|
|
175
189
|
|
|
176
190
|
[datatypes.ListLike.nested]
|
|
177
|
-
Init = "collections.abc.Iterable"
|
|
178
191
|
__Frozen__ = "builtins.tuple"
|
|
179
192
|
__Mutable__ = ""
|
|
180
193
|
|
|
@@ -187,13 +200,27 @@ abstractmethods = [
|
|
|
187
200
|
]
|
|
188
201
|
|
|
189
202
|
[datatypes.ListSlot.nested]
|
|
190
|
-
Init = "collections.abc.Iterable"
|
|
191
203
|
__Frozen__ = "builtins.tuple"
|
|
192
204
|
__Mutable__ = ""
|
|
193
205
|
|
|
194
206
|
[datatypes.ListSlot.varia]
|
|
195
207
|
generic = 1
|
|
196
208
|
|
|
209
|
+
[datatypes.Mapping.issubclass]
|
|
210
|
+
"collections.abc.Mapping" = true
|
|
211
|
+
"datahold.Collection" = true
|
|
212
|
+
|
|
213
|
+
[datatypes.MutableDictLike.issubclass]
|
|
214
|
+
"collections.abc.Mapping" = true
|
|
215
|
+
"collections.abc.MutableMapping" = true
|
|
216
|
+
"datahold.MutableMapping" = true
|
|
217
|
+
|
|
218
|
+
[datatypes.MutableDictSlot.issubclass]
|
|
219
|
+
"collections.abc.Mapping" = true
|
|
220
|
+
"collections.abc.MutableMapping" = true
|
|
221
|
+
"datahold.MutableDictLike" = true
|
|
222
|
+
"datahold.MutableMapping" = true
|
|
223
|
+
|
|
197
224
|
[datatypes.MutableListLike]
|
|
198
225
|
abstractmethods = [
|
|
199
226
|
"__mutate__",
|
|
@@ -226,7 +253,6 @@ reverse = "collections.abc.MutableSequence"
|
|
|
226
253
|
"datahold.MutableSequence" = true
|
|
227
254
|
|
|
228
255
|
[datatypes.MutableListLike.nested]
|
|
229
|
-
Init = "collections.abc.Iterable"
|
|
230
256
|
__Frozen__ = "builtins.tuple"
|
|
231
257
|
__hash__ = ""
|
|
232
258
|
|
|
@@ -243,13 +269,16 @@ abstractmethods = []
|
|
|
243
269
|
"datahold.MutableListSlot" = true
|
|
244
270
|
|
|
245
271
|
[datatypes.MutableListSlot.nested]
|
|
246
|
-
Init = "collections.abc.Iterable"
|
|
247
272
|
__Frozen__ = "builtins.tuple"
|
|
248
273
|
__hash__ = ""
|
|
249
274
|
|
|
250
275
|
[datatypes.MutableListSlot.varia]
|
|
251
276
|
generic = 1
|
|
252
277
|
|
|
278
|
+
[datatypes.MutableMapping.issubclass]
|
|
279
|
+
"collections.abc.MutableMapping" = true
|
|
280
|
+
"datahold.Mapping" = true
|
|
281
|
+
|
|
253
282
|
[datatypes.MutableSequence.attributes]
|
|
254
283
|
__Frozen__ = "datahold.Sequence"
|
|
255
284
|
__Mutable__ = "datahold.MutableSequence"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
setdoc<2,>=1.3.24
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|