ducktools-classbuilder 0.8.2__tar.gz → 0.8.4__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.
Potentially problematic release.
This version of ducktools-classbuilder might be problematic. Click here for more details.
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/.github/workflows/auto_test.yml +1 -1
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/PKG-INFO +1 -1
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/src/ducktools/classbuilder/__init__.py +8 -6
- ducktools_classbuilder-0.8.4/src/ducktools/classbuilder/_version.py +2 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/src/ducktools/classbuilder/annotations.py +12 -45
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/src/ducktools/classbuilder/prefab.py +1 -1
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/src/ducktools/classbuilder/prefab.pyi +47 -14
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/src/ducktools_classbuilder.egg-info/PKG-INFO +1 -1
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/src/ducktools_classbuilder.egg-info/SOURCES.txt +1 -0
- ducktools_classbuilder-0.8.4/tests/py314_tests/_test_support.py +42 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/py314_tests/test_forwardref_annotations.py +5 -3
- ducktools_classbuilder-0.8.2/src/ducktools/classbuilder/_version.py +0 -2
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/.github/dependabot.yml +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/.github/workflows/publish_to_pypi.yml +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/.github/workflows/publish_to_testpypi.yml +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/.gitignore +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/.readthedocs.yaml +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/LICENSE +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/MANIFEST.in +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/README.md +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/docs/Makefile +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/docs/api.md +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/docs/approach_vs_tool.md +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/docs/conf.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/docs/extension_examples.md +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/docs/generated_code.md +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/docs/index.md +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/docs/make.bat +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/docs/perf/performance_tests.md +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/docs/prefab/index.md +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/docs/tutorial.md +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/docs_code/docs_ex10_frozen_attributes.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/docs_code/docs_ex1_basic.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/docs_code/docs_ex2_register.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/docs_code/docs_ex3_iterable.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/docs_code/docs_ex5_frozen.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/docs_code/docs_ex7_posonly.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/docs_code/docs_ex8_converters.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/docs_code/docs_ex9_annotated.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/docs_code/index_example.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/docs_code/tutorial_code.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/pyproject.toml +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/setup.cfg +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/src/ducktools/classbuilder/__init__.pyi +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/src/ducktools/classbuilder/annotations.pyi +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/src/ducktools/classbuilder/py.typed +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/src/ducktools_classbuilder.egg-info/dependency_links.txt +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/src/ducktools_classbuilder.egg-info/requires.txt +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/src/ducktools_classbuilder.egg-info/top_level.txt +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/annotations/test_annotated.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/annotations/test_annotations_module.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/annotations/test_future_annotations.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/conftest.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/dynamic/test_compare_attrib.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/dynamic/test_construction.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/dynamic/test_frozen.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/dynamic/test_internals.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/dynamic/test_pre_post_init.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/dynamic/test_private.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/dynamic/test_slots_novalues.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/dynamic/test_slotted_class.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/dynamic/test_subclass_implementation.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/shared/conftest.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/shared/examples/creation.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/shared/examples/creation_empty.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/shared/examples/dunders.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/shared/examples/fails/creation_2.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/shared/examples/fails/creation_3.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/shared/examples/fails/creation_5.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/shared/examples/fails/inheritance_1.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/shared/examples/fails/inheritance_2.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/shared/examples/funcs_prefabs.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/shared/examples/hint_syntax.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/shared/examples/inheritance.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/shared/examples/init_ex.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/shared/examples/kw_only.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/shared/examples/repr_func.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/shared/test_creation.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/shared/test_dunders.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/shared/test_funcs.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/shared/test_hint_syntax.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/shared/test_inheritance.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/shared/test_init.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/shared/test_kw_only.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/shared/test_repr.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/py312_tests/test_generic_annotations.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/test_core.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/test_field_flags.py +0 -0
- {ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/test_slotmakermeta.py +0 -0
{ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/.github/workflows/auto_test.yml
RENAMED
|
@@ -14,7 +14,7 @@ jobs:
|
|
|
14
14
|
fail-fast: false
|
|
15
15
|
matrix:
|
|
16
16
|
os: [ubuntu-latest]
|
|
17
|
-
python-version: ["3.13", "3.12", "3.11", "3.10", "pypy-3.10", "3.9", "3.8"]
|
|
17
|
+
python-version: ["3.14-dev", "3.13", "3.12", "3.11", "3.10", "pypy-3.10", "3.9", "3.8"]
|
|
18
18
|
|
|
19
19
|
steps:
|
|
20
20
|
- uses: actions/checkout@v4
|
{ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/src/ducktools/classbuilder/__init__.py
RENAMED
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
import os
|
|
34
34
|
|
|
35
35
|
from .annotations import get_ns_annotations, is_classvar
|
|
36
|
-
from ._version import __version__, __version_tuple__
|
|
36
|
+
from ._version import __version__, __version_tuple__ # noqa: F401
|
|
37
37
|
|
|
38
38
|
# Change this name if you make heavy modifications
|
|
39
39
|
INTERNALS_DICT = "__classbuilder_internals__"
|
|
@@ -280,7 +280,7 @@ def get_init_generator(null=NOTHING, extra_code=None):
|
|
|
280
280
|
|
|
281
281
|
assigns = "\n ".join(assignments) if assignments else "pass\n"
|
|
282
282
|
code = (
|
|
283
|
-
f"def {funcname}(self, {args}):\n"
|
|
283
|
+
f"def {funcname}(self, {args}):\n"
|
|
284
284
|
f" {assigns}\n"
|
|
285
285
|
)
|
|
286
286
|
# Handle additional function calls
|
|
@@ -663,10 +663,10 @@ class Field(metaclass=SlotMakerMeta):
|
|
|
663
663
|
def from_field(cls, fld, /, **kwargs):
|
|
664
664
|
"""
|
|
665
665
|
Create an instance of field or subclass from another field.
|
|
666
|
-
|
|
667
|
-
This is intended to be used to convert a base
|
|
666
|
+
|
|
667
|
+
This is intended to be used to convert a base
|
|
668
668
|
Field into a subclass.
|
|
669
|
-
|
|
669
|
+
|
|
670
670
|
:param fld: field class to convert
|
|
671
671
|
:param kwargs: Additional keyword arguments for subclasses
|
|
672
672
|
:return: new field subclass instance
|
|
@@ -762,7 +762,9 @@ def make_annotation_gatherer(
|
|
|
762
762
|
else:
|
|
763
763
|
cls_dict = cls_or_ns.__dict__
|
|
764
764
|
|
|
765
|
-
|
|
765
|
+
# This should really be dict[str, field_type] but static analysis
|
|
766
|
+
# doesn't understand this.
|
|
767
|
+
cls_fields: dict[str, Field] = {}
|
|
766
768
|
modifications = {}
|
|
767
769
|
|
|
768
770
|
cls_annotations = get_ns_annotations(cls_dict)
|
|
@@ -23,39 +23,12 @@ import sys
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
class _LazyAnnotationLib:
|
|
26
|
-
def __init__(self):
|
|
27
|
-
if sys.version_info < (3, 14):
|
|
28
|
-
self.annotationlib_unavailable = True
|
|
29
|
-
else:
|
|
30
|
-
self.annotationlib_unavailable = None
|
|
31
|
-
|
|
32
26
|
def __getattr__(self, item):
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
import annotationlib
|
|
38
|
-
except ImportError:
|
|
39
|
-
self.annotationlib_unavailable = True
|
|
40
|
-
raise ImportError("'annotationlib' is not available")
|
|
41
|
-
else:
|
|
42
|
-
self.Format = annotationlib.Format
|
|
43
|
-
self.call_annotate_function = annotationlib.call_annotate_function
|
|
44
|
-
|
|
45
|
-
# This function keeps getting changed and renamed
|
|
46
|
-
get_ns_annotate = getattr(annotationlib, "get_annotate_from_class_namespace", None)
|
|
47
|
-
if get_ns_annotate is None:
|
|
48
|
-
get_ns_annotate = getattr(annotationlib, "get_annotate_function")
|
|
49
|
-
self.get_ns_annotate = get_ns_annotate
|
|
27
|
+
global _lazyannotationlib
|
|
28
|
+
import annotationlib # type: ignore - this is a Python 3.14 library
|
|
29
|
+
_lazyannotationlib = annotationlib
|
|
30
|
+
return getattr(annotationlib, item)
|
|
50
31
|
|
|
51
|
-
if item == "Format":
|
|
52
|
-
return self.Format
|
|
53
|
-
elif item == "call_annotate_function":
|
|
54
|
-
return self.call_annotate_function
|
|
55
|
-
elif item == "get_ns_annotate":
|
|
56
|
-
return get_ns_annotate
|
|
57
|
-
|
|
58
|
-
raise AttributeError(f"{item!r} is not available from this lazy importer")
|
|
59
32
|
|
|
60
33
|
_lazy_annotationlib = _LazyAnnotationLib()
|
|
61
34
|
|
|
@@ -72,19 +45,14 @@ def get_ns_annotations(ns):
|
|
|
72
45
|
annotations = ns.get("__annotations__")
|
|
73
46
|
if annotations is not None:
|
|
74
47
|
annotations = annotations.copy()
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
annotate
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
annotate,
|
|
84
|
-
format=_lazy_annotationlib.Format.FORWARDREF
|
|
85
|
-
)
|
|
86
|
-
except ImportError:
|
|
87
|
-
pass
|
|
48
|
+
elif sys.version_info >= (3, 14):
|
|
49
|
+
# See if we're using PEP-649 annotations
|
|
50
|
+
annotate = _lazy_annotationlib.get_annotate_from_class_namespace(ns)
|
|
51
|
+
if annotate:
|
|
52
|
+
annotations = _lazy_annotationlib.call_annotate_function(
|
|
53
|
+
annotate,
|
|
54
|
+
format=_lazy_annotationlib.Format.FORWARDREF
|
|
55
|
+
)
|
|
88
56
|
|
|
89
57
|
if annotations is None:
|
|
90
58
|
annotations = {}
|
|
@@ -125,4 +93,3 @@ def is_classvar(hint):
|
|
|
125
93
|
):
|
|
126
94
|
return True
|
|
127
95
|
return False
|
|
128
|
-
|
{ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/src/ducktools/classbuilder/prefab.py
RENAMED
|
@@ -36,7 +36,7 @@ from . import (
|
|
|
36
36
|
|
|
37
37
|
# These aren't used but are re-exported for ease of use
|
|
38
38
|
# noinspection PyUnresolvedReferences
|
|
39
|
-
from . import SlotFields, KW_ONLY
|
|
39
|
+
from . import SlotFields, KW_ONLY # noqa: F401
|
|
40
40
|
|
|
41
41
|
PREFAB_FIELDS = "PREFAB_FIELDS"
|
|
42
42
|
PREFAB_INIT_FUNC = "__prefab_init__"
|
{ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/src/ducktools/classbuilder/prefab.pyi
RENAMED
|
@@ -125,23 +125,56 @@ class Prefab(metaclass=SlotMakerMeta):
|
|
|
125
125
|
recursive_repr: bool = False,
|
|
126
126
|
) -> None: ...
|
|
127
127
|
|
|
128
|
-
|
|
129
|
-
#
|
|
130
|
-
#
|
|
128
|
+
# As far as I can tell these are the correct types
|
|
129
|
+
# But mypy.stubtest crashes trying to analyse them
|
|
130
|
+
# Due to the combination of overload and dataclass_transform
|
|
131
|
+
# @typing.overload
|
|
132
|
+
# def prefab(
|
|
133
|
+
# cls: None = None,
|
|
134
|
+
# *,
|
|
135
|
+
# init: bool = ...,
|
|
136
|
+
# repr: bool = ...,
|
|
137
|
+
# eq: bool = ...,
|
|
138
|
+
# iter: bool = ...,
|
|
139
|
+
# match_args: bool = ...,
|
|
140
|
+
# kw_only: bool = ...,
|
|
141
|
+
# frozen: bool = ...,
|
|
142
|
+
# dict_method: bool = ...,
|
|
143
|
+
# recursive_repr: bool = ...,
|
|
144
|
+
# ) -> Callable[[type[_T]], type[_T]]: ...
|
|
145
|
+
|
|
146
|
+
# @dataclass_transform(field_specifiers=(Attribute, attribute))
|
|
147
|
+
# @typing.overload
|
|
148
|
+
# def prefab(
|
|
149
|
+
# cls: type[_T],
|
|
150
|
+
# *,
|
|
151
|
+
# init: bool = ...,
|
|
152
|
+
# repr: bool = ...,
|
|
153
|
+
# eq: bool = ...,
|
|
154
|
+
# iter: bool = ...,
|
|
155
|
+
# match_args: bool = ...,
|
|
156
|
+
# kw_only: bool = ...,
|
|
157
|
+
# frozen: bool = ...,
|
|
158
|
+
# dict_method: bool = ...,
|
|
159
|
+
# recursive_repr: bool = ...,
|
|
160
|
+
# ) -> type[_T]: ...
|
|
161
|
+
|
|
162
|
+
# As mypy crashes, and the only difference is the return type
|
|
163
|
+
# just return `Any` for now to avoid the overload.
|
|
131
164
|
@dataclass_transform(field_specifiers=(Attribute, attribute))
|
|
132
165
|
def prefab(
|
|
133
|
-
cls: type[_T] | None =
|
|
166
|
+
cls: type[_T] | None = ...,
|
|
134
167
|
*,
|
|
135
|
-
init: bool =
|
|
136
|
-
repr: bool =
|
|
137
|
-
eq: bool =
|
|
138
|
-
iter: bool =
|
|
139
|
-
match_args: bool =
|
|
140
|
-
kw_only: bool =
|
|
141
|
-
frozen: bool =
|
|
142
|
-
dict_method: bool =
|
|
143
|
-
recursive_repr: bool =
|
|
144
|
-
) ->
|
|
168
|
+
init: bool = ...,
|
|
169
|
+
repr: bool = ...,
|
|
170
|
+
eq: bool = ...,
|
|
171
|
+
iter: bool = ...,
|
|
172
|
+
match_args: bool = ...,
|
|
173
|
+
kw_only: bool = ...,
|
|
174
|
+
frozen: bool = ...,
|
|
175
|
+
dict_method: bool = ...,
|
|
176
|
+
recursive_repr: bool = ...,
|
|
177
|
+
) -> typing.Any: ...
|
|
145
178
|
|
|
146
179
|
def build_prefab(
|
|
147
180
|
class_name: str,
|
|
@@ -82,4 +82,5 @@ tests/prefab/shared/examples/fails/creation_5.py
|
|
|
82
82
|
tests/prefab/shared/examples/fails/inheritance_1.py
|
|
83
83
|
tests/prefab/shared/examples/fails/inheritance_2.py
|
|
84
84
|
tests/py312_tests/test_generic_annotations.py
|
|
85
|
+
tests/py314_tests/_test_support.py
|
|
85
86
|
tests/py314_tests/test_forwardref_annotations.py
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
from annotationlib import ForwardRef
|
|
2
|
+
|
|
3
|
+
# From test/support/__init__.py
|
|
4
|
+
class EqualToForwardRef:
|
|
5
|
+
"""Helper to ease use of annotationlib.ForwardRef in tests.
|
|
6
|
+
|
|
7
|
+
This checks only attributes that can be set using the constructor.
|
|
8
|
+
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
def __init__(
|
|
12
|
+
self,
|
|
13
|
+
arg,
|
|
14
|
+
*,
|
|
15
|
+
module=None,
|
|
16
|
+
owner=None,
|
|
17
|
+
is_class=False,
|
|
18
|
+
):
|
|
19
|
+
self.__forward_arg__ = arg
|
|
20
|
+
self.__forward_is_class__ = is_class
|
|
21
|
+
self.__forward_module__ = module
|
|
22
|
+
self.__owner__ = owner
|
|
23
|
+
|
|
24
|
+
def __eq__(self, other):
|
|
25
|
+
if not isinstance(other, (EqualToForwardRef, ForwardRef)):
|
|
26
|
+
return NotImplemented
|
|
27
|
+
return (
|
|
28
|
+
self.__forward_arg__ == other.__forward_arg__
|
|
29
|
+
and self.__forward_module__ == other.__forward_module__
|
|
30
|
+
and self.__forward_is_class__ == other.__forward_is_class__
|
|
31
|
+
and self.__owner__ == other.__owner__
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
def __repr__(self):
|
|
35
|
+
extra = []
|
|
36
|
+
if self.__forward_module__ is not None:
|
|
37
|
+
extra.append(f", module={self.__forward_module__!r}")
|
|
38
|
+
if self.__forward_is_class__:
|
|
39
|
+
extra.append(", is_class=True")
|
|
40
|
+
if self.__owner__ is not None:
|
|
41
|
+
extra.append(f", owner={self.__owner__!r}")
|
|
42
|
+
return f"EqualToForwardRef({self.__forward_arg__!r}{''.join(extra)})"
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
# Bare forwardrefs only work in 3.14 or later
|
|
2
2
|
|
|
3
3
|
from ducktools.classbuilder.annotations import get_ns_annotations
|
|
4
|
-
from annotationlib import ForwardRef
|
|
5
4
|
|
|
6
5
|
from pathlib import Path
|
|
7
6
|
|
|
7
|
+
from _test_support import EqualToForwardRef
|
|
8
|
+
|
|
8
9
|
global_type = int
|
|
9
10
|
|
|
11
|
+
|
|
10
12
|
def test_bare_forwardref():
|
|
11
13
|
class Ex:
|
|
12
14
|
a: str
|
|
@@ -15,7 +17,7 @@ def test_bare_forwardref():
|
|
|
15
17
|
|
|
16
18
|
annos = get_ns_annotations(Ex.__dict__)
|
|
17
19
|
|
|
18
|
-
assert annos == {'a': str, 'b': Path, 'c':
|
|
20
|
+
assert annos == {'a': str, 'b': Path, 'c': EqualToForwardRef("plain_forwardref")}
|
|
19
21
|
|
|
20
22
|
|
|
21
23
|
def test_inner_outer_ref():
|
|
@@ -38,7 +40,7 @@ def test_inner_outer_ref():
|
|
|
38
40
|
cls, annos = make_func()
|
|
39
41
|
|
|
40
42
|
# Forwardref given as string if used before it can be evaluated
|
|
41
|
-
assert annos == {"a_val": str, "b_val": int, "c_val":
|
|
43
|
+
assert annos == {"a_val": str, "b_val": int, "c_val": EqualToForwardRef("hyper_type")}
|
|
42
44
|
|
|
43
45
|
# Correctly evaluated if it exists
|
|
44
46
|
assert get_ns_annotations(cls.__dict__) == {
|
|
File without changes
|
{ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/.github/workflows/publish_to_pypi.yml
RENAMED
|
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
|
{ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/docs/perf/performance_tests.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/docs_code/docs_ex2_register.py
RENAMED
|
File without changes
|
{ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/docs_code/docs_ex3_iterable.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/docs_code/docs_ex8_converters.py
RENAMED
|
File without changes
|
{ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/docs_code/docs_ex9_annotated.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/src/ducktools/classbuilder/py.typed
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/annotations/test_annotated.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/dynamic/test_frozen.py
RENAMED
|
File without changes
|
{ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/dynamic/test_internals.py
RENAMED
|
File without changes
|
|
File without changes
|
{ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/dynamic/test_private.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/shared/conftest.py
RENAMED
|
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
|
{ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/shared/test_creation.py
RENAMED
|
File without changes
|
{ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/shared/test_dunders.py
RENAMED
|
File without changes
|
{ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/shared/test_funcs.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/shared/test_init.py
RENAMED
|
File without changes
|
{ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/shared/test_kw_only.py
RENAMED
|
File without changes
|
{ducktools_classbuilder-0.8.2 → ducktools_classbuilder-0.8.4}/tests/prefab/shared/test_repr.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|