datahold 4.0.0.dev26__tar.gz → 4.0.0.dev28__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.
Files changed (41) hide show
  1. {datahold-4.0.0.dev26 → datahold-4.0.0.dev28}/PKG-INFO +1 -1
  2. {datahold-4.0.0.dev26 → datahold-4.0.0.dev28}/pyproject.toml +1 -1
  3. {datahold-4.0.0.dev26 → datahold-4.0.0.dev28}/src/datahold/__init__.py +151 -110
  4. {datahold-4.0.0.dev26 → datahold-4.0.0.dev28}/src/datahold.egg-info/PKG-INFO +1 -1
  5. {datahold-4.0.0.dev26 → datahold-4.0.0.dev28}/src/datahold.egg-info/SOURCES.txt +3 -1
  6. datahold-4.0.0.dev28/tests/test_FrozenSetSlot.py +233 -0
  7. datahold-4.0.0.dev28/tests/test_MutableDictSlot.py +403 -0
  8. datahold-4.0.0.dev28/tests/test_MutableSetSlot.py +477 -0
  9. {datahold-4.0.0.dev26 → datahold-4.0.0.dev28}/tests/test_abstractmethods.py +3 -1
  10. datahold-4.0.0.dev28/tests/test_metaclass.py +25 -0
  11. {datahold-4.0.0.dev26 → datahold-4.0.0.dev28}/tests/test_name.py +6 -5
  12. {datahold-4.0.0.dev26 → datahold-4.0.0.dev28}/tests/testdata.toml +35 -11
  13. datahold-4.0.0.dev26/tests/test_MutableDictSlot.py +0 -0
  14. datahold-4.0.0.dev26/tests/test_internal_comparison.py +0 -50
  15. {datahold-4.0.0.dev26 → datahold-4.0.0.dev28}/LICENSE.txt +0 -0
  16. {datahold-4.0.0.dev26 → datahold-4.0.0.dev28}/MANIFEST.in +0 -0
  17. {datahold-4.0.0.dev26 → datahold-4.0.0.dev28}/README.rst +0 -0
  18. {datahold-4.0.0.dev26 → datahold-4.0.0.dev28}/docs/v1.1.rst +0 -0
  19. {datahold-4.0.0.dev26 → datahold-4.0.0.dev28}/docs/v1.2.rst +0 -0
  20. {datahold-4.0.0.dev26 → datahold-4.0.0.dev28}/docs/v2.0.rst +0 -0
  21. {datahold-4.0.0.dev26 → datahold-4.0.0.dev28}/docs/v2.1.rst +0 -0
  22. {datahold-4.0.0.dev26 → datahold-4.0.0.dev28}/docs/v2.2.rst +0 -0
  23. {datahold-4.0.0.dev26 → datahold-4.0.0.dev28}/docs/v2.3.rst +0 -0
  24. {datahold-4.0.0.dev26 → datahold-4.0.0.dev28}/docs/v3.0.rst +0 -0
  25. {datahold-4.0.0.dev26 → datahold-4.0.0.dev28}/docs/v4.0.rst +0 -0
  26. {datahold-4.0.0.dev26 → datahold-4.0.0.dev28}/run_tests.py +0 -0
  27. {datahold-4.0.0.dev26 → datahold-4.0.0.dev28}/setup.cfg +0 -0
  28. {datahold-4.0.0.dev26 → datahold-4.0.0.dev28}/src/datahold/py.typed +0 -0
  29. {datahold-4.0.0.dev26 → datahold-4.0.0.dev28}/src/datahold.egg-info/dependency_links.txt +0 -0
  30. {datahold-4.0.0.dev26 → datahold-4.0.0.dev28}/src/datahold.egg-info/requires.txt +0 -0
  31. {datahold-4.0.0.dev26 → datahold-4.0.0.dev28}/src/datahold.egg-info/top_level.txt +0 -0
  32. {datahold-4.0.0.dev26 → datahold-4.0.0.dev28}/tests/test_FrozenListSlot.py +0 -0
  33. {datahold-4.0.0.dev26 → datahold-4.0.0.dev28}/tests/test_MutableListSlot.py +0 -0
  34. {datahold-4.0.0.dev26 → datahold-4.0.0.dev28}/tests/test_all.py +0 -0
  35. {datahold-4.0.0.dev26 → datahold-4.0.0.dev28}/tests/test_attributes.py +0 -0
  36. {datahold-4.0.0.dev26 → datahold-4.0.0.dev28}/tests/test_docs.py +0 -0
  37. {datahold-4.0.0.dev26 → datahold-4.0.0.dev28}/tests/test_generic.py +0 -0
  38. {datahold-4.0.0.dev26 → datahold-4.0.0.dev28}/tests/test_issubclass.py +0 -0
  39. {datahold-4.0.0.dev26 → datahold-4.0.0.dev28}/tests/test_nested.py +0 -0
  40. {datahold-4.0.0.dev26 → datahold-4.0.0.dev28}/tests/test_sorted.py +0 -0
  41. {datahold-4.0.0.dev26 → datahold-4.0.0.dev28}/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.dev26
