datahold 4.0.0.dev8__tar.gz → 4.0.0.dev9__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.dev8 → datahold-4.0.0.dev9}/PKG-INFO +1 -1
- {datahold-4.0.0.dev8 → datahold-4.0.0.dev9}/pyproject.toml +1 -1
- {datahold-4.0.0.dev8 → datahold-4.0.0.dev9}/src/datahold/__init__.py +53 -53
- {datahold-4.0.0.dev8 → datahold-4.0.0.dev9}/src/datahold.egg-info/PKG-INFO +1 -1
- {datahold-4.0.0.dev8 → datahold-4.0.0.dev9}/tests/test_FrozenHoldDict.py +3 -3
- {datahold-4.0.0.dev8 → datahold-4.0.0.dev9}/tests/test_FrozenHoldList.py +3 -3
- {datahold-4.0.0.dev8 → datahold-4.0.0.dev9}/tests/test_FrozenHoldSet.py +3 -3
- {datahold-4.0.0.dev8 → datahold-4.0.0.dev9}/tests/test_HoldDict.py +3 -3
- {datahold-4.0.0.dev8 → datahold-4.0.0.dev9}/tests/test_HoldList.py +3 -3
- {datahold-4.0.0.dev8 → datahold-4.0.0.dev9}/tests/test_HoldSet.py +3 -3
- {datahold-4.0.0.dev8 → datahold-4.0.0.dev9}/tests/test_testdata.py +13 -11
- datahold-4.0.0.dev9/tests/testdata.toml +145 -0
- datahold-4.0.0.dev8/tests/testdata.toml +0 -145
- {datahold-4.0.0.dev8 → datahold-4.0.0.dev9}/LICENSE.txt +0 -0
- {datahold-4.0.0.dev8 → datahold-4.0.0.dev9}/MANIFEST.in +0 -0
- {datahold-4.0.0.dev8 → datahold-4.0.0.dev9}/README.rst +0 -0
- {datahold-4.0.0.dev8 → datahold-4.0.0.dev9}/docs/v1.1.rst +0 -0
- {datahold-4.0.0.dev8 → datahold-4.0.0.dev9}/docs/v1.2.rst +0 -0
- {datahold-4.0.0.dev8 → datahold-4.0.0.dev9}/docs/v2.0.rst +0 -0
- {datahold-4.0.0.dev8 → datahold-4.0.0.dev9}/docs/v2.1.rst +0 -0
- {datahold-4.0.0.dev8 → datahold-4.0.0.dev9}/docs/v2.2.rst +0 -0
- {datahold-4.0.0.dev8 → datahold-4.0.0.dev9}/docs/v2.3.rst +0 -0
- {datahold-4.0.0.dev8 → datahold-4.0.0.dev9}/docs/v3.0.rst +0 -0
- {datahold-4.0.0.dev8 → datahold-4.0.0.dev9}/docs/v4.0.rst +0 -0
- {datahold-4.0.0.dev8 → datahold-4.0.0.dev9}/run_tests.py +0 -0
- {datahold-4.0.0.dev8 → datahold-4.0.0.dev9}/setup.cfg +0 -0
- {datahold-4.0.0.dev8 → datahold-4.0.0.dev9}/src/datahold/py.typed +0 -0
- {datahold-4.0.0.dev8 → datahold-4.0.0.dev9}/src/datahold.egg-info/SOURCES.txt +0 -0
- {datahold-4.0.0.dev8 → datahold-4.0.0.dev9}/src/datahold.egg-info/dependency_links.txt +0 -0
- {datahold-4.0.0.dev8 → datahold-4.0.0.dev9}/src/datahold.egg-info/requires.txt +0 -0
- {datahold-4.0.0.dev8 → datahold-4.0.0.dev9}/src/datahold.egg-info/top_level.txt +0 -0
|
@@ -3,21 +3,21 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
__all__: list[str] = [
|
|
6
|
-
"BaseDataAbstractSet",
|
|
7
|
-
"BaseDataCollection",
|
|
8
|
-
"BaseDataDict",
|
|
9
|
-
"BaseDataList",
|
|
10
|
-
"BaseDataMapping",
|
|
11
|
-
"BaseDataSequence",
|
|
12
|
-
"BaseDataSet",
|
|
13
6
|
"BaseHoldObject",
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
7
|
+
"Collection",
|
|
8
|
+
"DictLike",
|
|
9
|
+
"FrozenDictLike",
|
|
10
|
+
"FrozenListLike",
|
|
11
|
+
"FrozenMapping",
|
|
12
|
+
"FrozenSetLike",
|
|
13
|
+
"ListLike",
|
|
14
|
+
"Mapping",
|
|
15
|
+
"MutableDictLike",
|
|
16
|
+
"MutableListLike",
|
|
17
|
+
"MutableSetLike",
|
|
18
|
+
"Sequence",
|
|
19
|
+
"Set",
|
|
20
|
+
"SetLike",
|
|
21
21
|
]
|
|
22
22
|
|
|
23
23
|
import enum
|
|
@@ -81,7 +81,7 @@ class BaseHoldObject[HoldData: Copyable]:
|
|
|
81
81
|
### COLLECTION ###
|
|
82
82
|
|
|
83
83
|
|
|
84
|
-
class
|
|
84
|
+
class Collection[Item](
|
|
85
85
|
abc.Sized,
|
|
86
86
|
abc.Iterable[Item],
|
|
87
87
|
abc.Container[object],
|
|
@@ -123,8 +123,8 @@ class BaseDataCollection[Item](
|
|
|
123
123
|
### ABSTRACT SET ###
|
|
124
124
|
|
|
125
125
|
|
|
126
|
-
class
|
|
127
|
-
|
|
126
|
+
class Set[Item](
|
|
127
|
+
Collection[Item],
|
|
128
128
|
abc.Set[Item],
|
|
129
129
|
):
|
|
130
130
|
"""Provide an easy abc for a custom (abstract) set."""
|
|
@@ -135,7 +135,7 @@ class BaseDataAbstractSet[Item](
|
|
|
135
135
|
### SET ###
|
|
136
136
|
|
|
137
137
|
|
|
138
|
-
class
|
|
138
|
+
class SetLike[Item: abc.Hashable](Set[Item]):
|
|
139
139
|
"""Provide an easy abc for custom set-like."""
|
|
140
140
|
|
|
141
141
|
__slots__ = ()
|
|
@@ -190,7 +190,7 @@ class BaseDataSet[Item: abc.Hashable](BaseDataAbstractSet[Item]):
|
|
|
190
190
|
return type(self)(self.__fget__().union(*others))
|
|
191
191
|
|
|
192
192
|
|
|
193
|
-
class
|
|
193
|
+
class FrozenSetLike[Item: abc.Hashable](SetLike[Item], abc.Hashable):
|
|
194
194
|
"""Provide easy abc for custom frozen set-like."""
|
|
195
195
|
|
|
196
196
|
__slots__ = ()
|
|
@@ -200,8 +200,8 @@ class FrozenDataSet[Item: abc.Hashable](BaseDataSet[Item], abc.Hashable):
|
|
|
200
200
|
return hash(frozenset(self.__fget__()))
|
|
201
201
|
|
|
202
202
|
|
|
203
|
-
class
|
|
204
|
-
|
|
203
|
+
class MutableSetLike[Item: abc.Hashable](
|
|
204
|
+
SetLike[Item],
|
|
205
205
|
abc.MutableSet[Item],
|
|
206
206
|
):
|
|
207
207
|
"""Provide easy abc for custom mutable set-like."""
|
|
@@ -252,8 +252,8 @@ class DataSet[Item: abc.Hashable](
|
|
|
252
252
|
|
|
253
253
|
|
|
254
254
|
### MAPPING ###
|
|
255
|
-
class
|
|
256
|
-
|
|
255
|
+
class Mapping[Key: abc.Hashable, Value](
|
|
256
|
+
Collection[Key], abc.Mapping[Key, Value]
|
|
257
257
|
):
|
|
258
258
|
"""Provide an easy abc for a custom mapping."""
|
|
259
259
|
|
|
@@ -261,7 +261,7 @@ class BaseDataMapping[Key: abc.Hashable, Value](
|
|
|
261
261
|
|
|
262
262
|
@setdoc.basic
|
|
263
263
|
class Data[DataKey, DataValue](
|
|
264
|
-
|
|
264
|
+
Collection.Data[DataKey],
|
|
265
265
|
Protocol,
|
|
266
266
|
):
|
|
267
267
|
@setdoc.basic
|
|
@@ -279,8 +279,8 @@ class BaseDataMapping[Key: abc.Hashable, Value](
|
|
|
279
279
|
raise KeyError(key) from None
|
|
280
280
|
|
|
281
281
|
|
|
282
|
-
class
|
|
283
|
-
|
|
282
|
+
class FrozenMapping[Key: abc.Hashable, Value](
|
|
283
|
+
Mapping[Key, Value],
|
|
284
284
|
abc.Hashable,
|
|
285
285
|
):
|
|
286
286
|
"""Provide an easy abc for a custom frozen mapping."""
|
|
@@ -295,8 +295,8 @@ class FrozenDataMapping[Key: abc.Hashable, Value](
|
|
|
295
295
|
### DICT ###
|
|
296
296
|
|
|
297
297
|
|
|
298
|
-
class
|
|
299
|
-
|
|
298
|
+
class DictLike[Key: abc.Hashable, Value](
|
|
299
|
+
Mapping[Key | str, Optional[Value]],
|
|
300
300
|
):
|
|
301
301
|
"""Provide an easy abc for custom dict-like."""
|
|
302
302
|
|
|
@@ -323,7 +323,7 @@ class BaseDataDict[Key: abc.Hashable, Value](
|
|
|
323
323
|
/,
|
|
324
324
|
**kwargs: Optional[Value],
|
|
325
325
|
) -> None:
|
|
326
|
-
data_:
|
|
326
|
+
data_: DictLike.Data[Key, Value]
|
|
327
327
|
data_ = dict( # type: ignore[assignment]
|
|
328
328
|
data, # type: ignore[arg-type]
|
|
329
329
|
**kwargs,
|
|
@@ -333,7 +333,7 @@ class BaseDataDict[Key: abc.Hashable, Value](
|
|
|
333
333
|
@setdoc.basic
|
|
334
334
|
def __or__(
|
|
335
335
|
self: Self,
|
|
336
|
-
other:
|
|
336
|
+
other: DictLike[Key, Value],
|
|
337
337
|
/,
|
|
338
338
|
) -> Self:
|
|
339
339
|
return type(self)(self.__fget__() | other.__fget__())
|
|
@@ -355,17 +355,17 @@ class BaseDataDict[Key: abc.Hashable, Value](
|
|
|
355
355
|
return cls(dict.fromkeys(iterable, value))
|
|
356
356
|
|
|
357
357
|
|
|
358
|
-
class
|
|
359
|
-
|
|
360
|
-
|
|
358
|
+
class FrozenDictLike[Key: abc.Hashable, Value](
|
|
359
|
+
DictLike[Key, Value],
|
|
360
|
+
FrozenMapping[Key | str, Optional[Value]],
|
|
361
361
|
):
|
|
362
362
|
"""Provide easy abc for custom frozen dict-like."""
|
|
363
363
|
|
|
364
364
|
__slots__ = ()
|
|
365
365
|
|
|
366
366
|
|
|
367
|
-
class
|
|
368
|
-
|
|
367
|
+
class MutableDictLike[Key: abc.Hashable, Value](
|
|
368
|
+
DictLike[Key, Value],
|
|
369
369
|
abc.MutableMapping[Key | str, Optional[Value]],
|
|
370
370
|
):
|
|
371
371
|
"""Provide easy abc for custom mutable dict-like."""
|
|
@@ -374,7 +374,7 @@ class DataDict[Key: abc.Hashable, Value](
|
|
|
374
374
|
|
|
375
375
|
@setdoc.basic
|
|
376
376
|
def __delitem__(self: Self, key: Key | str, /) -> None:
|
|
377
|
-
data:
|
|
377
|
+
data: MutableDictLike.Data[Key, Value]
|
|
378
378
|
data = self.__fget__()
|
|
379
379
|
del data[key]
|
|
380
380
|
self.__fset__(data)
|
|
@@ -382,7 +382,7 @@ class DataDict[Key: abc.Hashable, Value](
|
|
|
382
382
|
@setdoc.basic
|
|
383
383
|
def __ior__(
|
|
384
384
|
self: Self,
|
|
385
|
-
other:
|
|
385
|
+
other: DictLike[Key, Value],
|
|
386
386
|
/,
|
|
387
387
|
) -> Self:
|
|
388
388
|
self.__fset__(self.__fget__() | other.__fget__())
|
|
@@ -396,7 +396,7 @@ class DataDict[Key: abc.Hashable, Value](
|
|
|
396
396
|
/,
|
|
397
397
|
) -> None:
|
|
398
398
|
# what to do if Key includes unhashable types?
|
|
399
|
-
data:
|
|
399
|
+
data: MutableDictLike.Data[Key, Value]
|
|
400
400
|
data = self.__fget__()
|
|
401
401
|
data[key] = value
|
|
402
402
|
self.__fset__(data)
|
|
@@ -409,8 +409,8 @@ class DataDict[Key: abc.Hashable, Value](
|
|
|
409
409
|
### SEQUENCE ###
|
|
410
410
|
|
|
411
411
|
|
|
412
|
-
class
|
|
413
|
-
|
|
412
|
+
class Sequence[Item](
|
|
413
|
+
Collection[Item],
|
|
414
414
|
abc.Sequence[Item],
|
|
415
415
|
):
|
|
416
416
|
"""Provide an easy abc for a custom sequence."""
|
|
@@ -419,7 +419,7 @@ class BaseDataSequence[Item](
|
|
|
419
419
|
|
|
420
420
|
@setdoc.basic
|
|
421
421
|
class Data[DataItem](
|
|
422
|
-
|
|
422
|
+
Collection.Data[DataItem],
|
|
423
423
|
Protocol,
|
|
424
424
|
):
|
|
425
425
|
"""Provide sequence data protocol."""
|
|
@@ -457,7 +457,7 @@ class BaseDataSequence[Item](
|
|
|
457
457
|
### LIST ###
|
|
458
458
|
|
|
459
459
|
|
|
460
|
-
class
|
|
460
|
+
class ListLike[Item](Sequence[Item]):
|
|
461
461
|
"""Provide an easy abc for custom list-like."""
|
|
462
462
|
|
|
463
463
|
__slots__ = ()
|
|
@@ -466,7 +466,7 @@ class BaseDataList[Item](BaseDataSequence[Item]):
|
|
|
466
466
|
type Init[InitItem] = abc.Iterable[InitItem]
|
|
467
467
|
|
|
468
468
|
@setdoc.basic
|
|
469
|
-
def __add__(self: Self, other:
|
|
469
|
+
def __add__(self: Self, other: ListLike[Item], /) -> Self:
|
|
470
470
|
# list.__add__ reveals Overload(
|
|
471
471
|
# def [_T] (list[_T], list[_T]) -> list[_T],
|
|
472
472
|
# def [_T, _S] (list[_T], list[_S]) -> list[_S | _T],
|
|
@@ -475,14 +475,14 @@ class BaseDataList[Item](BaseDataSequence[Item]):
|
|
|
475
475
|
# def [_T_co] (tuple[_T_co, ...], tuple[_T_co, ...]) -> tuple[_T_co, ...],
|
|
476
476
|
# def [_T_co, _T] (tuple[_T_co, ...], tuple[_T, ...]) -> tuple[_T_co | _T, ...],
|
|
477
477
|
# )
|
|
478
|
-
if isinstance(other,
|
|
478
|
+
if isinstance(other, ListLike):
|
|
479
479
|
return type(self)(self.__fget__() + other.__fget__())
|
|
480
480
|
else:
|
|
481
481
|
return NotImplemented
|
|
482
482
|
|
|
483
483
|
@setdoc.basic
|
|
484
484
|
def __eq__(self: Self, other: object, /) -> NotImplementedType | bool:
|
|
485
|
-
if isinstance(other,
|
|
485
|
+
if isinstance(other, ListLike):
|
|
486
486
|
return self.__fget__() == other.__fget__()
|
|
487
487
|
else:
|
|
488
488
|
return NotImplemented
|
|
@@ -497,7 +497,7 @@ class BaseDataList[Item](BaseDataSequence[Item]):
|
|
|
497
497
|
|
|
498
498
|
@setdoc.basic
|
|
499
499
|
def __ge__(self: Self, other: object, /) -> NotImplementedType | bool:
|
|
500
|
-
if isinstance(other,
|
|
500
|
+
if isinstance(other, ListLike):
|
|
501
501
|
return self.__fget__() >= other.__fget__()
|
|
502
502
|
else:
|
|
503
503
|
return NotImplemented
|
|
@@ -521,7 +521,7 @@ class BaseDataList[Item](BaseDataSequence[Item]):
|
|
|
521
521
|
|
|
522
522
|
@setdoc.basic
|
|
523
523
|
def __gt__(self: Self, other: object, /) -> NotImplementedType | bool:
|
|
524
|
-
if isinstance(other,
|
|
524
|
+
if isinstance(other, ListLike):
|
|
525
525
|
return self.__fget__() > other.__fget__()
|
|
526
526
|
else:
|
|
527
527
|
return NotImplemented
|
|
@@ -532,14 +532,14 @@ class BaseDataList[Item](BaseDataSequence[Item]):
|
|
|
532
532
|
|
|
533
533
|
@setdoc.basic
|
|
534
534
|
def __le__(self: Self, other: object, /) -> NotImplementedType | bool:
|
|
535
|
-
if isinstance(other,
|
|
535
|
+
if isinstance(other, ListLike):
|
|
536
536
|
return self.__fget__() <= other.__fget__()
|
|
537
537
|
else:
|
|
538
538
|
return NotImplemented
|
|
539
539
|
|
|
540
540
|
@setdoc.basic
|
|
541
541
|
def __lt__(self: Self, other: object, /) -> NotImplementedType | bool:
|
|
542
|
-
if isinstance(other,
|
|
542
|
+
if isinstance(other, ListLike):
|
|
543
543
|
return self.__fget__() < other.__fget__()
|
|
544
544
|
else:
|
|
545
545
|
return NotImplemented
|
|
@@ -555,8 +555,8 @@ class BaseDataList[Item](BaseDataSequence[Item]):
|
|
|
555
555
|
__rmul__ = __mul__
|
|
556
556
|
|
|
557
557
|
|
|
558
|
-
class
|
|
559
|
-
|
|
558
|
+
class FrozenListLike[Item](
|
|
559
|
+
ListLike[Item],
|
|
560
560
|
abc.Hashable,
|
|
561
561
|
):
|
|
562
562
|
"""Provide easy abc for custom frozen list-like."""
|
|
@@ -568,8 +568,8 @@ class FrozenDataList[Item](
|
|
|
568
568
|
return hash(tuple(self.__fget__()))
|
|
569
569
|
|
|
570
570
|
|
|
571
|
-
class
|
|
572
|
-
|
|
571
|
+
class MutableListLike[Item](
|
|
572
|
+
ListLike[Item],
|
|
573
573
|
abc.MutableSequence[Item],
|
|
574
574
|
):
|
|
575
575
|
"""Provide easy abc for custom mutable list-like."""
|
|
@@ -11,12 +11,12 @@ from typing import Any, Self
|
|
|
11
11
|
|
|
12
12
|
from frozendict import frozendict
|
|
13
13
|
|
|
14
|
-
from datahold import BaseHoldObject,
|
|
14
|
+
from datahold import BaseHoldObject, FrozenDictLike
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
class FrozenHoldDict[Key: abc.Hashable, Value](
|
|
18
|
-
BaseHoldObject[
|
|
19
|
-
|
|
18
|
+
BaseHoldObject[FrozenDictLike.Data[Key, Value]],
|
|
19
|
+
FrozenDictLike[Key, Value],
|
|
20
20
|
):
|
|
21
21
|
"""Provide usable frozen dict-like with slots."""
|
|
22
22
|
|
|
@@ -7,12 +7,12 @@ __all__: list[str] = [
|
|
|
7
7
|
import unittest
|
|
8
8
|
from typing import Any, Self
|
|
9
9
|
|
|
10
|
-
from datahold import BaseHoldObject,
|
|
10
|
+
from datahold import BaseHoldObject, FrozenListLike
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
class FrozenHoldList[Item](
|
|
14
|
-
BaseHoldObject[
|
|
15
|
-
|
|
14
|
+
BaseHoldObject[FrozenListLike.Data[Item]],
|
|
15
|
+
FrozenListLike[Item],
|
|
16
16
|
):
|
|
17
17
|
"""Provide usable frozen list-like with slots."""
|
|
18
18
|
|
|
@@ -8,12 +8,12 @@ import unittest
|
|
|
8
8
|
from collections import abc
|
|
9
9
|
from typing import Any, Self
|
|
10
10
|
|
|
11
|
-
from datahold import BaseHoldObject,
|
|
11
|
+
from datahold import BaseHoldObject, FrozenSetLike
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
class FrozenHoldSet[Item: abc.Hashable](
|
|
15
|
-
BaseHoldObject[
|
|
16
|
-
|
|
15
|
+
BaseHoldObject[FrozenSetLike.Data[Item]],
|
|
16
|
+
FrozenSetLike[Item],
|
|
17
17
|
):
|
|
18
18
|
"""Provide usable frozen set-like with slots."""
|
|
19
19
|
|
|
@@ -8,12 +8,12 @@ import unittest
|
|
|
8
8
|
from collections import abc
|
|
9
9
|
from typing import Any, Self, cast
|
|
10
10
|
|
|
11
|
-
from datahold import BaseHoldObject,
|
|
11
|
+
from datahold import BaseHoldObject, MutableDictLike
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
class HoldDict[Key: abc.Hashable, Value](
|
|
15
|
-
BaseHoldObject[
|
|
16
|
-
|
|
15
|
+
BaseHoldObject[MutableDictLike.Data[Key, Value]],
|
|
16
|
+
MutableDictLike[Key, Value],
|
|
17
17
|
):
|
|
18
18
|
"""Provide usable mutable dict-like with slots."""
|
|
19
19
|
|
|
@@ -7,12 +7,12 @@ __all__: list[str] = [
|
|
|
7
7
|
import unittest
|
|
8
8
|
from typing import Any, Self
|
|
9
9
|
|
|
10
|
-
from datahold import BaseHoldObject,
|
|
10
|
+
from datahold import BaseHoldObject, MutableListLike
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
class HoldList[Item](
|
|
14
|
-
BaseHoldObject[
|
|
15
|
-
|
|
14
|
+
BaseHoldObject[MutableListLike.Data[Item]],
|
|
15
|
+
MutableListLike[Item],
|
|
16
16
|
):
|
|
17
17
|
"""Provide usable mutable list-like with slots."""
|
|
18
18
|
|
|
@@ -8,12 +8,12 @@ import unittest
|
|
|
8
8
|
from collections import abc
|
|
9
9
|
from typing import Any, Self
|
|
10
10
|
|
|
11
|
-
from datahold import BaseHoldObject,
|
|
11
|
+
from datahold import BaseHoldObject, MutableSetLike
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
class HoldSet[Item: abc.Hashable](
|
|
15
|
-
BaseHoldObject[
|
|
16
|
-
|
|
15
|
+
BaseHoldObject[MutableSetLike.Data[Item]],
|
|
16
|
+
MutableSetLike[Item],
|
|
17
17
|
):
|
|
18
18
|
"""Provide usable mutable set-like with slots."""
|
|
19
19
|
|
|
@@ -17,6 +17,7 @@ import io
|
|
|
17
17
|
import tomllib
|
|
18
18
|
import unittest
|
|
19
19
|
from functools import cached_property
|
|
20
|
+
from importlib import import_module
|
|
20
21
|
from pathlib import Path
|
|
21
22
|
from typing import Any, Self, TypeAliasType, cast, get_args, get_origin
|
|
22
23
|
|
|
@@ -42,14 +43,17 @@ class Lazy(enum.Enum):
|
|
|
42
43
|
with file.open("rb") as stream:
|
|
43
44
|
return tomllib.load(stream)
|
|
44
45
|
|
|
46
|
+
@classmethod
|
|
47
|
+
def get_import(cls: type[Self], qualname: str) -> type[Any]:
|
|
48
|
+
module: Any
|
|
49
|
+
parts: list[str]
|
|
50
|
+
parts = qualname.split(".")
|
|
51
|
+
module = import_module(".".join(parts[:-1]))
|
|
52
|
+
return cast(type[Any], getattr(module, parts[-1]))
|
|
53
|
+
|
|
45
54
|
@classmethod
|
|
46
55
|
def get_type(cls: type[Self], typename: str) -> type[Any]:
|
|
47
|
-
|
|
48
|
-
if typename in collections.abc.__all__:
|
|
49
|
-
ans = getattr(collections.abc, typename)
|
|
50
|
-
else:
|
|
51
|
-
ans = getattr(datahold, typename)
|
|
52
|
-
return cast(type[Any], ans)
|
|
56
|
+
return cast(type[Any], getattr(datahold, typename))
|
|
53
57
|
|
|
54
58
|
@cached_property
|
|
55
59
|
def test_object(self: Self) -> dict[str, Any]:
|
|
@@ -102,8 +106,6 @@ class TestCollection(unittest.TestCase):
|
|
|
102
106
|
typename: str
|
|
103
107
|
for typename in Lazy.lazy.types.keys():
|
|
104
108
|
cls = Lazy.get_type(typename=typename)
|
|
105
|
-
if cls is None:
|
|
106
|
-
raise Exception
|
|
107
109
|
self._test_cls(cls)
|
|
108
110
|
|
|
109
111
|
|
|
@@ -133,7 +135,7 @@ class TestConstructor(unittest.TestCase):
|
|
|
133
135
|
self.assertIn(info.get("repr"), [None, repr(obj)])
|
|
134
136
|
self.assertIn(info.get("str"), [None, str(obj)])
|
|
135
137
|
for x, y in info.get("parents", {}).items():
|
|
136
|
-
parenttype = Lazy.
|
|
138
|
+
parenttype = Lazy.get_import(x)
|
|
137
139
|
self.assertEqual(isinstance(obj, parenttype), y)
|
|
138
140
|
|
|
139
141
|
def go_types(self: Self, typename: str, /, **kwargs: Any) -> None:
|
|
@@ -147,7 +149,7 @@ class TestConstructor(unittest.TestCase):
|
|
|
147
149
|
|
|
148
150
|
def test_abstract_classes(self: Self) -> None:
|
|
149
151
|
for typename, kwargs in Lazy.lazy.types.items():
|
|
150
|
-
with self.subTest(
|
|
152
|
+
with self.subTest(type=typename):
|
|
151
153
|
self.go_types(typename, **kwargs)
|
|
152
154
|
|
|
153
155
|
|
|
@@ -303,7 +305,7 @@ class TestParents(unittest.TestCase):
|
|
|
303
305
|
if cls is None:
|
|
304
306
|
raise Exception
|
|
305
307
|
for x, y in kwargs.get("parents", {}).items():
|
|
306
|
-
parenttype = Lazy.
|
|
308
|
+
parenttype = Lazy.get_import(x)
|
|
307
309
|
self.assertEqual(issubclass(cls, parenttype), y, x)
|
|
308
310
|
|
|
309
311
|
def test_parents(self: Self) -> None:
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
[test_object]
|
|
2
|
+
METHODS = [
|
|
3
|
+
"__format__",
|
|
4
|
+
"__str__",
|
|
5
|
+
]
|
|
6
|
+
|
|
7
|
+
[types.Collection]
|
|
8
|
+
dirData = [
|
|
9
|
+
"__contains__",
|
|
10
|
+
"__iter__",
|
|
11
|
+
"__len__",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
[types.Collection.parents]
|
|
15
|
+
"collections.abc.Collection" = true
|
|
16
|
+
"collections.abc.Hashable" = true
|
|
17
|
+
|
|
18
|
+
[types.DictLike]
|
|
19
|
+
dirData = []
|
|
20
|
+
|
|
21
|
+
[types.DictLike.parents]
|
|
22
|
+
"collections.abc.Hashable" = false
|
|
23
|
+
"collections.abc.Mapping" = true
|
|
24
|
+
|
|
25
|
+
[types.FrozenDictLike]
|
|
26
|
+
Data = "frozendict"
|
|
27
|
+
dirData = []
|
|
28
|
+
isabstract = true
|
|
29
|
+
|
|
30
|
+
[types.FrozenDictLike.parents]
|
|
31
|
+
"datahold.DictLike" = true
|
|
32
|
+
"datahold.FrozenMapping" = true
|
|
33
|
+
|
|
34
|
+
[types.FrozenListLike]
|
|
35
|
+
Data = "tuple"
|
|
36
|
+
dirData = []
|
|
37
|
+
isabstract = true
|
|
38
|
+
|
|
39
|
+
[types.FrozenListLike.parents]
|
|
40
|
+
|
|
41
|
+
[types.FrozenMapping]
|
|
42
|
+
dirData = []
|
|
43
|
+
|
|
44
|
+
[types.FrozenMapping.parents]
|
|
45
|
+
"collections.abc.Hashable" = true
|
|
46
|
+
"datahold.Mapping" = true
|
|
47
|
+
|
|
48
|
+
[types.FrozenSetLike]
|
|
49
|
+
Data = "frozenset"
|
|
50
|
+
dirData = []
|
|
51
|
+
isabstract = true
|
|
52
|
+
|
|
53
|
+
[types.FrozenSetLike.parents]
|
|
54
|
+
|
|
55
|
+
[types.ListLike]
|
|
56
|
+
dirData = []
|
|
57
|
+
|
|
58
|
+
[types.ListLike.parents]
|
|
59
|
+
"collections.abc.Hashable" = false
|
|
60
|
+
"collections.abc.Sequence" = true
|
|
61
|
+
|
|
62
|
+
[types.Mapping]
|
|
63
|
+
dirData = []
|
|
64
|
+
|
|
65
|
+
[types.Mapping.parents]
|
|
66
|
+
"collections.abc.Hashable" = false
|
|
67
|
+
"datahold.Collection" = true
|
|
68
|
+
|
|
69
|
+
[types.MutableDictLike]
|
|
70
|
+
Data = "frozendict"
|
|
71
|
+
dirData = []
|
|
72
|
+
isabstract = true
|
|
73
|
+
n_type_params = 2
|
|
74
|
+
|
|
75
|
+
[types.MutableDictLike.constructor.empty]
|
|
76
|
+
valid = false
|
|
77
|
+
|
|
78
|
+
[types.MutableDictLike.parents]
|
|
79
|
+
"collections.abc.MutableMapping" = true
|
|
80
|
+
"datahold.DictLike" = true
|
|
81
|
+
"datahold.Mapping" = true
|
|
82
|
+
|
|
83
|
+
[types.MutableListLike]
|
|
84
|
+
Data = "tuple"
|
|
85
|
+
dirData = []
|
|
86
|
+
isabstract = true
|
|
87
|
+
n_type_params = 1
|
|
88
|
+
|
|
89
|
+
[types.MutableListLike.constructor.empty]
|
|
90
|
+
valid = false
|
|
91
|
+
|
|
92
|
+
[types.MutableListLike.parents]
|
|
93
|
+
"collections.abc.MutableSequence" = true
|
|
94
|
+
"collections.abc.Sequence" = true
|
|
95
|
+
"datahold.ListLike" = true
|
|
96
|
+
|
|
97
|
+
[types.MutableSetLike]
|
|
98
|
+
Data = "frozenset"
|
|
99
|
+
dirData = []
|
|
100
|
+
isabstract = true
|
|
101
|
+
n_type_params = 1
|
|
102
|
+
|
|
103
|
+
[types.MutableSetLike.constructor.empty]
|
|
104
|
+
valid = false
|
|
105
|
+
|
|
106
|
+
[types.MutableSetLike.parents]
|
|
107
|
+
"collections.abc.MutableSet" = true
|
|
108
|
+
"collections.abc.Set" = true
|
|
109
|
+
"datahold.SetLike" = true
|
|
110
|
+
|
|
111
|
+
[types.Sequence]
|
|
112
|
+
dirData = [
|
|
113
|
+
"__contains__",
|
|
114
|
+
"__getitem__",
|
|
115
|
+
"__iter__",
|
|
116
|
+
"__len__",
|
|
117
|
+
]
|
|
118
|
+
|
|
119
|
+
[types.Sequence.parents]
|
|
120
|
+
"collections.abc.Hashable" = true
|
|
121
|
+
"datahold.Collection" = true
|
|
122
|
+
|
|
123
|
+
[types.Set]
|
|
124
|
+
dirData = [
|
|
125
|
+
"__contains__",
|
|
126
|
+
"__iter__",
|
|
127
|
+
"__len__",
|
|
128
|
+
]
|
|
129
|
+
|
|
130
|
+
[types.Set.parents]
|
|
131
|
+
"collections.abc.Hashable" = false
|
|
132
|
+
"datahold.Collection" = true
|
|
133
|
+
|
|
134
|
+
[types.SetLike]
|
|
135
|
+
dirData = []
|
|
136
|
+
|
|
137
|
+
[types.SetLike.parents]
|
|
138
|
+
"collections.abc.Hashable" = false
|
|
139
|
+
"collections.abc.Set" = true
|
|
140
|
+
"datahold.Set" = true
|
|
141
|
+
|
|
142
|
+
[varia]
|
|
143
|
+
HOLD_TYPES = [
|
|
144
|
+
"BaseHoldObject",
|
|
145
|
+
]
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
[test_object]
|
|
2
|
-
METHODS = [
|
|
3
|
-
"__format__",
|
|
4
|
-
"__str__",
|
|
5
|
-
]
|
|
6
|
-
|
|
7
|
-
[types.BaseDataAbstractSet]
|
|
8
|
-
dirData = [
|
|
9
|
-
"__contains__",
|
|
10
|
-
"__iter__",
|
|
11
|
-
"__len__",
|
|
12
|
-
]
|
|
13
|
-
|
|
14
|
-
[types.BaseDataAbstractSet.parents]
|
|
15
|
-
BaseDataCollection = true
|
|
16
|
-
Hashable = false
|
|
17
|
-
|
|
18
|
-
[types.BaseDataCollection]
|
|
19
|
-
dirData = [
|
|
20
|
-
"__contains__",
|
|
21
|
-
"__iter__",
|
|
22
|
-
"__len__",
|
|
23
|
-
]
|
|
24
|
-
|
|
25
|
-
[types.BaseDataCollection.parents]
|
|
26
|
-
Collection = true
|
|
27
|
-
Hashable = true
|
|
28
|
-
|
|
29
|
-
[types.BaseDataDict]
|
|
30
|
-
dirData = []
|
|
31
|
-
|
|
32
|
-
[types.BaseDataDict.parents]
|
|
33
|
-
Hashable = false
|
|
34
|
-
Mapping = true
|
|
35
|
-
|
|
36
|
-
[types.BaseDataList]
|
|
37
|
-
dirData = []
|
|
38
|
-
|
|
39
|
-
[types.BaseDataList.parents]
|
|
40
|
-
Hashable = false
|
|
41
|
-
Sequence = true
|
|
42
|
-
|
|
43
|
-
[types.BaseDataMapping]
|
|
44
|
-
dirData = []
|
|
45
|
-
|
|
46
|
-
[types.BaseDataMapping.parents]
|
|
47
|
-
BaseDataCollection = true
|
|
48
|
-
Hashable = false
|
|
49
|
-
|
|
50
|
-
[types.BaseDataSequence]
|
|
51
|
-
dirData = [
|
|
52
|
-
"__contains__",
|
|
53
|
-
"__getitem__",
|
|
54
|
-
"__iter__",
|
|
55
|
-
"__len__",
|
|
56
|
-
]
|
|
57
|
-
|
|
58
|
-
[types.BaseDataSequence.parents]
|
|
59
|
-
BaseDataCollection = true
|
|
60
|
-
Hashable = true
|
|
61
|
-
|
|
62
|
-
[types.BaseDataSet]
|
|
63
|
-
dirData = []
|
|
64
|
-
|
|
65
|
-
[types.BaseDataSet.parents]
|
|
66
|
-
BaseDataAbstractSet = true
|
|
67
|
-
Hashable = false
|
|
68
|
-
Set = true
|
|
69
|
-
|
|
70
|
-
[types.DataDict]
|
|
71
|
-
Data = "frozendict"
|
|
72
|
-
dirData = []
|
|
73
|
-
isabstract = true
|
|
74
|
-
n_type_params = 2
|
|
75
|
-
|
|
76
|
-
[types.DataDict.constructor.empty]
|
|
77
|
-
valid = false
|
|
78
|
-
|
|
79
|
-
[types.DataDict.parents]
|
|
80
|
-
BaseDataDict = true
|
|
81
|
-
BaseDataMapping = true
|
|
82
|
-
MutableMapping = true
|
|
83
|
-
|
|
84
|
-
[types.DataList]
|
|
85
|
-
Data = "tuple"
|
|
86
|
-
dirData = []
|
|
87
|
-
isabstract = true
|
|
88
|
-
n_type_params = 1
|
|
89
|
-
|
|
90
|
-
[types.DataList.constructor.empty]
|
|
91
|
-
valid = false
|
|
92
|
-
|
|
93
|
-
[types.DataList.parents]
|
|
94
|
-
BaseDataList = true
|
|
95
|
-
MutableSequence = true
|
|
96
|
-
Sequence = true
|
|
97
|
-
|
|
98
|
-
[types.DataSet]
|
|
99
|
-
Data = "frozenset"
|
|
100
|
-
dirData = []
|
|
101
|
-
isabstract = true
|
|
102
|
-
n_type_params = 1
|
|
103
|
-
|
|
104
|
-
[types.DataSet.constructor.empty]
|
|
105
|
-
valid = false
|
|
106
|
-
|
|
107
|
-
[types.DataSet.parents]
|
|
108
|
-
BaseDataSet = true
|
|
109
|
-
MutableSet = true
|
|
110
|
-
Set = true
|
|
111
|
-
|
|
112
|
-
[types.FrozenDataDict]
|
|
113
|
-
Data = "frozendict"
|
|
114
|
-
dirData = []
|
|
115
|
-
isabstract = true
|
|
116
|
-
|
|
117
|
-
[types.FrozenDataDict.parents]
|
|
118
|
-
BaseDataDict = true
|
|
119
|
-
FrozenDataMapping = true
|
|
120
|
-
|
|
121
|
-
[types.FrozenDataList]
|
|
122
|
-
Data = "tuple"
|
|
123
|
-
dirData = []
|
|
124
|
-
isabstract = true
|
|
125
|
-
|
|
126
|
-
[types.FrozenDataList.parents]
|
|
127
|
-
|
|
128
|
-
[types.FrozenDataMapping]
|
|
129
|
-
dirData = []
|
|
130
|
-
|
|
131
|
-
[types.FrozenDataMapping.parents]
|
|
132
|
-
BaseDataMapping = true
|
|
133
|
-
Hashable = true
|
|
134
|
-
|
|
135
|
-
[types.FrozenDataSet]
|
|
136
|
-
Data = "frozenset"
|
|
137
|
-
dirData = []
|
|
138
|
-
isabstract = true
|
|
139
|
-
|
|
140
|
-
[types.FrozenDataSet.parents]
|
|
141
|
-
|
|
142
|
-
[varia]
|
|
143
|
-
HOLD_TYPES = [
|
|
144
|
-
"BaseHoldObject",
|
|
145
|
-
]
|
|
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
|