datahold 4.0.0.dev32__tar.gz → 4.0.0.dev33__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 (40) hide show
  1. {datahold-4.0.0.dev32 → datahold-4.0.0.dev33}/PKG-INFO +1 -1
  2. {datahold-4.0.0.dev32 → datahold-4.0.0.dev33}/pyproject.toml +1 -1
  3. {datahold-4.0.0.dev32 → datahold-4.0.0.dev33}/src/datahold/__init__.py +84 -8
  4. {datahold-4.0.0.dev32 → datahold-4.0.0.dev33}/src/datahold.egg-info/PKG-INFO +1 -1
  5. {datahold-4.0.0.dev32 → datahold-4.0.0.dev33}/tests/testdata.toml +4 -0
  6. {datahold-4.0.0.dev32 → datahold-4.0.0.dev33}/LICENSE.txt +0 -0
  7. {datahold-4.0.0.dev32 → datahold-4.0.0.dev33}/MANIFEST.in +0 -0
  8. {datahold-4.0.0.dev32 → datahold-4.0.0.dev33}/README.rst +0 -0
  9. {datahold-4.0.0.dev32 → datahold-4.0.0.dev33}/docs/v1.1.rst +0 -0
  10. {datahold-4.0.0.dev32 → datahold-4.0.0.dev33}/docs/v1.2.rst +0 -0
  11. {datahold-4.0.0.dev32 → datahold-4.0.0.dev33}/docs/v2.0.rst +0 -0
  12. {datahold-4.0.0.dev32 → datahold-4.0.0.dev33}/docs/v2.1.rst +0 -0
  13. {datahold-4.0.0.dev32 → datahold-4.0.0.dev33}/docs/v2.2.rst +0 -0
  14. {datahold-4.0.0.dev32 → datahold-4.0.0.dev33}/docs/v2.3.rst +0 -0
  15. {datahold-4.0.0.dev32 → datahold-4.0.0.dev33}/docs/v3.0.rst +0 -0
  16. {datahold-4.0.0.dev32 → datahold-4.0.0.dev33}/docs/v4.0.rst +0 -0
  17. {datahold-4.0.0.dev32 → datahold-4.0.0.dev33}/run_tests.py +0 -0
  18. {datahold-4.0.0.dev32 → datahold-4.0.0.dev33}/setup.cfg +0 -0
  19. {datahold-4.0.0.dev32 → datahold-4.0.0.dev33}/src/datahold/py.typed +0 -0
  20. {datahold-4.0.0.dev32 → datahold-4.0.0.dev33}/src/datahold.egg-info/SOURCES.txt +0 -0
  21. {datahold-4.0.0.dev32 → datahold-4.0.0.dev33}/src/datahold.egg-info/dependency_links.txt +0 -0
  22. {datahold-4.0.0.dev32 → datahold-4.0.0.dev33}/src/datahold.egg-info/requires.txt +0 -0
  23. {datahold-4.0.0.dev32 → datahold-4.0.0.dev33}/src/datahold.egg-info/top_level.txt +0 -0
  24. {datahold-4.0.0.dev32 → datahold-4.0.0.dev33}/tests/test_FrozenDictSlot.py +0 -0
  25. {datahold-4.0.0.dev32 → datahold-4.0.0.dev33}/tests/test_FrozenListSlot.py +0 -0
  26. {datahold-4.0.0.dev32 → datahold-4.0.0.dev33}/tests/test_FrozenSetSlot.py +0 -0
  27. {datahold-4.0.0.dev32 → datahold-4.0.0.dev33}/tests/test_MutableDictSlot.py +0 -0
  28. {datahold-4.0.0.dev32 → datahold-4.0.0.dev33}/tests/test_MutableListSlot.py +0 -0
  29. {datahold-4.0.0.dev32 → datahold-4.0.0.dev33}/tests/test_MutableSetSlot.py +0 -0
  30. {datahold-4.0.0.dev32 → datahold-4.0.0.dev33}/tests/test_abstractmethods.py +0 -0
  31. {datahold-4.0.0.dev32 → datahold-4.0.0.dev33}/tests/test_all.py +0 -0
  32. {datahold-4.0.0.dev32 → datahold-4.0.0.dev33}/tests/test_attributes.py +0 -0
  33. {datahold-4.0.0.dev32 → datahold-4.0.0.dev33}/tests/test_docs.py +0 -0
  34. {datahold-4.0.0.dev32 → datahold-4.0.0.dev33}/tests/test_generic.py +0 -0
  35. {datahold-4.0.0.dev32 → datahold-4.0.0.dev33}/tests/test_issubclass.py +0 -0
  36. {datahold-4.0.0.dev32 → datahold-4.0.0.dev33}/tests/test_metaclass.py +0 -0
  37. {datahold-4.0.0.dev32 → datahold-4.0.0.dev33}/tests/test_name.py +0 -0
  38. {datahold-4.0.0.dev32 → datahold-4.0.0.dev33}/tests/test_nested.py +0 -0
  39. {datahold-4.0.0.dev32 → datahold-4.0.0.dev33}/tests/test_sorted.py +0 -0
  40. {datahold-4.0.0.dev32 → datahold-4.0.0.dev33}/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.dev32
