ducktools-classbuilder 0.7.2__py3-none-any.whl → 0.7.4__py3-none-any.whl
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.
Potentially problematic release.
This version of ducktools-classbuilder might be problematic. Click here for more details.
- ducktools/classbuilder/__init__.py +0 -5
- ducktools/classbuilder/_version.py +2 -2
- ducktools/classbuilder/annotations.py +39 -2
- {ducktools_classbuilder-0.7.2.dist-info → ducktools_classbuilder-0.7.4.dist-info}/METADATA +3 -2
- ducktools_classbuilder-0.7.4.dist-info/RECORD +13 -0
- {ducktools_classbuilder-0.7.2.dist-info → ducktools_classbuilder-0.7.4.dist-info}/WHEEL +1 -1
- ducktools_classbuilder-0.7.2.dist-info/RECORD +0 -13
- {ducktools_classbuilder-0.7.2.dist-info → ducktools_classbuilder-0.7.4.dist-info}/LICENSE.md +0 -0
- {ducktools_classbuilder-0.7.2.dist-info → ducktools_classbuilder-0.7.4.dist-info}/top_level.txt +0 -0
|
@@ -654,11 +654,6 @@ class Field(metaclass=SlotMakerMeta):
|
|
|
654
654
|
f"{cls_name} cannot define both a default value and a default factory."
|
|
655
655
|
)
|
|
656
656
|
|
|
657
|
-
if self.kw_only and not self.init:
|
|
658
|
-
raise AttributeError(
|
|
659
|
-
f"{cls_name} cannot be keyword only if it is not in init."
|
|
660
|
-
)
|
|
661
|
-
|
|
662
657
|
@classmethod
|
|
663
658
|
def from_field(cls, fld, /, **kwargs):
|
|
664
659
|
"""
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
__version__ = "0.7.
|
|
2
|
-
__version_tuple__ = (0, 7,
|
|
1
|
+
__version__ = "0.7.4"
|
|
2
|
+
__version_tuple__ = (0, 7, 4)
|
|
@@ -37,6 +37,36 @@ del _cell_factory
|
|
|
37
37
|
# End evil stuff from types.py
|
|
38
38
|
|
|
39
39
|
|
|
40
|
+
class _Stringlike(str):
|
|
41
|
+
# There are typing operators that are not supported by strings
|
|
42
|
+
# This adds the 'or' operator '|'
|
|
43
|
+
|
|
44
|
+
def __or__(self, other):
|
|
45
|
+
if isinstance(other, str):
|
|
46
|
+
other_r = other
|
|
47
|
+
elif name := getattr(other, "__name__", None):
|
|
48
|
+
other_r = name
|
|
49
|
+
else:
|
|
50
|
+
other_r = str(other)
|
|
51
|
+
|
|
52
|
+
return type(self)(f"{self} | {other_r}")
|
|
53
|
+
|
|
54
|
+
def __ror__(self, other):
|
|
55
|
+
if isinstance(other, str):
|
|
56
|
+
other_r = other
|
|
57
|
+
elif name := getattr(other, "__name__", None):
|
|
58
|
+
other_r = name
|
|
59
|
+
else:
|
|
60
|
+
other_r = str(other)
|
|
61
|
+
|
|
62
|
+
return type(self)(f"{other_r} | {self}")
|
|
63
|
+
|
|
64
|
+
def __repr__(self):
|
|
65
|
+
base = super().__repr__()
|
|
66
|
+
clsname = type(self).__name__
|
|
67
|
+
return f"{clsname}({base})"
|
|
68
|
+
|
|
69
|
+
|
|
40
70
|
class _StringGlobs(dict):
|
|
41
71
|
"""
|
|
42
72
|
Based on the fake globals dictionary used for annotations
|
|
@@ -47,7 +77,7 @@ class _StringGlobs(dict):
|
|
|
47
77
|
is not found.
|
|
48
78
|
"""
|
|
49
79
|
def __missing__(self, key):
|
|
50
|
-
return key
|
|
80
|
+
return _Stringlike(key)
|
|
51
81
|
|
|
52
82
|
def __repr__(self):
|
|
53
83
|
cls_name = self.__class__.__name__
|
|
@@ -165,7 +195,14 @@ def call_annotate_func(annotate):
|
|
|
165
195
|
closure = None
|
|
166
196
|
|
|
167
197
|
new_annotate = _FunctionType(annotate.__code__, globs, closure=closure)
|
|
168
|
-
|
|
198
|
+
|
|
199
|
+
# Convert _Stringlike back to str
|
|
200
|
+
annos = {
|
|
201
|
+
k: str(v) if isinstance(v, _Stringlike) else v
|
|
202
|
+
for k, v in new_annotate(1).items()
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return annos
|
|
169
206
|
|
|
170
207
|
|
|
171
208
|
def get_ns_annotations(ns, eval_str=True):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: ducktools-classbuilder
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.4
|
|
4
4
|
Summary: Toolkit for creating class boilerplate generators
|
|
5
5
|
Author: David C Ellis
|
|
6
6
|
License: MIT License
|
|
@@ -48,8 +48,9 @@ Requires-Dist: pydantic ; extra == 'performance_tests'
|
|
|
48
48
|
Provides-Extra: testing
|
|
49
49
|
Requires-Dist: pytest >=8.2 ; extra == 'testing'
|
|
50
50
|
Requires-Dist: pytest-cov ; extra == 'testing'
|
|
51
|
-
Requires-Dist: mypy ; extra == 'testing'
|
|
52
51
|
Requires-Dist: typing-extensions ; extra == 'testing'
|
|
52
|
+
Provides-Extra: type_checking
|
|
53
|
+
Requires-Dist: mypy ; extra == 'type_checking'
|
|
53
54
|
|
|
54
55
|
# Ducktools: Class Builder #
|
|
55
56
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
ducktools/classbuilder/__init__.py,sha256=DA5ZisvBEQGK3Mx2Y_SS43ZkIOHd1WZs2JF2g9n1URs,32354
|
|
2
|
+
ducktools/classbuilder/__init__.pyi,sha256=t2KrEsEhKFbLpl0QeX0CiCy_VTRFRZO_2ABdfndRfZY,7939
|
|
3
|
+
ducktools/classbuilder/_version.py,sha256=Z7KmGeeyyT2ppHJrXQg4HcQhc0Y9QqZpNm00ZQT7MuY,52
|
|
4
|
+
ducktools/classbuilder/annotations.py,sha256=cgFlMmEXIhBUZ3DWbPQgFVqPx56s1vR3KROaiypDroo,9174
|
|
5
|
+
ducktools/classbuilder/annotations.pyi,sha256=vW3YQIiKYYQJll9_B4oTkBwIh4nOy1AnU9Ny8_a0dRY,686
|
|
6
|
+
ducktools/classbuilder/prefab.py,sha256=6YOVVYYeuMF5gv9DnK-sCvNKxBaBoqDXNLUQ22-xINk,24097
|
|
7
|
+
ducktools/classbuilder/prefab.pyi,sha256=x2ioTpkhNjQXFeKABFOzE0xNeZ8f_W5vusmuAzE19mc,4491
|
|
8
|
+
ducktools/classbuilder/py.typed,sha256=la67KBlbjXN-_-DfGNcdOcjYumVpKG_Tkw-8n5dnGB4,8
|
|
9
|
+
ducktools_classbuilder-0.7.4.dist-info/LICENSE.md,sha256=6Thz9Dbw8R4fWInl6sGl8Rj3UnKnRbDwrc6jZerpugQ,1070
|
|
10
|
+
ducktools_classbuilder-0.7.4.dist-info/METADATA,sha256=ToPo40dXDorKyD_bL_pJwIZbDsiptuJJ4QpqoBdrSBc,11004
|
|
11
|
+
ducktools_classbuilder-0.7.4.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
|
|
12
|
+
ducktools_classbuilder-0.7.4.dist-info/top_level.txt,sha256=uSDLtio3ZFqdwcsMJ2O5yhjB4Q3ytbBWbA8rJREganc,10
|
|
13
|
+
ducktools_classbuilder-0.7.4.dist-info/RECORD,,
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
ducktools/classbuilder/__init__.py,sha256=sHgrsySQDxcvnkL0GsQu9Q4Um2-9gRFyGeYGgNAEjag,32521
|
|
2
|
-
ducktools/classbuilder/__init__.pyi,sha256=t2KrEsEhKFbLpl0QeX0CiCy_VTRFRZO_2ABdfndRfZY,7939
|
|
3
|
-
ducktools/classbuilder/_version.py,sha256=iYP0OHZX_Sj2gXyYk7ivc79K_EYWflz05BN2AbALx90,52
|
|
4
|
-
ducktools/classbuilder/annotations.py,sha256=x-3936HcJzv04rga8k0fFTbu1656yDglVN6kCan4hiw,8203
|
|
5
|
-
ducktools/classbuilder/annotations.pyi,sha256=vW3YQIiKYYQJll9_B4oTkBwIh4nOy1AnU9Ny8_a0dRY,686
|
|
6
|
-
ducktools/classbuilder/prefab.py,sha256=6YOVVYYeuMF5gv9DnK-sCvNKxBaBoqDXNLUQ22-xINk,24097
|
|
7
|
-
ducktools/classbuilder/prefab.pyi,sha256=x2ioTpkhNjQXFeKABFOzE0xNeZ8f_W5vusmuAzE19mc,4491
|
|
8
|
-
ducktools/classbuilder/py.typed,sha256=la67KBlbjXN-_-DfGNcdOcjYumVpKG_Tkw-8n5dnGB4,8
|
|
9
|
-
ducktools_classbuilder-0.7.2.dist-info/LICENSE.md,sha256=6Thz9Dbw8R4fWInl6sGl8Rj3UnKnRbDwrc6jZerpugQ,1070
|
|
10
|
-
ducktools_classbuilder-0.7.2.dist-info/METADATA,sha256=o8V0NVephCbyJqbxiqqoIMerLLQsnQSYLQ5VrJWrUFk,10968
|
|
11
|
-
ducktools_classbuilder-0.7.2.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
|
|
12
|
-
ducktools_classbuilder-0.7.2.dist-info/top_level.txt,sha256=uSDLtio3ZFqdwcsMJ2O5yhjB4Q3ytbBWbA8rJREganc,10
|
|
13
|
-
ducktools_classbuilder-0.7.2.dist-info/RECORD,,
|
{ducktools_classbuilder-0.7.2.dist-info → ducktools_classbuilder-0.7.4.dist-info}/LICENSE.md
RENAMED
|
File without changes
|
{ducktools_classbuilder-0.7.2.dist-info → ducktools_classbuilder-0.7.4.dist-info}/top_level.txt
RENAMED
|
File without changes
|