datahold 4.0.0.dev33__tar.gz → 4.0.0.dev40__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 (44) hide show
  1. {datahold-4.0.0.dev33 → datahold-4.0.0.dev40}/PKG-INFO +7 -4
  2. {datahold-4.0.0.dev33 → datahold-4.0.0.dev40}/pyproject.toml +7 -4
  3. datahold-4.0.0.dev40/src/datahold/__init__.py +304 -0
  4. {datahold-4.0.0.dev33 → datahold-4.0.0.dev40}/src/datahold.egg-info/PKG-INFO +7 -4
  5. {datahold-4.0.0.dev33 → datahold-4.0.0.dev40}/src/datahold.egg-info/SOURCES.txt +0 -17
  6. datahold-4.0.0.dev40/src/datahold.egg-info/requires.txt +5 -0
  7. datahold-4.0.0.dev40/tests/test_MutableListSlot.py +539 -0
  8. datahold-4.0.0.dev40/tests/testdata.toml +0 -0
  9. datahold-4.0.0.dev33/docs/v4.0.rst +0 -667
  10. datahold-4.0.0.dev33/src/datahold/__init__.py +0 -1048
  11. datahold-4.0.0.dev33/src/datahold.egg-info/requires.txt +0 -2
  12. datahold-4.0.0.dev33/tests/test_FrozenDictSlot.py +0 -585
  13. datahold-4.0.0.dev33/tests/test_FrozenListSlot.py +0 -602
  14. datahold-4.0.0.dev33/tests/test_FrozenSetSlot.py +0 -504
  15. datahold-4.0.0.dev33/tests/test_MutableDictSlot.py +0 -713
  16. datahold-4.0.0.dev33/tests/test_MutableListSlot.py +0 -1063
  17. datahold-4.0.0.dev33/tests/test_MutableSetSlot.py +0 -824
  18. datahold-4.0.0.dev33/tests/test_abstractmethods.py +0 -32
  19. datahold-4.0.0.dev33/tests/test_all.py +0 -37
  20. datahold-4.0.0.dev33/tests/test_attributes.py +0 -43
  21. datahold-4.0.0.dev33/tests/test_docs.py +0 -43
  22. datahold-4.0.0.dev33/tests/test_generic.py +0 -36
  23. datahold-4.0.0.dev33/tests/test_issubclass.py +0 -36
  24. datahold-4.0.0.dev33/tests/test_metaclass.py +0 -26
  25. datahold-4.0.0.dev33/tests/test_name.py +0 -80
  26. datahold-4.0.0.dev33/tests/test_nested.py +0 -46
  27. datahold-4.0.0.dev33/tests/test_sorted.py +0 -48
  28. datahold-4.0.0.dev33/tests/test_variance.py +0 -42
  29. datahold-4.0.0.dev33/tests/testdata.toml +0 -345
  30. {datahold-4.0.0.dev33 → datahold-4.0.0.dev40}/LICENSE.txt +0 -0
  31. {datahold-4.0.0.dev33 → datahold-4.0.0.dev40}/MANIFEST.in +0 -0
  32. {datahold-4.0.0.dev33 → datahold-4.0.0.dev40}/README.rst +0 -0
  33. {datahold-4.0.0.dev33 → datahold-4.0.0.dev40}/docs/v1.1.rst +0 -0
  34. {datahold-4.0.0.dev33 → datahold-4.0.0.dev40}/docs/v1.2.rst +0 -0
  35. {datahold-4.0.0.dev33 → datahold-4.0.0.dev40}/docs/v2.0.rst +0 -0
  36. {datahold-4.0.0.dev33 → datahold-4.0.0.dev40}/docs/v2.1.rst +0 -0
  37. {datahold-4.0.0.dev33 → datahold-4.0.0.dev40}/docs/v2.2.rst +0 -0
  38. {datahold-4.0.0.dev33 → datahold-4.0.0.dev40}/docs/v2.3.rst +0 -0
  39. {datahold-4.0.0.dev33 → datahold-4.0.0.dev40}/docs/v3.0.rst +0 -0
  40. {datahold-4.0.0.dev33 → datahold-4.0.0.dev40}/run_tests.py +0 -0
  41. {datahold-4.0.0.dev33 → datahold-4.0.0.dev40}/setup.cfg +0 -0
  42. {datahold-4.0.0.dev33 → datahold-4.0.0.dev40}/src/datahold/py.typed +0 -0
  43. {datahold-4.0.0.dev33 → datahold-4.0.0.dev40}/src/datahold.egg-info/dependency_links.txt +0 -0
  44. {datahold-4.0.0.dev33 → datahold-4.0.0.dev40}/src/datahold.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: datahold