3
+ Version: 4.0.0.dev28
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
@@ -31,7 +31,7 @@ license-files = [
31
31
  name = "datahold"
32
32
  readme = "README.rst"
33
33
  requires-python = ">=3.11"
34
- version = "4.0.0.dev26"
34
+ version = "4.0.0.dev28"
35
35
 
36
36
  [project.urls]
37
37
  Download = "https://pypi.org/project/datahold/#files"
@@ -9,6 +9,7 @@ __all__: list[str] = [
9
9
  "FrozenDictSlot",
10
10
  "FrozenListLike",
11
11
  "FrozenListSlot",
12
+ "FrozenObjectSlot",
12
13
  "FrozenSetLike",
13
14
  "FrozenSetSlot",
14
15
  "ListLike",
@@ -18,16 +19,20 @@ __all__: list[str] = [
18
19
  "MutableListLike",
19
20
  "MutableListSlot",
20
21
  "MutableMapping",
22
+ "MutableObject",
23
+ "MutableObjectLike",
21
24
  "MutableSequence",
22
25
  "MutableSet",
23
26
  "MutableSetLike",
24
27
  "MutableSetSlot",
28
+ "Object",
29
+ "ObjectSlot",
25
30
  "Sequence",
26
31
  "Set",
27
32
  "SetLike",
28
33
  ]
29
34
 
30
- from abc import abstractmethod
35
+ from abc import ABCMeta, abstractmethod
31
36
  from collections import abc
32
37
  from contextlib import contextmanager
33
38
  from types import NotImplementedType, TracebackType
@@ -164,15 +169,82 @@ class MutableSequence_Mutable[Item](Protocol):
164
169
 
165
170
  ### TYPE ALIASES ###
166
171
 
172
+ type Dict[Key, Value] = dict[Key | str, Optional[Value]]
167
173
 
168
174
  type DictInit[Key, Value] = (
169
175
  SupportsKeysAndGetitem[Key | str, Optional[Value]]
170
176
  | abc.Iterable[tuple[Key | str, Optional[Value]]]
171
177
  )
172
178
 
179
+ type FrozenDict[Key, Value] = frozendict[Key | str, Optional[Value]]
180
+
173
181
  type Slice[Index] = slice[Optional[Index], Optional[Index], Optional[Index]]
174
182
 
175
183
 
184
+ ### OBJECT ###
185
+ class Object[Frozen](metaclass=ABCMeta):
186
+ """Provide abc for custom object."""
187
+
188
+ __slots__ = ()
189
+
190
+ @abstractmethod
191
+ @setdoc.basic
192
+ def __frozen__(self: Self, /) -> Frozen: ...
193
+
194
+
195
+ class MutableObject[Frozen, Mutable](Object[Frozen]):
196
+ """Provide abc for custom mutable object."""
197
+
198
+ __slots__ = ()
199
+
200
+ @abstractmethod
201
+ @setdoc.basic
202
+ def __mutate__(self: Self, /) -> ContextManager[Mutable]: ...
203
+
204
+
205
+ ### OBJECT-LIKE ###
206
+
207
+
208
+ class MutableObjectLike[Frozen, Mutable](
209
+ MutableObject[Frozen, Mutable],
210
+ ):
211
+ """Provide abc for custom mutable object-like."""
212
+
213
+ __slots__ = ()
214
+
215
+ @abstractmethod
216
+ @setdoc.basic
217
+ def __init__(self: Self, other: Self, /) -> None: ...
218
+ @setdoc.basic
219
+ def copy(self: Self, /) -> Self:
220
+ return type(self)(self)
221
+
222
+
223
+ ### OBJECT-HOLD ###
224
+
225
+
226
+ class ObjectSlot[Frozen](
227
+ Object[Frozen],
228
+ ):
229
+ """Provide slotted abc for custom object-like."""
230
+
231
+ __slots__ = ("_slot",)
232
+ _slot: Frozen
233
+
234
+
235
+ class FrozenObjectSlot[Frozen](
236
+ ObjectSlot[Frozen],
237
+ ):
238
+ """Provide slotted abc for custom frozen object-like."""
239
+
240
+ __slots__ = ()
241
+ _slot: Frozen
242
+
243
+ @setdoc.basic
244
+ def __frozen__(self: Self, /) -> Frozen:
245
+ return self._slot
246
+
247
+
176
248
  ### COLLECTION ###
177
249
 
178
250
 
@@ -180,11 +252,10 @@ class Collection[Item](
180
252
  abc.Sized,
181
253
  abc.Iterable[Item],
182
254
  abc.Container[object],
255
+ Object[Collection_Frozen[Item]],
183
256
  ):
184
257
  """Provide abc for custom collection."""
185
258
 
186
- type __Frozen__[Item_] = Collection_Frozen[Item_]
187
-
188
259
  @setdoc.basic
189
260
  def __contains__(self: Self, other: object, /) -> bool:
190
261
  try:
@@ -192,10 +263,6 @@ class Collection[Item](
192
263
  except TypeError:
193
264
  return other in (x for x in self) # type: ignore[operator]
194
265
 
195
- @abstractmethod
196
- @setdoc.basic
197
- def __frozen__(self: Self, /) -> Collection_Frozen[Item]: ...
198
-
199
266
  @setdoc.basic
200
267
  def __iter__(self: Self, /) -> abc.Iterator[Item]:
201
268
  return iter(self.__frozen__())
@@ -214,15 +281,15 @@ class Set[Item: abc.Hashable](Collection[Item], abc.Set[Item]):
214
281
  __slots__ = ()
215
282
 
216
283
 
217
- class MutableSet[Item: abc.Hashable](Set[Item], abc.MutableSet[Item]):
284
+ class MutableSet[Item: abc.Hashable](
285
+ Set[Item],
286
+ abc.MutableSet[Item],
287
+ MutableObject[Collection_Frozen[Item], MutableSet_Mutable[Item]],
288
+ ):
218
289
  """Provide abc for custom mutable set."""
219
290
 
220
291
  __slots__ = ()
221
- type __Mutable__[Item_] = MutableSet_Mutable[Item_]
222
292
 
223
- @abstractmethod
224
- @setdoc.basic
225
- def __mutate__(self: Self) -> ContextManager[MutableSet_Mutable[Item]]: ...
226
293
  @setdoc.basic
227
294
  def add(self: Self, item: Item, /) -> None:
228
295
  with self.__mutate__() as mutable:
@@ -241,11 +308,10 @@ class SetLike[Item: abc.Hashable](Set[Item]):
241
308
  """Provide abc for custom set-like."""
242
309
 
243
310
  __slots__ = ()
244
- type __Frozen__[Item_] = frozenset[Item_]
245
311
 
246
312
  @abstractmethod
247
313
  @setdoc.basic
248
- def __frozen__(self: Self, /) -> __Frozen__[Item]: ...
314
+ def __frozen__(self: Self, /) -> frozenset[Item]: ...
249
315
  @abstractmethod
250
316
  @setdoc.basic
251
317
  def __init__(self: Self, data: abc.Iterable[Item] = (), /) -> None: ...
@@ -260,12 +326,12 @@ class SetLike[Item: abc.Hashable](Set[Item]):
260
326
  return type(self)(self.__frozen__().intersection(*others))
261
327
 
262
328
  @setdoc.basic
263
- def issubset(self: Self, other: abc.Iterable[abc.Hashable], /) -> Self:
264
- return type(self)(self.__frozen__().issubset(other)) # type: ignore
329
+ def issubset(self: Self, other: abc.Iterable[abc.Hashable], /) -> bool:
330
+ return self.__frozen__().issubset(other)
265
331
 
266
332
  @setdoc.basic
267
- def issuperset(self: Self, other: abc.Iterable[abc.Hashable], /) -> Self:
268
- return type(self)(self.__frozen__().issuperset(other)) # type: ignore
333
+ def issuperset(self: Self, other: abc.Iterable[abc.Hashable], /) -> bool:
334
+ return self.__frozen__().issuperset(other)
269
335
 
270
336
  @setdoc.basic
271
337
  def symmetric_difference(self: Self, other: abc.Iterable[Item], /) -> Self:
@@ -273,7 +339,7 @@ class SetLike[Item: abc.Hashable](Set[Item]):
273
339
 
274
340
  @setdoc.basic
275
341
  def union(self: Self, /, *others: abc.Iterable[Item]) -> Self:
276
- return type(self)(self.__frozen__().union(others)) # type: ignore
342
+ return type(self)(self.__frozen__().union(*others))
277
343
 
278
344
 
279
345
  class FrozenSetLike[Item: abc.Hashable](SetLike[Item], abc.Hashable):
@@ -286,14 +352,17 @@ class FrozenSetLike[Item: abc.Hashable](SetLike[Item], abc.Hashable):
286
352
  return hash(self.__frozen__())
287
353
 
288
354
 
289
- class MutableSetLike[Item: abc.Hashable](SetLike[Item], MutableSet[Item]):
355
+ class MutableSetLike[Item: abc.Hashable](
356
+ SetLike[Item],
357
+ MutableObjectLike[frozenset[Item], set[Item]],
358
+ MutableSet[Item],
359
+ ):
290
360
  """Provide abc for custom mutable set-like."""
291
361
 
292
362
  __slots__ = ()
293
- type __Mutable__[Item_] = set[Item_]
294
363
 
295
364
  @setdoc.basic
296
- def __frozen__(self: Self, /) -> MutableSetLike.__Frozen__[Item]:
365
+ def __frozen__(self: Self, /) -> frozenset[Item]:
297
366
  with self.__mutate__() as mutable:
298
367
  return frozenset(mutable)
299
368
 
@@ -302,9 +371,6 @@ class MutableSetLike[Item: abc.Hashable](SetLike[Item], MutableSet[Item]):
302
371
  with self.__mutate__() as mutable:
303
372
  mutable.update(data)
304
373
 
305
- @abstractmethod
306
- @setdoc.basic
307
- def __mutate__(self: Self) -> ContextManager[__Mutable__[Item]]: ...
308
374
  @setdoc.basic
309
375
  def difference_update(
310
376
  self: Self, /, *others: abc.Iterable[abc.Hashable]
@@ -335,36 +401,34 @@ class MutableSetLike[Item: abc.Hashable](SetLike[Item], MutableSet[Item]):
335
401
  ### SET-SLOT ###
336
402
 
337
403
 
338
- class FrozenSetSlot[Item](FrozenSetLike[Item]):
404
+ class FrozenSetSlot[Item](
405
+ FrozenObjectSlot[frozenset[Item]],
406
+ FrozenSetLike[Item],
407
+ ):
339
408
  """Provide slotted frozen set-like."""
340
409
 
341
- __slots__ = ("_slot",)
342
-
343
- _slot: FrozenSetSlot.__Frozen__[Item]
344
-
345
- @setdoc.basic
346
- def __frozen__(self: Self, /) -> FrozenSetSlot.__Frozen__[Item]:
347
- return self._slot
410
+ __slots__ = ()
348
411
 
349
412
  @setdoc.basic
350
413
  def __init__(self: Self, data: abc.Iterable[Item] = (), /) -> None:
351
414
  self._slot = frozenset(data)
352
415
 
353
416
 
354
- class MutableSetSlot[Item](MutableSetLike[Item]):
417
+ class MutableSetSlot[Item](
418
+ MutableSetLike[Item],
419
+ ObjectSlot[frozenset[Item]],
420
+ ):
355
421
  """Provide slotted mutable set-like."""
356
422
 
357
- __slots__ = ("_slot",)
358
-
359
- _slot: FrozenSetSlot.__Frozen__[Item]
423
+ __slots__ = ()
360
424
 
361
425
  @contextmanager
362
426
  @setdoc.basic
363
427
  def __mutate__(
364
428
  self: Self,
365
429
  /,
366
- ) -> abc.Generator[MutableSetSlot.__Mutable__[Item], None, None]:
367
- slot: MutableSetSlot.__Mutable__[Item]
430
+ ) -> abc.Generator[set[Item], None, None]:
431
+ slot: set[Item]
368
432
  slot = set(getattr(self, "_slot", ()))
369
433
  yield slot
370
434
  self._slot = frozenset(slot)
@@ -381,11 +445,9 @@ class Mapping[Key: abc.Hashable, Value](
381
445
 
382
446
  __slots__ = ()
383
447
 
384
- type __Frozen__[Key_, Value_] = Mapping_Frozen[Key_, Value_]
385
-
386
448
  @abstractmethod
387
449
  @setdoc.basic
388
- def __frozen__(self: Self, /) -> __Frozen__[Key, Value]: ...
450
+ def __frozen__(self: Self, /) -> Mapping_Frozen[Key, Value]: ...
389
451
  @setdoc.basic
390
452
  def __getitem__(self: Self, key: abc.Hashable, /) -> Value:
391
453
  return self.__frozen__()[key]
@@ -394,21 +456,17 @@ class Mapping[Key: abc.Hashable, Value](
394
456
  class MutableMapping[Key: abc.Hashable, Value](
395
457
  Mapping[Key, Value],
396
458
  abc.MutableMapping[Key | str, Optional[Value]],
459
+ MutableObject[FrozenDict[Key, Value], Dict[Key, Value]],
397
460
  ):
398
461
  """Provide abc for custom mutable mapping."""
399
462
 
400
463
  __slots__ = ()
401
464
 
402
- type __Mutable__[Key_, Value_] = MutableMapping_Mutable[Key_, Value_]
403
-
404
465
  @setdoc.basic
405
466
  def __delitem__(self: Self, key: Key | str, /) -> None:
406
467
  with self.__mutate__() as mutable:
407
468
  del mutable[key]
408
469
 
409
- @abstractmethod
410
- @setdoc.basic
411
- def __mutate__(self: Self) -> ContextManager[__Mutable__[Key, Value]]: ...
412
470
  @setdoc.basic
413
471
  def __setitem__(
414
472
  self: Self, key: Key | str, value: Optional[Value], /
@@ -426,11 +484,12 @@ class DictLike[Key: abc.Hashable, Value](
426
484
  """Provide abc for custom dict-like."""
427
485
 
428
486
  __slots__ = ()
429
- type __Frozen__[Key_, Value_] = frozendict[Key_ | str, Optional[Value_]]
430
487
 
431
488
  @abstractmethod
432
489
  @setdoc.basic
433
- def __frozen__(self: Self, /) -> __Frozen__[Key, Value]: ... # type: ignore[override]
490
+ def __frozen__(self: Self, /) -> FrozenDict[Key, Value]: # type: ignore[override]
491
+ ...
492
+
434
493
  @abstractmethod
435
494
  @setdoc.basic
436
495
  def __init__(
@@ -445,13 +504,13 @@ class DictLike[Key: abc.Hashable, Value](
445
504
  other: DictInit[Key_, Value_],
446
505
  /,
447
506
  ) -> DictLike[Key | Key_, Value | Value_]:
448
- data: DictLike.__Frozen__[Key_, Value_]
507
+ data: FrozenDict[Key, Value]
449
508
  try:
450
509
  data = frozendict(other) # type: ignore[arg-type]
451
510
  except TypeError:
452
511
  return NotImplemented
453
512
  return type(self)( # type: ignore[return-value]
454
- self.__frozen__() | data # type: ignore[operator]
513
+ self.__frozen__() | data
455
514
  )
456
515
 
457
516
  @classmethod
@@ -480,20 +539,18 @@ class FrozenDictLike[Key: abc.Hashable, Value](
480
539
 
481
540
  class MutableDictLike[Key: abc.Hashable, Value](
482
541
  DictLike[Key, Value],
542
+ MutableObjectLike[FrozenDict[Key, Value], Dict[Key, Value]],
483
543
  MutableMapping[Key, Value],
484
544
  ):
485
545
  """Provide abc for custom mutable dict-like."""
486
546
 
487
547
  __slots__ = ()
488
- type __Mutable__[Key_: abc.Hashable, Value_] = dict[
489
- Key_ | str, Optional[Value_]
490
- ]
491
548
 
492
549
  @setdoc.basic
493
550
  def __frozen__( # type: ignore[override]
494
551
  self: Self,
495
552
  /,
496
- ) -> MutableDictLike.__Frozen__[Key, Value]:
553
+ ) -> FrozenDict[Key, Value]:
497
554
  with self.__mutate__() as mutable:
498
555
  return frozendict(mutable)
499
556
 
@@ -516,32 +573,25 @@ class MutableDictLike[Key: abc.Hashable, Value](
516
573
  mutable |= other
517
574
  return self
518
575
 
519
- @abstractmethod
520
- @setdoc.basic
521
- def __mutate__(
522
- self: Self, /
523
- ) -> ContextManager[__Mutable__[Key, Value]]: ...
524
576
  @setdoc.basic
525
- def copy(self: Self, /) -> Self:
526
- return type(self)(self)
577
+ def popitem(self: Self, /) -> tuple[Key | str, Optional[Value]]:
578
+ # for most dict d
579
+ # dict.popitem(d) and collections.abc.MutableMapping.popitem(d)
580
+ # behave differently
581
+ with self.__mutate__() as mutable:
582
+ return mutable.popitem()
527
583
 
528
584
 
529
585
  ### DICT-SLOT ###
530
586
 
531
587
 
532
- class FrozenDictSlot[Key: abc.Hashable, Value](
588
+ class FrozenDictSlot[Key: abc.Hashable, Value]( # type: ignore[misc]
589
+ FrozenObjectSlot[FrozenDict[Key, Value]],
533
590
  FrozenDictLike[Key, Value],
534
591
  ):
535
592
  """Provide slotted frozen dict-like."""
536
593
 
537
- __slots__ = ("_slot",)
538
- _slot: FrozenDictSlot.__Frozen__[Key, Value]
539
-
540
- @setdoc.basic
541
- def __frozen__( # type: ignore[override]
542
- self: Self,
543
- ) -> FrozenDictSlot.__Frozen__[Key, Value]:
544
- return self._slot
594
+ __slots__ = ()
545
595
 
546
596
  @setdoc.basic
547
597
  def __init__(
@@ -555,19 +605,19 @@ class FrozenDictSlot[Key: abc.Hashable, Value](
555
605
 
556
606
  class MutableDictSlot[Key: abc.Hashable, Value](
557
607
  MutableDictLike[Key, Value],
608
+ ObjectSlot[FrozenDict[Key, Value]],
558
609
  ):
559
610
  """Provide slotted mutable dict-like."""
560
611
 
561
- __slots__ = ("_slot",)
562
- _slot: FrozenDictSlot.__Frozen__[Key, Value]
612
+ __slots__ = ()
563
613
 
564
614
  @contextmanager
565
615
  @setdoc.basic
566
616
  def __mutate__(
567
617
  self: Self,
568
618
  /,
569
- ) -> abc.Generator[MutableDictSlot.__Mutable__[Key, Value], None, None]:
570
- slot: MutableDictSlot.__Mutable__[Key, Value]
619
+ ) -> abc.Generator[Dict[Key, Value], None, None]:
620
+ slot: Dict[Key, Value]
571
621
  slot = dict(getattr(self, "_slot", ()))
572
622
  yield slot
573
623
  self._slot = frozendict(slot)
@@ -580,11 +630,10 @@ class Sequence[Item](Collection[Item], abc.Sequence[Item]):
580
630
  """Provide abc for customized sequence."""
581
631
 
582
632
  __slots__ = ()
583
- type __Frozen__[Item_] = Sequence_Frozen[Item_]
584
633
 
585
634
  @abstractmethod
586
635
  @setdoc.basic
587
- def __frozen__(self: Self, /) -> __Frozen__[Item]: ...
636
+ def __frozen__(self: Self, /) -> Sequence_Frozen[Item]: ...
588
637
  @overload
589
638
  @setdoc.basic
590
639
  def __getitem__(self: Self, key: int, /) -> Item: ...
@@ -598,11 +647,14 @@ class Sequence[Item](Collection[Item], abc.Sequence[Item]):
598
647
  return self.__frozen__()[key]
599
648
 
600
649
 
601
- class MutableSequence[Item](Sequence[Item], abc.MutableSequence[Item]):
650
+ class MutableSequence[Item](
651
+ Sequence[Item],
652
+ abc.MutableSequence[Item],
653
+ MutableObject[Sequence_Frozen[Item], MutableSequence_Mutable[Item]],
654
+ ):
602
655
  """Provide abc for custom mutable sequence."""
603
656
 
604
657
  __slots__ = ()
605
- type __Mutable__[Item_] = MutableSequence_Mutable[Item_]
606
658
 
607
659
  @overload
608
660
  @setdoc.basic
@@ -630,10 +682,6 @@ class MutableSequence[Item](Sequence[Item], abc.MutableSequence[Item]):
630
682
  with self.__mutate__() as mutable:
631
683
  return mutable[key]
632
684
 
633
- @abstractmethod
634
- @setdoc.basic
635
- def __mutate__(self: Self, /) -> ContextManager[__Mutable__[Item]]: ...
636
-
637
685
  @overload
638
686
  @setdoc.basic
639
687
  def __setitem__(self: Self, key: int, value: Item, /) -> None: ...
@@ -664,9 +712,6 @@ class ListLike[Item](Sequence[Item]):
664
712
 
665
713
  __slots__ = ()
666
714
 
667
- type __Frozen__[Item_] = tuple[Item_, ...]
668
- # Frozen has to be tuple to allow covariance
669
-
670
715
  @setdoc.basic
671
716
  def __add__[Item_](
672
717
  self: Self, other: ListLike[Item_], /
@@ -685,7 +730,9 @@ class ListLike[Item](Sequence[Item]):
685
730
 
686
731
  @abstractmethod
687
732
  @setdoc.basic
688
- def __frozen__(self: Self, /) -> __Frozen__[Item]: ...
733
+ def __frozen__(self: Self, /) -> tuple[Item, ...]:
734
+ # __frozen__ has to be tuple to allow covariance
735
+ ...
689
736
 
690
737
  @setdoc.basic
691
738
  def __ge__(self: Self, other: ListLike[Any], /) -> bool:
@@ -758,17 +805,19 @@ class FrozenListLike[Item](ListLike[Item], abc.Hashable):
758
805
  __slots__ = ()
759
806
 
760
807
  @setdoc.basic
761
- def __hash__(self: Self) -> int:
808
+ def __hash__(self: Self, /) -> int:
762
809
  return hash(self.__frozen__())
763
810
 
764
811
 
765
- class MutableListLike[Item](ListLike[Item], MutableSequence[Item]):
812
+ class MutableListLike[Item](
813
+ ListLike[Item],
814
+ MutableObjectLike[tuple[Item, ...], list[Item]],
815
+ MutableSequence[Item],
816
+ ):
766
817
  """Provide abc for custom mutable list-like."""
767
818
 
768
819
  __slots__ = ()
769
820
 
770
- type __Mutable__[Item_] = list[Item_]
771
-
772
821
  @overload
773
822
  @setdoc.basic
774
823
  def __delitem__(self: Self, key: SupportsIndex, /) -> None: ...
@@ -783,7 +832,7 @@ class MutableListLike[Item](ListLike[Item], MutableSequence[Item]):
783
832
  del mutable[key]
784
833
 
785
834
  @setdoc.basic
786
- def __frozen__(self: Self) -> MutableListLike.__Frozen__[Item]:
835
+ def __frozen__(self: Self) -> tuple[Item, ...]:
787
836
  with self.__mutate__() as mutable:
788
837
  return tuple(mutable)
789
838
 
@@ -798,10 +847,6 @@ class MutableListLike[Item](ListLike[Item], MutableSequence[Item]):
798
847
  with self.__mutate__() as mutable:
799
848
  mutable.extend(data)
800
849
 
801
- @abstractmethod
802
- @setdoc.basic
803
- def __mutate__(self: Self, /) -> ContextManager[__Mutable__[Item]]: ...
804
-
805
850
  @overload
806
851
  @setdoc.basic
807
852
  def __setitem__(
@@ -822,10 +867,6 @@ class MutableListLike[Item](ListLike[Item], MutableSequence[Item]):
822
867
  with self.__mutate__() as mutable:
823
868
  mutable[key] = value # type: ignore
824
869
 
825
- @setdoc.basic
826
- def copy(self: Self) -> Self:
827
- return type(self)(self)
828
-
829
870
  @setdoc.basic
830
871
  def insert(self: Self, index: SupportsIndex, item: Item, /) -> None:
831
872
  with self.__mutate__() as mutable:
@@ -844,26 +885,26 @@ class MutableListLike[Item](ListLike[Item], MutableSequence[Item]):
844
885
  ### LIST-SLOT ###
845
886
 
846
887
 
847
- class FrozenListSlot[Item](FrozenListLike[Item]):
888
+ class FrozenListSlot[Item](
889
+ FrozenObjectSlot[tuple[Item, ...]],
890
+ FrozenListLike[Item],
891
+ ):
848
892
  """Provide slotted frozen list-like."""
849
893
 
850
- __slots__ = ("_slot",)
851
- _slot: FrozenListSlot.__Frozen__[Item]
852
-
853
- @setdoc.basic
854
- def __frozen__(self: Self) -> FrozenListSlot.__Frozen__[Item]:
855
- return self._slot
894
+ __slots__ = ()
856
895
 
857
896
  @setdoc.basic
858
897
  def __init__(self: Self, data: abc.Iterable[Item] = (), /) -> None:
859
898
  self._slot = tuple(data)
860
899
 
861
900
 
862
- class MutableListSlot[Item](MutableListLike[Item]):
901
+ class MutableListSlot[Item](
902
+ MutableListLike[Item],
903
+ ObjectSlot[tuple[Item, ...]],
904
+ ):
863
905
  """Provide slotted mutable list-like."""
864
906
 
865
- __slots__ = ("_slot",)
866
- _slot: MutableListSlot.__Frozen__[Item]
907
+ __slots__ = ()
867
908
 
868
909
  @contextmanager
869
910
  @setdoc.basic
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: datahold
3
- Version: 4.0.0.dev26
3
+ Version: 4.0.0.dev28
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
@@ -20,15 +20,17 @@ src/datahold.egg-info/dependency_links.txt
20
20
  src/datahold.egg-info/requires.txt
21
21
  src/datahold.egg-info/top_level.txt
22
22
  tests/test_FrozenListSlot.py
23
+ tests/test_FrozenSetSlot.py
23
24
  tests/test_MutableDictSlot.py
24
25
  tests/test_MutableListSlot.py
26
+ tests/test_MutableSetSlot.py
25
27
  tests/test_abstractmethods.py
26
28
  tests/test_all.py
27
29
  tests/test_attributes.py
28
30
  tests/test_docs.py
29
31
  tests/test_generic.py
30
- tests/test_internal_comparison.py
31
32
  tests/test_issubclass.py
33
+ tests/test_metaclass.py
32
34
  tests/test_name.py
33
35
  tests/test_nested.py
34
36
  tests/test_sorted.py