datahold 4.0.0.dev29__tar.gz → 4.0.0.dev31__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.dev29 → datahold-4.0.0.dev31}/PKG-INFO +1 -1
- {datahold-4.0.0.dev29 → datahold-4.0.0.dev31}/pyproject.toml +1 -1
- {datahold-4.0.0.dev29 → datahold-4.0.0.dev31}/src/datahold/__init__.py +47 -38
- {datahold-4.0.0.dev29 → datahold-4.0.0.dev31}/src/datahold.egg-info/PKG-INFO +1 -1
- datahold-4.0.0.dev31/tests/test_FrozenDictSlot.py +626 -0
- {datahold-4.0.0.dev29 → datahold-4.0.0.dev31}/tests/test_FrozenListSlot.py +160 -133
- {datahold-4.0.0.dev29 → datahold-4.0.0.dev31}/tests/test_FrozenSetSlot.py +136 -108
- {datahold-4.0.0.dev29 → datahold-4.0.0.dev31}/tests/test_MutableDictSlot.py +46 -44
- {datahold-4.0.0.dev29 → datahold-4.0.0.dev31}/tests/test_MutableListSlot.py +139 -137
- {datahold-4.0.0.dev29 → datahold-4.0.0.dev31}/tests/test_MutableSetSlot.py +74 -60
- {datahold-4.0.0.dev29 → datahold-4.0.0.dev31}/tests/test_all.py +10 -0
- {datahold-4.0.0.dev29 → datahold-4.0.0.dev31}/tests/test_nested.py +1 -1
- {datahold-4.0.0.dev29 → datahold-4.0.0.dev31}/tests/testdata.toml +5 -0
- datahold-4.0.0.dev29/tests/test_FrozenDictSlot.py +0 -271
- {datahold-4.0.0.dev29 → datahold-4.0.0.dev31}/LICENSE.txt +0 -0
- {datahold-4.0.0.dev29 → datahold-4.0.0.dev31}/MANIFEST.in +0 -0
- {datahold-4.0.0.dev29 → datahold-4.0.0.dev31}/README.rst +0 -0
- {datahold-4.0.0.dev29 → datahold-4.0.0.dev31}/docs/v1.1.rst +0 -0
- {datahold-4.0.0.dev29 → datahold-4.0.0.dev31}/docs/v1.2.rst +0 -0
- {datahold-4.0.0.dev29 → datahold-4.0.0.dev31}/docs/v2.0.rst +0 -0
- {datahold-4.0.0.dev29 → datahold-4.0.0.dev31}/docs/v2.1.rst +0 -0
- {datahold-4.0.0.dev29 → datahold-4.0.0.dev31}/docs/v2.2.rst +0 -0
- {datahold-4.0.0.dev29 → datahold-4.0.0.dev31}/docs/v2.3.rst +0 -0
- {datahold-4.0.0.dev29 → datahold-4.0.0.dev31}/docs/v3.0.rst +0 -0
- {datahold-4.0.0.dev29 → datahold-4.0.0.dev31}/docs/v4.0.rst +0 -0
- {datahold-4.0.0.dev29 → datahold-4.0.0.dev31}/run_tests.py +0 -0
- {datahold-4.0.0.dev29 → datahold-4.0.0.dev31}/setup.cfg +0 -0
- {datahold-4.0.0.dev29 → datahold-4.0.0.dev31}/src/datahold/py.typed +0 -0
- {datahold-4.0.0.dev29 → datahold-4.0.0.dev31}/src/datahold.egg-info/SOURCES.txt +0 -0
- {datahold-4.0.0.dev29 → datahold-4.0.0.dev31}/src/datahold.egg-info/dependency_links.txt +0 -0
- {datahold-4.0.0.dev29 → datahold-4.0.0.dev31}/src/datahold.egg-info/requires.txt +0 -0
- {datahold-4.0.0.dev29 → datahold-4.0.0.dev31}/src/datahold.egg-info/top_level.txt +0 -0
- {datahold-4.0.0.dev29 → datahold-4.0.0.dev31}/tests/test_abstractmethods.py +0 -0
- {datahold-4.0.0.dev29 → datahold-4.0.0.dev31}/tests/test_attributes.py +0 -0
- {datahold-4.0.0.dev29 → datahold-4.0.0.dev31}/tests/test_docs.py +0 -0
- {datahold-4.0.0.dev29 → datahold-4.0.0.dev31}/tests/test_generic.py +0 -0
- {datahold-4.0.0.dev29 → datahold-4.0.0.dev31}/tests/test_issubclass.py +0 -0
- {datahold-4.0.0.dev29 → datahold-4.0.0.dev31}/tests/test_metaclass.py +0 -0
- {datahold-4.0.0.dev29 → datahold-4.0.0.dev31}/tests/test_name.py +0 -0
- {datahold-4.0.0.dev29 → datahold-4.0.0.dev31}/tests/test_sorted.py +0 -0
- {datahold-4.0.0.dev29 → datahold-4.0.0.dev31}/tests/test_variance.py +0 -0
|
@@ -37,15 +37,7 @@ from abc import ABCMeta, abstractmethod
|
|
|
37
37
|
from collections import abc
|
|
38
38
|
from contextlib import contextmanager
|
|
39
39
|
from types import NotImplementedType, TracebackType
|
|
40
|
-
from typing import
|
|
41
|
-
Any,
|
|
42
|
-
Never,
|
|
43
|
-
Optional,
|
|
44
|
-
Protocol,
|
|
45
|
-
Self,
|
|
46
|
-
SupportsIndex,
|
|
47
|
-
overload,
|
|
48
|
-
)
|
|
40
|
+
from typing import Any, Never, Protocol, Self, SupportsIndex, overload
|
|
49
41
|
|
|
50
42
|
import setdoc
|
|
51
43
|
from frozendict import frozendict
|
|
@@ -87,7 +79,7 @@ class Collection_Frozen[Item](
|
|
|
87
79
|
def __contains__(self: Self, other: Never, /) -> bool: ...
|
|
88
80
|
|
|
89
81
|
|
|
90
|
-
class
|
|
82
|
+
class SupportsAddAndDiscard[Item: abc.Hashable](Protocol):
|
|
91
83
|
@setdoc.basic
|
|
92
84
|
def add(self: Self, item: Item, /) -> object: ...
|
|
93
85
|
@setdoc.basic
|
|
@@ -97,14 +89,14 @@ class MutableSet_Mutable[Item: abc.Hashable](Protocol):
|
|
|
97
89
|
class Mapping_Frozen[Key, Value](Collection_Frozen[Key], Protocol):
|
|
98
90
|
@setdoc.basic
|
|
99
91
|
def __getitem__(self: Self, key: Never, /) -> Value: ...
|
|
100
|
-
class
|
|
92
|
+
class SupportsDelitemAndSetitem[Key, Value](
|
|
101
93
|
Protocol,
|
|
102
94
|
):
|
|
103
95
|
@setdoc.basic
|
|
104
|
-
def __delitem__(self: Self, key:
|
|
96
|
+
def __delitem__(self: Self, key: Key | str, /) -> object: ...
|
|
105
97
|
@setdoc.basic
|
|
106
98
|
def __setitem__(
|
|
107
|
-
self: Self, key:
|
|
99
|
+
self: Self, key: Key | str, value: Value | None, /
|
|
108
100
|
) -> object: ...
|
|
109
101
|
class Sequence_Frozen[Item](
|
|
110
102
|
Collection_Frozen[Item],
|
|
@@ -170,16 +162,17 @@ class MutableSequence_Mutable[Item](Protocol):
|
|
|
170
162
|
|
|
171
163
|
### TYPE ALIASES ###
|
|
172
164
|
|
|
173
|
-
type Dict[Key, Value] = dict[Key | str,
|
|
165
|
+
type Dict[Key, Value] = dict[Key | str, Value | None]
|
|
174
166
|
|
|
175
167
|
type Dict_Init[Key, Value] = (
|
|
176
|
-
SupportsKeysAndGetitem[Key |
|
|
177
|
-
|
|
|
168
|
+
SupportsKeysAndGetitem[Key, Value | None]
|
|
169
|
+
| SupportsKeysAndGetitem[Key | str, Value | None]
|
|
170
|
+
| abc.Iterable[tuple[Key | str, Value | None]]
|
|
178
171
|
)
|
|
179
172
|
|
|
180
|
-
type FrozenDict[Key, Value] = frozendict[Key | str,
|
|
173
|
+
type FrozenDict[Key, Value] = frozendict[Key | str, Value | None]
|
|
181
174
|
|
|
182
|
-
type Slice[Index] = slice[
|
|
175
|
+
type Slice[Index] = slice[Index | None, Index | None, Index | None]
|
|
183
176
|
|
|
184
177
|
|
|
185
178
|
### OBJECT ###
|
|
@@ -299,7 +292,7 @@ class Set[Item: abc.Hashable](Collection[Item], abc.Set[Item]):
|
|
|
299
292
|
class MutableSet[Item: abc.Hashable](
|
|
300
293
|
Set[Item],
|
|
301
294
|
abc.MutableSet[Item],
|
|
302
|
-
MutableObject[Collection_Frozen[Item],
|
|
295
|
+
MutableObject[Collection_Frozen[Item], SupportsAddAndDiscard[Item]],
|
|
303
296
|
):
|
|
304
297
|
"""Provide abc for custom mutable set."""
|
|
305
298
|
|
|
@@ -470,13 +463,15 @@ class Mapping[Key: abc.Hashable, Value](
|
|
|
470
463
|
raise KeyError(key) from None
|
|
471
464
|
|
|
472
465
|
@overload
|
|
473
|
-
def get(self, key: object) ->
|
|
466
|
+
def get(self, key: object, /) -> Value | None: ...
|
|
474
467
|
@overload
|
|
475
|
-
def get[Value_](
|
|
468
|
+
def get[Value_](
|
|
469
|
+
self, key: object, default: Value_, /
|
|
470
|
+
) -> Value | Value_: ...
|
|
476
471
|
@setdoc.basic
|
|
477
472
|
def get[Value_](
|
|
478
|
-
self: Self, key: object, default:
|
|
479
|
-
) ->
|
|
473
|
+
self: Self, key: object, default: Value_ | None = None
|
|
474
|
+
) -> Value | Value_ | None:
|
|
480
475
|
# this method is just as Mapping.get
|
|
481
476
|
# with the signature corrected
|
|
482
477
|
try:
|
|
@@ -487,8 +482,11 @@ class Mapping[Key: abc.Hashable, Value](
|
|
|
487
482
|
|
|
488
483
|
class MutableMapping[Key: abc.Hashable, Value](
|
|
489
484
|
Mapping[Key, Value],
|
|
490
|
-
abc.MutableMapping[Key | str,
|
|
491
|
-
MutableObject[
|
|
485
|
+
abc.MutableMapping[Key | str, Value | None],
|
|
486
|
+
MutableObject[
|
|
487
|
+
Mapping_Frozen[Key | str, Value | None],
|
|
488
|
+
SupportsDelitemAndSetitem[Key | str, Value | None],
|
|
489
|
+
],
|
|
492
490
|
):
|
|
493
491
|
"""Provide abc for custom mutable mapping."""
|
|
494
492
|
|
|
@@ -501,7 +499,7 @@ class MutableMapping[Key: abc.Hashable, Value](
|
|
|
501
499
|
|
|
502
500
|
@setdoc.basic
|
|
503
501
|
def __setitem__(
|
|
504
|
-
self: Self, key: Key | str, value:
|
|
502
|
+
self: Self, key: Key | str, value: Value | None, /
|
|
505
503
|
) -> None:
|
|
506
504
|
with self.__mutate__() as mutable:
|
|
507
505
|
mutable[key] = value
|
|
@@ -511,7 +509,8 @@ class MutableMapping[Key: abc.Hashable, Value](
|
|
|
511
509
|
|
|
512
510
|
|
|
513
511
|
class DictLike[Key: abc.Hashable, Value](
|
|
514
|
-
Mapping[Key | str,
|
|
512
|
+
Mapping[Key | str, Value | None],
|
|
513
|
+
abc.Reversible[Key | str],
|
|
515
514
|
):
|
|
516
515
|
"""Provide abc for custom dict-like."""
|
|
517
516
|
|
|
@@ -530,26 +529,30 @@ class DictLike[Key: abc.Hashable, Value](
|
|
|
530
529
|
**kwargs: Value,
|
|
531
530
|
): ...
|
|
532
531
|
@setdoc.basic
|
|
533
|
-
def __or__[Key_, Value_](
|
|
532
|
+
def __or__[Key_: abc.Hashable, Value_](
|
|
534
533
|
self: Self,
|
|
535
534
|
other: Dict_Init[Key_, Value_],
|
|
536
535
|
/,
|
|
537
536
|
) -> DictLike[Key | Key_, Value | Value_]:
|
|
538
|
-
|
|
537
|
+
other_: FrozenDict[Key, Value]
|
|
539
538
|
try:
|
|
540
|
-
|
|
539
|
+
other_ = frozendict(other) # type: ignore[arg-type]
|
|
541
540
|
except TypeError:
|
|
542
541
|
return NotImplemented
|
|
543
542
|
return type(self)( # type: ignore[return-value]
|
|
544
|
-
self.__frozen__() |
|
|
543
|
+
self.__frozen__() | other_
|
|
545
544
|
)
|
|
546
545
|
|
|
546
|
+
@setdoc.basic
|
|
547
|
+
def __reversed__(self: Self, /) -> abc.Iterator[Key | str]:
|
|
548
|
+
yield from reversed(self.__frozen__())
|
|
549
|
+
|
|
547
550
|
@classmethod
|
|
548
551
|
@setdoc.basic
|
|
549
552
|
def fromkeys(
|
|
550
553
|
cls: type[Self],
|
|
551
554
|
iterable: abc.Iterable[Key | str],
|
|
552
|
-
value:
|
|
555
|
+
value: Value | None = None,
|
|
553
556
|
/,
|
|
554
557
|
) -> Self:
|
|
555
558
|
return cls(dict.fromkeys(iterable, value))
|
|
@@ -586,9 +589,12 @@ class MutableDictLike[Key: abc.Hashable, Value](
|
|
|
586
589
|
self: Self,
|
|
587
590
|
other: Dict_Init[Key, Value] = (),
|
|
588
591
|
/,
|
|
589
|
-
**kwargs:
|
|
592
|
+
**kwargs: Value | None,
|
|
590
593
|
):
|
|
591
|
-
self.update(
|
|
594
|
+
self.update(
|
|
595
|
+
other, # type: ignore[arg-type]
|
|
596
|
+
**kwargs,
|
|
597
|
+
)
|
|
592
598
|
|
|
593
599
|
@setdoc.basic
|
|
594
600
|
def __ior__( # type: ignore[override]
|
|
@@ -597,11 +603,11 @@ class MutableDictLike[Key: abc.Hashable, Value](
|
|
|
597
603
|
/,
|
|
598
604
|
) -> Self:
|
|
599
605
|
with self.__mutate__() as mutable:
|
|
600
|
-
mutable |= other
|
|
606
|
+
mutable |= other # type: ignore[arg-type]
|
|
601
607
|
return self
|
|
602
608
|
|
|
603
609
|
@setdoc.basic
|
|
604
|
-
def popitem(self: Self, /) -> tuple[Key | str,
|
|
610
|
+
def popitem(self: Self, /) -> tuple[Key | str, Value | None]:
|
|
605
611
|
# for most dict d
|
|
606
612
|
# dict.popitem(d) and collections.abc.MutableMapping.popitem(d)
|
|
607
613
|
# behave differently
|
|
@@ -625,9 +631,12 @@ class FrozenDictSlot[Key: abc.Hashable, Value](
|
|
|
625
631
|
self: Self,
|
|
626
632
|
other: Dict_Init[Key, Value] = (),
|
|
627
633
|
/,
|
|
628
|
-
**kwargs:
|
|
634
|
+
**kwargs: Value | None,
|
|
629
635
|
) -> None:
|
|
630
|
-
self._slot = frozendict(
|
|
636
|
+
self._slot = frozendict(
|
|
637
|
+
other, # type: ignore[arg-type]
|
|
638
|
+
**kwargs,
|
|
639
|
+
)
|
|
631
640
|
|
|
632
641
|
|
|
633
642
|
class MutableDictSlot[Key: abc.Hashable, Value](
|