3
+ Version: 4.0.0.dev33
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.dev32"
34
+ version = "4.0.0.dev33"
35
35
 
36
36
  [project.urls]
37
37
  Download = "https://pypi.org/project/datahold/#files"
@@ -33,15 +33,31 @@ __all__: list[str] = [
33
33
  "SetLike",
34
34
  ]
35
35
 
36
+ import enum
36
37
  from abc import ABCMeta, abstractmethod
37
38
  from collections import abc
38
39
  from contextlib import contextmanager
39
40
  from types import NotImplementedType, TracebackType
40
- from typing import Any, Never, Protocol, Self, SupportsIndex, overload
41
+ from typing import (
42
+ Any,
43
+ Never,
44
+ Protocol,
45
+ Self,
46
+ SupportsIndex,
47
+ overload,
48
+ runtime_checkable,
49
+ )
41
50
 
42
51
  import setdoc
43
52
  from frozendict import frozendict
44
53
 
54
+ ### SENTINEL ###
55
+
56
+
57
+ class Missing(enum.Enum):
58
+ MISSING = enum.auto()
59
+
60
+
45
61
  ### PROTOCOLS ###
46
62
 
47
63
 
@@ -61,7 +77,8 @@ class ContextManager[Enter](Protocol):
61
77
  ) -> object: ...
62
78
 
63
79
 
64
- class SupportsKeysAndGetitem[Key, Value](Protocol):
80
+ @runtime_checkable
81
+ class SupportsKeysAndGetItem[Key, Value](Protocol):
65
82
  """Provide protocol supporting keys and __getitem__."""
66
83
 
67
84
  @setdoc.basic
@@ -91,7 +108,7 @@ class Mapping_Frozen[Key, Value](Collection_Frozen[Key], Protocol):
91
108
  def __getitem__(self: Self, key: Never, /) -> Value: ...
92
109
 
93
110
 