3
- Version: 4.0.0.dev33
3
+ Version: 4.0.0.dev40
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
@@ -16,11 +16,14 @@ Classifier: Programming Language :: Python
16
16
  Classifier: Programming Language :: Python :: 3
17
17
  Classifier: Programming Language :: Python :: 3 :: Only
18
18
  Classifier: Typing :: Typed
19
- Requires-Python: >=3.11
19
+ Requires-Python: >=3.12
20
20
  Description-Content-Type: text/x-rst
21
21
  License-File: LICENSE.txt
22
- Requires-Dist: frozendict<3,>=2.4.7
23
- Requires-Dist: setdoc<2,>=1.3.24
22
+ Requires-Dist: cmp3<2,>=1.1
23
+ Requires-Dist: copyable<2,>=1.1
24
+ Requires-Dist: frozendict<3,>=2.4.6
25
+ Requires-Dist: iterprod<2,>=1.1
26
+ Requires-Dist: setdoc<2,>=1.4
24
27
  Dynamic: license-file
25
28
 
26
29
  ========
@@ -19,8 +19,11 @@ classifiers = [
19
19
  "Typing :: Typed",
20
20
  ]
21
21
  dependencies = [
22
- "frozendict>=2.4.7,<3",
23
- "setdoc>=1.3.24,<2",
22
+ "cmp3>=1.1,<2",
23
+ "copyable>=1.1,<2",
24
+ "frozendict>=2.4.6,<3",
25
+ "iterprod>=1.1,<2",
26
+ "setdoc>=1.4,<2",
24
27
  ]
25
28
  description = "This project wraps common mutable datastructures for inheritance with modification."
26
29
  keywords = []
@@ -30,8 +33,8 @@ license-files = [
30
33
  ]
31
34
  name = "datahold"
32
35
  readme = "README.rst"
33
- requires-python = ">=3.11"
34
- version = "4.0.0.dev33"
36
+ requires-python = ">=3.12"
37
+ version = "4.0.0.dev40"
35
38
 
36
39
  [project.urls]
37
40
  Download = "https://pypi.org/project/datahold/#files"
