ducktools-classbuilder 0.7.3__py3-none-any.whl → 0.7.5__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 +7 -77
- ducktools/classbuilder/annotations.pyi +0 -5
- {ducktools_classbuilder-0.7.3.dist-info → ducktools_classbuilder-0.7.5.dist-info}/METADATA +1 -1
- ducktools_classbuilder-0.7.5.dist-info/RECORD +13 -0
- {ducktools_classbuilder-0.7.3.dist-info → ducktools_classbuilder-0.7.5.dist-info}/WHEEL +1 -1
- ducktools_classbuilder-0.7.3.dist-info/RECORD +0 -13
- {ducktools_classbuilder-0.7.3.dist-info → ducktools_classbuilder-0.7.5.dist-info}/LICENSE.md +0 -0
- {ducktools_classbuilder-0.7.3.dist-info → ducktools_classbuilder-0.7.5.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.5"
|
|
2
|
+
__version_tuple__ = (0, 7, 5)
|
|
@@ -24,19 +24,6 @@ import sys
|
|
|
24
24
|
import builtins
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
# Evil stuff from types.py
|
|
28
|
-
def _cell_factory():
|
|
29
|
-
a = 1
|
|
30
|
-
|
|
31
|
-
def f():
|
|
32
|
-
nonlocal a
|
|
33
|
-
return f.__closure__[0]
|
|
34
|
-
_FunctionType = type(_cell_factory)
|
|
35
|
-
_CellType = type(_cell_factory())
|
|
36
|
-
del _cell_factory
|
|
37
|
-
# End evil stuff from types.py
|
|
38
|
-
|
|
39
|
-
|
|
40
27
|
class _Stringlike(str):
|
|
41
28
|
# There are typing operators that are not supported by strings
|
|
42
29
|
# This adds the 'or' operator '|'
|
|
@@ -142,69 +129,6 @@ def eval_hint(hint, context=None, *, recursion_limit=2):
|
|
|
142
129
|
return hint
|
|
143
130
|
|
|
144
131
|
|
|
145
|
-
def call_annotate_func(annotate):
|
|
146
|
-
# Python 3.14 breaks the old methods of getting annotations
|
|
147
|
-
# The new annotationlib currently relies on 'ast' and 'functools'
|
|
148
|
-
# that this project tries to avoid importing.
|
|
149
|
-
|
|
150
|
-
# The basic logic is copied from there, however, replacing ForwardRef
|
|
151
|
-
# with a more basic class.
|
|
152
|
-
# While `annotationlib` is trying to return ForwardRef objects that can
|
|
153
|
-
# be evaluated later, this module only cares about annotations that can
|
|
154
|
-
# be evaluated at the point this function is called.
|
|
155
|
-
# As such we throw away the other information and just return strings
|
|
156
|
-
# instead of forwardrefs.
|
|
157
|
-
|
|
158
|
-
try:
|
|
159
|
-
raw_annotations = annotate(1)
|
|
160
|
-
except NameError:
|
|
161
|
-
pass
|
|
162
|
-
else:
|
|
163
|
-
return raw_annotations
|
|
164
|
-
|
|
165
|
-
# The annotate func may support forwardref natively
|
|
166
|
-
try:
|
|
167
|
-
raw_annotations = annotate(2)
|
|
168
|
-
except NotImplementedError:
|
|
169
|
-
pass
|
|
170
|
-
else:
|
|
171
|
-
return raw_annotations
|
|
172
|
-
|
|
173
|
-
# Not supported so we have to implement our own deferred handling
|
|
174
|
-
# Some modified logic from annotationlib
|
|
175
|
-
namespace = {**annotate.__builtins__, **annotate.__globals__}
|
|
176
|
-
globs = _StringGlobs(namespace)
|
|
177
|
-
|
|
178
|
-
# This handles closures where the variable is defined after get annotations is called.
|
|
179
|
-
if annotate.__closure__:
|
|
180
|
-
freevars = annotate.__code__.co_freevars
|
|
181
|
-
new_closure = []
|
|
182
|
-
for i, cell in enumerate(annotate.__closure__):
|
|
183
|
-
try:
|
|
184
|
-
cell.cell_contents
|
|
185
|
-
except ValueError:
|
|
186
|
-
if i < len(freevars):
|
|
187
|
-
name = freevars[i]
|
|
188
|
-
else:
|
|
189
|
-
name = "__cell__"
|
|
190
|
-
new_closure.append(_CellType(name))
|
|
191
|
-
else:
|
|
192
|
-
new_closure.append(cell)
|
|
193
|
-
closure = tuple(new_closure)
|
|
194
|
-
else:
|
|
195
|
-
closure = None
|
|
196
|
-
|
|
197
|
-
new_annotate = _FunctionType(annotate.__code__, globs, closure=closure)
|
|
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
|
|
206
|
-
|
|
207
|
-
|
|
208
132
|
def get_ns_annotations(ns, eval_str=True):
|
|
209
133
|
"""
|
|
210
134
|
Given a class namespace, attempt to retrieve the
|
|
@@ -221,10 +145,16 @@ def get_ns_annotations(ns, eval_str=True):
|
|
|
221
145
|
|
|
222
146
|
# In 3.14 the 'canonical' method of getting annotations is to use __annotate__
|
|
223
147
|
# If this doesn't exist, check __annotations__ and treat as 3.13 or earlier.
|
|
148
|
+
# This is disabled if __future__ annotations are used, however.
|
|
224
149
|
annotate = ns.get("__annotate__")
|
|
225
150
|
|
|
226
151
|
if annotate is not None:
|
|
227
|
-
|
|
152
|
+
try:
|
|
153
|
+
raw_annotations = annotate(1) # VALUE call
|
|
154
|
+
except (NameError, AttributeError):
|
|
155
|
+
# Slow path, only used if annotations can't be evaluated.
|
|
156
|
+
from annotationlib import Format, call_annotate_function
|
|
157
|
+
raw_annotations = call_annotate_function(annotate, format=Format.FORWARDREF)
|
|
228
158
|
else:
|
|
229
159
|
raw_annotations = ns.get("__annotations__", {})
|
|
230
160
|
|
|
@@ -9,11 +9,6 @@ class _StringGlobs(dict):
|
|
|
9
9
|
def __missing__(self, key: _T) -> _T: ...
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
def call_annotate_func(
|
|
13
|
-
annotate: Callable[[int], dict[str, type | typing.ForwardRef]]
|
|
14
|
-
) -> dict[str, type | str]: ...
|
|
15
|
-
|
|
16
|
-
|
|
17
12
|
def eval_hint(
|
|
18
13
|
hint: type | str,
|
|
19
14
|
context: None | dict[str, typing.Any] = None,
|
|
@@ -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=o9df2KexrwOUrw2GuPKSVwZk5OtIJ6Z5AHyArVPvEzg,52
|
|
4
|
+
ducktools/classbuilder/annotations.py,sha256=9QWofrFwYUxtyzwZ4vrFcoFG1Hi9gMe3mrVS3h_Sn1o,7212
|
|
5
|
+
ducktools/classbuilder/annotations.pyi,sha256=hnXC7eN3bosx0DbIpu7iCK4p16p4n9JAp5rZar9qe80,557
|
|
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.5.dist-info/LICENSE.md,sha256=6Thz9Dbw8R4fWInl6sGl8Rj3UnKnRbDwrc6jZerpugQ,1070
|
|
10
|
+
ducktools_classbuilder-0.7.5.dist-info/METADATA,sha256=ZKoBZozXg4yJD5ToSOJosDJE8oeBCMgHrU_CGXymzQQ,11004
|
|
11
|
+
ducktools_classbuilder-0.7.5.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
|
|
12
|
+
ducktools_classbuilder-0.7.5.dist-info/top_level.txt,sha256=uSDLtio3ZFqdwcsMJ2O5yhjB4Q3ytbBWbA8rJREganc,10
|
|
13
|
+
ducktools_classbuilder-0.7.5.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=SIkfjhjtpB8h4zuKinR8f9uXIG2btFt5dWqwqdWWTLQ,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.3.dist-info/LICENSE.md,sha256=6Thz9Dbw8R4fWInl6sGl8Rj3UnKnRbDwrc6jZerpugQ,1070
|
|
10
|
-
ducktools_classbuilder-0.7.3.dist-info/METADATA,sha256=bPvyPBu8p23LSFZ4Acnc13eQ4RGZzIrgjgn0FJ0dgC0,11004
|
|
11
|
-
ducktools_classbuilder-0.7.3.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
|
|
12
|
-
ducktools_classbuilder-0.7.3.dist-info/top_level.txt,sha256=uSDLtio3ZFqdwcsMJ2O5yhjB4Q3ytbBWbA8rJREganc,10
|
|
13
|
-
ducktools_classbuilder-0.7.3.dist-info/RECORD,,
|
{ducktools_classbuilder-0.7.3.dist-info → ducktools_classbuilder-0.7.5.dist-info}/LICENSE.md
RENAMED
|
File without changes
|
{ducktools_classbuilder-0.7.3.dist-info → ducktools_classbuilder-0.7.5.dist-info}/top_level.txt
RENAMED
|
File without changes
|