94
- class SupportsDelitemAndSetitem[Key, Value](
111
+ class SupportsDelItemAndSetItem[Key, Value](
95
112
  Protocol,
96
113
  ):
97
114
  @setdoc.basic
@@ -167,8 +184,9 @@ class MutableSequence_Mutable[Item](Protocol):
167
184
  type Dict[Key, Value] = dict[Key | str, Value | None]
168
185
 
169
186
  type Dict_Init[Key, Value] = (
170
- SupportsKeysAndGetitem[Key, Value | None]
171
- | SupportsKeysAndGetitem[Key | str, Value | None]
187
+ SupportsKeysAndGetItem[Key, Value | None]
188
+ | SupportsKeysAndGetItem[str, Value | None]
189
+ | SupportsKeysAndGetItem[Key | str, Value | None]
172
190
  | abc.Iterable[tuple[Key | str, Value | None]]
173
191
  )
174
192
 
@@ -322,9 +340,11 @@ class SetLike[Item: abc.Hashable](Set[Item]):
322
340
  @abstractmethod
323
341
  @setdoc.basic
324
342
  def __frozen__(self: Self, /) -> frozenset[Item]: ...
343
+
325
344
  @abstractmethod
326
345
  @setdoc.basic
327
346
  def __init__(self: Self, other: abc.Iterable[Item] = (), /) -> None: ...
347
+
328
348
  @setdoc.basic
329
349
  def difference(self: Self, /, *others: abc.Iterable[abc.Hashable]) -> Self:
330
350
  return type(self)(self.__frozen__().difference(*others))
@@ -487,7 +507,7 @@ class MutableMapping[Key: abc.Hashable, Value](
487
507
  abc.MutableMapping[Key | str, Value | None],
488
508
  MutableObject[
489
509
  Mapping_Frozen[Key | str, Value | None],
490
- SupportsDelitemAndSetitem[Key | str, Value | None],
510
+ SupportsDelItemAndSetItem[Key | str, Value | None],
491
511
  ],
492
512
  ):
493
513
  """Provide abc for custom mutable mapping."""
@@ -506,6 +526,62 @@ class MutableMapping[Key: abc.Hashable, Value](
506
526
  with self.__mutate__() as mutable:
507
527
  mutable[key] = value
508
528
 
529
+ @overload
530
+ @setdoc.basic
531
+ def pop(self: Self, key: Key | str, /) -> Value: ...
532
+ @overload
533
+ @setdoc.basic
534
+ def pop[Value_](
535
+ self: Self, key: Key | str, default: Value_, /
536
+ ) -> Value | Value_: ...
537
+ @setdoc.basic
538
+ def pop[Value_](
539
+ self: Self,
540
+ key: Key | str,
541
+ default: Missing | Value_ = Missing.MISSING,
542
+ /,
543
+ ) -> Value | Value_ | None:
544
+ try:
545
+ value = self[key]
546
+ except KeyError:
547
+ if isinstance(default, Missing):
548
+ raise
549
+ return default
550
+ else:
551
+ del self[key]
552
+ return value
553
+
554
+ @setdoc.basic
555
+ def setdefault(
556
+ self: Self,
557
+ key: Key | str,
558
+ default: Value | None = None,
559
+ /,
560
+ ) -> Value | None:
561
+ try:
562
+ return self[key]
563
+ except KeyError:
564
+ self[key] = default
565
+ return default
566
+
567
+ @setdoc.basic
568
+ def update(
569
+ self: Self,
570
+ other: Dict_Init[Key, Value] = (),
571
+ /,
572
+ **kwargs: Value | None,
573
+ ) -> None:
574
+ key: Any
575
+ value: Value | None
576
+ if isinstance(other, SupportsKeysAndGetItem):
577
+ for key in other.keys():
578
+ self[key] = other[key]
579
+ else:
580
+ for key, value in other:
581
+ self[key] = value
582
+ for key, value in kwargs.items():
583
+ self[key] = value
584
+
509
585
 
510
586
  ### DICT-LIKE ###
511
587
 
@@ -546,7 +622,7 @@ class DictLike[Key: abc.Hashable, Value](
546
622
 
547
623
  @setdoc.basic
548
624
  def __reversed__(self: Self, /) -> abc.Iterator[Key]:
549
- yield from reversed(self.__frozen__())
625
+ return reversed(self.__frozen__())
550
626
 
551
627
  @overload
552
628
  @classmethod
@@ -610,7 +686,7 @@ class MutableDictLike[Key: abc.Hashable, Value](
610
686
  **kwargs: Value | None,
611
687
  ) -> None:
612
688
  self.update(
613
- other, # type: ignore[arg-type]
689
+ other,
614
690
  **kwargs,
615
691
  )
616
692
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: datahold
3
- Version: 4.0.0.dev32
3
+ Version: 4.0.0.dev33
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
@@ -269,6 +269,10 @@ generic = 1
269
269
  [datatypes.MutableMapping.attributes]
270
270
  __delitem__ = "datahold.MutableMapping"
271
271
  __setitem__ = "datahold.MutableMapping"
272
+ clear = "collections.abc.MutableMapping"
273
+ pop = "datahold.MutableMapping"
274
+ popitem = "datahold.MutableMapping"
275
+ setdefault = "datahold.MutableMapping"
272
276
 
273
277
  [datatypes.MutableMapping.issubclass]
274
278
  "collections.abc.MutableMapping" = true
File without changes