@@ -0,0 +1,304 @@
1
+ """Provide easily customized collections."""
2
+
3
+ from __future__ import annotations
4
+
5
+ __all__: list[str] = ["MutableListSlot"]
6
+
7
+ import sys
8
+ from collections import abc
9
+ from contextlib import contextmanager
10
+ from types import NotImplementedType
11
+ from typing import Any, Protocol, Self, SupportsIndex, overload
12
+
13
+ import setdoc
14
+
15
+ ### PROTOCOLS ###
16
+
17
+
18
+ class SupportsDunderGE[Other](Protocol):
19
+ def __ge__(self: Any, other: Other, /) -> bool: ...
20
+ class SupportsDunderGT[Other](Protocol):
21
+ def __gt__(self: Any, other: Other, /) -> bool: ...
22
+ class SupportsDunderLE[Other](Protocol):
23
+ def __le__(self: Any, other: Other, /) -> bool: ...
24
+ class SupportsDunderLT[Other](Protocol):
25
+ def __lt__(self: Any, other: Other, /) -> bool: ...
26
+
27
+
28
+ ### ALIASES ###
29
+
30
+ type Slice[Index] = slice[Index | None, Index | None, Index | None]
31
+ type Sort = SupportsDunderGT[Self] | SupportsDunderGT[Self] # type: ignore[misc]
32
+
33
+ ### LIST-SLOT ###
34
+
35
+
36
+ class MutableListSlot[Item]:
37
+ """Provide easily customized, slotted, mutable list-like."""
38
+
39
+ __slots__ = ("_slot",)
40
+
41
+ _slot: tuple[Item, ...]
42
+
43
+ def __add__[Item_](
44
+ self: MutableListSlot[Item],
45
+ other: MutableListSlot[Item_],
46
+ /,
47
+ ) -> MutableListSlot[Item | Item_]:
48
+ if isinstance(other, MutableListSlot):
49
+ return self.__type__(self.__frozen__() + other.__frozen__())
50
+ else:
51
+ return NotImplemented
52
+
53
+ def __contains__(self: MutableListSlot[Item], other: object, /) -> bool:
54
+ return other in self.__frozen__()
55
+
56
+ @overload
57
+ def __delitem__(
58
+ self: MutableListSlot[Item],
59
+ key: SupportsIndex,
60
+ /,
61
+ ) -> None: ...
62
+ @overload
63
+ def __delitem__(
64
+ self: MutableListSlot[Item],
65
+ key: Slice[SupportsIndex],
66
+ /,
67
+ ) -> None: ...
68
+ def __delitem__(
69
+ self: MutableListSlot[Item],
70
+ key: Any,
71
+ /,
72
+ ) -> None:
73
+ with self.__mutate__() as mutable:
74
+ del mutable[key]
75
+
76
+ def __eq__(
77
+ self: MutableListSlot[Item], other: object, /
78
+ ) -> NotImplementedType | bool:
79
+ if isinstance(other, MutableListSlot):
80
+ return self.__frozen__() == other.__frozen__()
81
+ else:
82
+ return NotImplemented
83
+
84
+ def __frozen__(self: MutableListSlot[Item], /) -> tuple[Item, ...]:
85
+ return self._slot
86
+
87
+ def __ge__(
88
+ self: MutableListSlot[Item],
89
+ other: MutableListSlot[SupportsDunderLE[Item]],
90
+ /,
91
+ ) -> bool:
92
+ return self.__frozen__() >= other.__frozen__() # type: ignore[no-any-return, operator]
93
+
94
+ @overload
95
+ def __getitem__(
96
+ self: MutableListSlot[Item], key: SupportsIndex, /
97
+ ) -> Item: ...
98
+ @overload
99
+ def __getitem__(
100
+ self: MutableListSlot[Item], key: Slice[SupportsIndex], /
101
+ ) -> MutableListSlot[Item]: ...
102
+ def __getitem__(self: MutableListSlot[Item], key: Any, /) -> Any:
103
+ if isinstance(key, SupportsIndex):
104
+ return self.__frozen__()[key]
105
+ else:
106
+ return self.__type__(self.__frozen__()[key])
107
+
108
+ def __gt__(
109
+ self: MutableListSlot[Item],
110
+ other: MutableListSlot[SupportsDunderLT[Item]],
111
+ /,
112
+ ) -> bool:
113
+ return self.__frozen__() > other.__frozen__() # type: ignore[no-any-return, operator]
114
+
115
+ def __iadd__( # type: ignore[misc]
116
+ self: MutableListSlot[Item],
117
+ other: abc.Iterable[Item],
118
+ /,
119
+ ) -> MutableListSlot[Item]:
120
+ with self.__mutate__() as mutable:
121
+ mutable += other
122
+ return self
123
+
124
+ def __imul__(
125
+ self: MutableListSlot[Item],
126
+ other: SupportsIndex,
127
+ /,
128
+ ) -> MutableListSlot[Item]:
129
+ with self.__mutate__() as mutable:
130
+ mutable *= other
131
+ return self
132
+
133
+ def __init__(
134
+ self: MutableListSlot[Item],
135
+ other: abc.Iterable[Item] = (),
136
+ /,
137
+ ) -> None:
138
+ self.extend(other)
139
+
140
+ def __iter__(
141
+ self: MutableListSlot[Item], /
142
+ ) -> abc.Generator[Item, None, None]:
143
+ i: int
144
+ i = 0
145
+ while True:
146
+ try:
147
+ v = self[i]
148
+ except IndexError:
149
+ return
150
+ yield v
151
+ i += 1
152
+
153
+ def __le__(
154
+ self: MutableListSlot[Item],
155
+ other: MutableListSlot[SupportsDunderGE[Item]],
156
+ /,
157
+ ) -> bool:
158
+ return self.__frozen__() <= other.__frozen__() # type: ignore[no-any-return, operator]
159
+
160
+ def __len__(self: MutableListSlot[Item], /) -> int:
161
+ return len(self.__frozen__())
162
+
163
+ def __lt__(
164
+ self: MutableListSlot[Item],
165
+ other: MutableListSlot[SupportsDunderGT[Item]],
166
+ /,
167
+ ) -> bool:
168
+ return self.__frozen__() < other.__frozen__() # type: ignore[no-any-return, operator]
169
+
170
+ def __mul__(
171
+ self: MutableListSlot[Item], other: SupportsIndex, /
172
+ ) -> MutableListSlot[Item]:
173
+ return self.__type__(self.__frozen__() * other)
174
+
175
+ __rmul__ = __mul__
176
+
177
+ @contextmanager
178
+ def __mutate__(
179
+ self: MutableListSlot[Item], /
180
+ ) -> abc.Generator[list[Item]]:
181
+ mutable: list[Item]
182
+ mutable = list(getattr(self, "_slot", ()))
183
+ yield mutable
184
+ self._slot = tuple(mutable)
185
+
186
+ def __repr__(self: MutableListSlot[Item], /) -> str:
187
+ return f"{type(self).__name__}({list(self.__frozen__())})"
188
+
189
+ def __reversed__(
190
+ self: MutableListSlot[Item], /
191
+ ) -> abc.Generator[Item, None, None]:
192
+ i: int
193
+ for i in reversed(range(len(self))):
194
+ yield self[i]
195
+
196
+ @overload
197
+ def __setitem__(
198
+ self: MutableListSlot[Item],
199
+ key: SupportsIndex,
200
+ value: Item,
201
+ /,
202
+ ) -> None: ...
203
+ @overload
204
+ def __setitem__(
205
+ self: MutableListSlot[Item],
206
+ key: Slice[SupportsIndex],
207
+ value: abc.Iterable[Item],
208
+ /,
209
+ ) -> None: ...
210
+ def __setitem__(
211
+ self: MutableListSlot[Item],
212
+ key: Any,
213
+ value: Any,
214
+ /,
215
+ ) -> None:
216
+ with self.__mutate__() as mutable:
217
+ mutable[key] = value
218
+
219
+ @classmethod
220
+ def __type__[Item_](
221
+ cls: type[MutableListSlot[Item]],
222
+ other: abc.Iterable[Item_],
223
+ /,
224
+ ) -> MutableListSlot[Item_]:
225
+ return MutableListSlot(other)
226
+
227
+ def append(self: MutableListSlot[Item], item: Item, /) -> None:
228
+ with self.__mutate__() as mutable:
229
+ mutable.append(item)
230
+
231
+ def clear(self: MutableListSlot[Item], /) -> None:
232
+ with self.__mutate__() as mutable:
233
+ mutable.clear()
234
+
235
+ def copy(self: MutableListSlot[Item], /) -> MutableListSlot[Item]:
236
+ return self.__type__(self.__frozen__())
237
+
238
+ def count(self: MutableListSlot[Item], item: object, /) -> int:
239
+ return self.__frozen__().count(item)
240
+
241
+ def extend(
242
+ self: MutableListSlot[Item], other: abc.Iterable[Item], /
243
+ ) -> None:
244
+ with self.__mutate__() as mutable:
245
+ mutable.extend(other)
246
+
247
+ def index(
248
+ self: MutableListSlot[Item],
249
+ item: Item,
250
+ start: SupportsIndex = 0,
251
+ stop: SupportsIndex = sys.maxsize,
252
+ /,
253
+ ) -> int:
254
+ return self.__frozen__().index(item, start, stop)
255
+
256
+ def insert(
257
+ self: MutableListSlot[Item], index: SupportsIndex, item: Item, /
258
+ ) -> None:
259
+ with self.__mutate__() as mutable:
260
+ mutable.insert(index, item)
261
+
262
+ def pop(self: MutableListSlot[Item], index: SupportsIndex = -1, /) -> Item:
263
+ with self.__mutate__() as mutable:
264
+ return mutable.pop(index)
265
+
266
+ def remove(self: MutableListSlot[Item], item: object, /) -> None:
267
+ with self.__mutate__() as mutable:
268
+ mutable.remove(
269
+ item, # type: ignore[arg-type]
270
+ )
271
+
272
+ def reverse(self: MutableListSlot[Item], /) -> None:
273
+ with self.__mutate__() as mutable:
274
+ mutable.reverse()
275
+
276
+ @overload
277
+ def sort[T: Sort](
278
+ self: MutableListSlot[T],
279
+ /,
280
+ *,
281
+ reverse: bool = False,
282
+ ) -> None: ...
283
+ @overload
284
+ def sort[T: Sort](
285
+ self: MutableListSlot[Item],
286
+ /,
287
+ *,
288
+ key: abc.Callable[[Item], T],
289
+ reverse: bool = False,
290
+ ) -> None: ...
291
+ def sort(
292
+ self: MutableListSlot[Item],
293
+ /,
294
+ *,
295
+ key: Any = None,
296
+ reverse: bool = False,
297
+ ) -> None:
298
+ with self.__mutate__() as mutable:
299
+ mutable.sort(key=key, reverse=reverse)
300
+
301
+
302
+ setdoc.Basics(
303
+ excepts=(AttributeError, TypeError),
304
+ )(*MutableListSlot.__dict__)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: datahold
3
- Version: 4.0.0.dev33
3
+ Version: 4.0.0.dev40
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
@@ -16,11 +16,14 @@ Classifier: Programming Language :: Python
16
16
  Classifier: Programming Language :: Python :: 3
17
17
  Classifier: Programming Language :: Python :: 3 :: Only
18
18
  Classifier: Typing :: Typed
19
- Requires-Python: >=3.11
19
+ Requires-Python: >=3.12
20
20
  Description-Content-Type: text/x-rst
21
21
  License-File: LICENSE.txt
22
- Requires-Dist: frozendict<3,>=2.4.7
23
- Requires-Dist: setdoc<2,>=1.3.24
22
+ Requires-Dist: cmp3<2,>=1.1
23
+ Requires-Dist: copyable<2,>=1.1
24
+ Requires-Dist: frozendict<3,>=2.4.6
25
+ Requires-Dist: iterprod<2,>=1.1
26
+ Requires-Dist: setdoc<2,>=1.4
24
27
  Dynamic: license-file
25
28
 
26
29
  ========
@@ -11,7 +11,6 @@ docs/v2.1.rst
11
11
  docs/v2.2.rst
12
12
  docs/v2.3.rst
13
13
  docs/v3.0.rst
14
- docs/v4.0.rst
15
14
  src/datahold/__init__.py
16
15
  src/datahold/py.typed
17
16
  src/datahold.egg-info/PKG-INFO
@@ -19,21 +18,5 @@ src/datahold.egg-info/SOURCES.txt
19
18
  src/datahold.egg-info/dependency_links.txt
20
19
  src/datahold.egg-info/requires.txt
21
20
  src/datahold.egg-info/top_level.txt
22
- tests/test_FrozenDictSlot.py
23
- tests/test_FrozenListSlot.py
24
- tests/test_FrozenSetSlot.py
25
- tests/test_MutableDictSlot.py
26
21
  tests/test_MutableListSlot.py
27
- tests/test_MutableSetSlot.py
28
- tests/test_abstractmethods.py
29
- tests/test_all.py
30
- tests/test_attributes.py
31
- tests/test_docs.py
32
- tests/test_generic.py
33
- tests/test_issubclass.py
34
- tests/test_metaclass.py
35
- tests/test_name.py
36
- tests/test_nested.py
37
- tests/test_sorted.py
38
- tests/test_variance.py
39
22
  tests/testdata.toml
@@ -0,0 +1,5 @@
1
+ cmp3<2,>=1.1
2
+ copyable<2,>=1.1
3
+ frozendict<3,>=2.4.6
4
+ iterprod<2,>=1.1
5
+ setdoc<2,>=1.4