ducktools-classbuilder 0.9.0__tar.gz → 0.9.1__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.9.0 → ducktools_classbuilder-0.9.1}/.github/workflows/auto_test.yml +1 -1
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/PKG-INFO +2 -1
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/pyproject.toml +5 -1
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/src/ducktools/classbuilder/__init__.py +31 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/src/ducktools/classbuilder/__init__.pyi +2 -0
- ducktools_classbuilder-0.9.1/src/ducktools/classbuilder/_version.py +2 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/src/ducktools/classbuilder/prefab.py +8 -1
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/src/ducktools/classbuilder/prefab.pyi +2 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/src/ducktools_classbuilder.egg-info/PKG-INFO +2 -1
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/src/ducktools_classbuilder.egg-info/SOURCES.txt +1 -0
- ducktools_classbuilder-0.9.1/tests/prefab/test_replace.py +65 -0
- ducktools_classbuilder-0.9.0/src/ducktools/classbuilder/_version.py +0 -2
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/.github/dependabot.yml +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/.github/workflows/publish_to_pypi.yml +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/.github/workflows/publish_to_testpypi.yml +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/.gitignore +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/.readthedocs.yaml +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/LICENSE +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/MANIFEST.in +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/README.md +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/docs/Makefile +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/docs/api.md +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/docs/approach_vs_tool.md +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/docs/conf.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/docs/extension_examples.md +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/docs/generated_code.md +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/docs/index.md +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/docs/make.bat +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/docs/perf/performance_tests.md +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/docs/prefab/index.md +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/docs/tutorial.md +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/docs_code/docs_ex10_frozen_attributes.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/docs_code/docs_ex1_basic.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/docs_code/docs_ex2_register.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/docs_code/docs_ex3_iterable.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/docs_code/docs_ex5_frozen.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/docs_code/docs_ex7_posonly.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/docs_code/docs_ex8_converters.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/docs_code/docs_ex9_annotated.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/docs_code/index_example.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/docs_code/tutorial_code.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/setup.cfg +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/src/ducktools/classbuilder/annotations.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/src/ducktools/classbuilder/annotations.pyi +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/src/ducktools/classbuilder/py.typed +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/src/ducktools_classbuilder.egg-info/dependency_links.txt +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/src/ducktools_classbuilder.egg-info/requires.txt +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/src/ducktools_classbuilder.egg-info/top_level.txt +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/annotations/test_annotated.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/annotations/test_annotations_module.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/annotations/test_future_annotations.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/conftest.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/prefab/dynamic/test_compare_attrib.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/prefab/dynamic/test_construction.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/prefab/dynamic/test_frozen.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/prefab/dynamic/test_internals.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/prefab/dynamic/test_pre_post_init.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/prefab/dynamic/test_private.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/prefab/dynamic/test_slots_novalues.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/prefab/dynamic/test_slotted_class.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/prefab/dynamic/test_subclass_implementation.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/prefab/shared/conftest.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/prefab/shared/examples/creation.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/prefab/shared/examples/creation_empty.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/prefab/shared/examples/dunders.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/prefab/shared/examples/fails/creation_2.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/prefab/shared/examples/fails/creation_3.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/prefab/shared/examples/fails/creation_5.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/prefab/shared/examples/fails/inheritance_1.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/prefab/shared/examples/fails/inheritance_2.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/prefab/shared/examples/funcs_prefabs.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/prefab/shared/examples/hint_syntax.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/prefab/shared/examples/inheritance.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/prefab/shared/examples/init_ex.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/prefab/shared/examples/kw_only.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/prefab/shared/examples/repr_func.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/prefab/shared/test_creation.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/prefab/shared/test_dunders.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/prefab/shared/test_funcs.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/prefab/shared/test_hint_syntax.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/prefab/shared/test_inheritance.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/prefab/shared/test_init.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/prefab/shared/test_kw_only.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/prefab/shared/test_repr.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/py312_tests/test_generic_annotations.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/py314_tests/_test_support.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/py314_tests/test_forwardref_annotations.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/test_core.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/test_field_flags.py +0 -0
- {ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/test_slotmakermeta.py +0 -0
{ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/.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.14-dev", "3.13", "3.12", "3.11", "3.
|
|
17
|
+
python-version: ["3.14-dev", "3.13", "3.12", "3.11", "pypy-3.11", "3.10", "3.9", "3.8"]
|
|
18
18
|
|
|
19
19
|
steps:
|
|
20
20
|
- uses: actions/checkout@v4
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: ducktools-classbuilder
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.1
|
|
4
4
|
Summary: Toolkit for creating class boilerplate generators
|
|
5
5
|
Author: David C Ellis
|
|
6
6
|
Project-URL: Homepage, https://github.com/davidcellis/ducktools-classbuilder
|
|
@@ -11,6 +11,7 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.11
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.12
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
14
15
|
Classifier: Operating System :: OS Independent
|
|
15
16
|
Classifier: License :: OSI Approved :: MIT License
|
|
16
17
|
Requires-Python: >=3.8
|
|
@@ -21,6 +21,7 @@ classifiers = [
|
|
|
21
21
|
"Programming Language :: Python :: 3.11",
|
|
22
22
|
"Programming Language :: Python :: 3.12",
|
|
23
23
|
"Programming Language :: Python :: 3.13",
|
|
24
|
+
"Programming Language :: Python :: 3.14",
|
|
24
25
|
"Operating System :: OS Independent",
|
|
25
26
|
"License :: OSI Approved :: MIT License",
|
|
26
27
|
]
|
|
@@ -37,7 +38,10 @@ where = ["src"]
|
|
|
37
38
|
|
|
38
39
|
[tool.setuptools_scm]
|
|
39
40
|
version_file = "src/ducktools/classbuilder/_version.py"
|
|
40
|
-
version_file_template = "
|
|
41
|
+
version_file_template = """
|
|
42
|
+
__version__ = "{version}"
|
|
43
|
+
__version_tuple__ = {version_tuple}
|
|
44
|
+
"""
|
|
41
45
|
|
|
42
46
|
[project.urls]
|
|
43
47
|
"Homepage" = "https://github.com/davidcellis/ducktools-classbuilder"
|
{ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/src/ducktools/classbuilder/__init__.py
RENAMED
|
@@ -385,6 +385,36 @@ def eq_generator(cls, funcname="__eq__"):
|
|
|
385
385
|
return GeneratedCode(code, globs)
|
|
386
386
|
|
|
387
387
|
|
|
388
|
+
def replace_generator(cls, funcname="__replace__"):
|
|
389
|
+
# Generate the replace method for built classes
|
|
390
|
+
# unlike the dataclasses implementation this is generated
|
|
391
|
+
attribs = get_fields(cls)
|
|
392
|
+
|
|
393
|
+
# This is essentially the as_dict generator for prefabs
|
|
394
|
+
# except based on attrib.init instead of .serialize
|
|
395
|
+
vals = ", ".join(
|
|
396
|
+
f"'{name}': self.{name}"
|
|
397
|
+
for name, attrib in attribs.items()
|
|
398
|
+
if attrib.init
|
|
399
|
+
)
|
|
400
|
+
init_dict = f"{{{vals}}}"
|
|
401
|
+
|
|
402
|
+
code = (
|
|
403
|
+
f"def {funcname}(self, /, **changes):\n"
|
|
404
|
+
f" new_kwargs = {init_dict}\n"
|
|
405
|
+
f" for name, value in changes.items():\n"
|
|
406
|
+
f" if name not in new_kwargs:\n"
|
|
407
|
+
f" raise TypeError(\n"
|
|
408
|
+
f" f\"{{name!r}} is not a valid replacable \"\n"
|
|
409
|
+
f" f\"field on {{self.__class__.__name__!r}}\"\n"
|
|
410
|
+
f" )\n"
|
|
411
|
+
f" new_kwargs[name] = value\n"
|
|
412
|
+
f" return self.__class__(**new_kwargs)\n"
|
|
413
|
+
)
|
|
414
|
+
globs = {}
|
|
415
|
+
return GeneratedCode(code, globs)
|
|
416
|
+
|
|
417
|
+
|
|
388
418
|
def frozen_setattr_generator(cls, funcname="__setattr__"):
|
|
389
419
|
globs = {}
|
|
390
420
|
field_names = set(get_fields(cls))
|
|
@@ -433,6 +463,7 @@ def frozen_delattr_generator(cls, funcname="__delattr__"):
|
|
|
433
463
|
init_maker = MethodMaker("__init__", init_generator)
|
|
434
464
|
repr_maker = MethodMaker("__repr__", repr_generator)
|
|
435
465
|
eq_maker = MethodMaker("__eq__", eq_generator)
|
|
466
|
+
replace_maker = MethodMaker("__replace__", replace_generator)
|
|
436
467
|
frozen_setattr_maker = MethodMaker("__setattr__", frozen_setattr_generator)
|
|
437
468
|
frozen_delattr_maker = MethodMaker("__delattr__", frozen_delattr_generator)
|
|
438
469
|
default_methods = frozenset({init_maker, repr_maker, eq_maker})
|
|
@@ -73,6 +73,7 @@ def get_repr_generator(
|
|
|
73
73
|
) -> _CodegenType: ...
|
|
74
74
|
def repr_generator(cls: type, funcname: str = "__repr__") -> GeneratedCode: ...
|
|
75
75
|
def eq_generator(cls: type, funcname: str = "__eq__") -> GeneratedCode: ...
|
|
76
|
+
def replace_generator(cls: type, funcname: str = "__replace__") -> GeneratedCode: ...
|
|
76
77
|
|
|
77
78
|
def frozen_setattr_generator(cls: type, funcname: str = "__setattr__") -> GeneratedCode: ...
|
|
78
79
|
|
|
@@ -81,6 +82,7 @@ def frozen_delattr_generator(cls: type, funcname: str = "__delattr__") -> Genera
|
|
|
81
82
|
init_maker: MethodMaker
|
|
82
83
|
repr_maker: MethodMaker
|
|
83
84
|
eq_maker: MethodMaker
|
|
85
|
+
replace_maker: MethodMaker
|
|
84
86
|
frozen_setattr_maker: MethodMaker
|
|
85
87
|
frozen_delattr_maker: MethodMaker
|
|
86
88
|
default_methods: frozenset[MethodMaker]
|
{ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/src/ducktools/classbuilder/prefab.py
RENAMED
|
@@ -30,7 +30,7 @@ from . import (
|
|
|
30
30
|
Field, MethodMaker, GatheredFields, GeneratedCode, SlotMakerMeta,
|
|
31
31
|
builder, get_flags, get_fields,
|
|
32
32
|
make_unified_gatherer,
|
|
33
|
-
frozen_setattr_maker, frozen_delattr_maker,
|
|
33
|
+
eq_maker, frozen_setattr_maker, frozen_delattr_maker, replace_maker,
|
|
34
34
|
get_repr_generator,
|
|
35
35
|
)
|
|
36
36
|
|
|
@@ -441,6 +441,8 @@ def _make_prefab(
|
|
|
441
441
|
if dict_method:
|
|
442
442
|
methods.add(asdict_maker)
|
|
443
443
|
|
|
444
|
+
methods.add(replace_maker)
|
|
445
|
+
|
|
444
446
|
flags = {
|
|
445
447
|
"kw_only": kw_only,
|
|
446
448
|
"slotted": slotted,
|
|
@@ -779,3 +781,8 @@ def as_dict(o):
|
|
|
779
781
|
for name, attrib in flds.items()
|
|
780
782
|
if attrib.serialize
|
|
781
783
|
}
|
|
784
|
+
|
|
785
|
+
def replace(obj, /, **changes):
|
|
786
|
+
if not is_prefab_instance(obj):
|
|
787
|
+
raise TypeError("replace() should be called on prefab instances")
|
|
788
|
+
return obj.__replace__(**changes)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: ducktools-classbuilder
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.1
|
|
4
4
|
Summary: Toolkit for creating class boilerplate generators
|
|
5
5
|
Author: David C Ellis
|
|
6
6
|
Project-URL: Homepage, https://github.com/davidcellis/ducktools-classbuilder
|
|
@@ -11,6 +11,7 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.11
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.12
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
14
15
|
Classifier: Operating System :: OS Independent
|
|
15
16
|
Classifier: License :: OSI Approved :: MIT License
|
|
16
17
|
Requires-Python: >=3.8
|
|
@@ -49,6 +49,7 @@ tests/test_slotmakermeta.py
|
|
|
49
49
|
tests/annotations/test_annotated.py
|
|
50
50
|
tests/annotations/test_annotations_module.py
|
|
51
51
|
tests/annotations/test_future_annotations.py
|
|
52
|
+
tests/prefab/test_replace.py
|
|
52
53
|
tests/prefab/dynamic/test_compare_attrib.py
|
|
53
54
|
tests/prefab/dynamic/test_construction.py
|
|
54
55
|
tests/prefab/dynamic/test_frozen.py
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import copy
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
import pytest
|
|
7
|
+
|
|
8
|
+
from ducktools.classbuilder.prefab import (
|
|
9
|
+
Prefab,
|
|
10
|
+
attribute,
|
|
11
|
+
prefab,
|
|
12
|
+
replace as prefab_replace,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
replace_funcs = [prefab_replace]
|
|
17
|
+
if sys.version_info >= (3, 13): # 3.13 test against the copy version too
|
|
18
|
+
replace_funcs.append(copy.replace) # type: ignore
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def ex_classes() -> tuple[type, type]:
|
|
22
|
+
@prefab
|
|
23
|
+
class ExDecorator:
|
|
24
|
+
a: int = 1
|
|
25
|
+
b: str = "Why?"
|
|
26
|
+
c: str = attribute(default="Non-replacable", init=False)
|
|
27
|
+
|
|
28
|
+
class ExBaseClass(Prefab):
|
|
29
|
+
a: int = 1
|
|
30
|
+
b: str = "Why?"
|
|
31
|
+
c: str = attribute(default="Non-replacable", init=False)
|
|
32
|
+
|
|
33
|
+
return ExDecorator, ExBaseClass
|
|
34
|
+
|
|
35
|
+
example_classes = ex_classes()
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
@pytest.mark.parametrize("replace", replace_funcs)
|
|
39
|
+
@pytest.mark.parametrize("ex_class", example_classes)
|
|
40
|
+
def test_replace_decorator(ex_class, replace):
|
|
41
|
+
ex = ex_class()
|
|
42
|
+
|
|
43
|
+
assert ex.a == 1
|
|
44
|
+
assert ex.b == "Why?"
|
|
45
|
+
assert ex.c == "Non-replacable"
|
|
46
|
+
|
|
47
|
+
ex_r = replace(ex, a=42)
|
|
48
|
+
|
|
49
|
+
assert ex != ex_r
|
|
50
|
+
|
|
51
|
+
assert ex_r.a == 42
|
|
52
|
+
assert ex_r.b == "Why?"
|
|
53
|
+
assert ex_r.c == "Non-replacable"
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
@pytest.mark.parametrize("replace", replace_funcs)
|
|
57
|
+
@pytest.mark.parametrize("ex_class", example_classes)
|
|
58
|
+
def test_replace_fail(ex_class, replace):
|
|
59
|
+
ex = ex_class()
|
|
60
|
+
|
|
61
|
+
with pytest.raises(TypeError):
|
|
62
|
+
replace(ex, c="Fails")
|
|
63
|
+
|
|
64
|
+
with pytest.raises(TypeError):
|
|
65
|
+
replace(ex, d="Does Not Exist")
|
|
File without changes
|
{ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/.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.9.0 → ducktools_classbuilder-0.9.1}/docs/perf/performance_tests.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/docs_code/docs_ex2_register.py
RENAMED
|
File without changes
|
{ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/docs_code/docs_ex3_iterable.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/docs_code/docs_ex8_converters.py
RENAMED
|
File without changes
|
{ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/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
|
{ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/src/ducktools/classbuilder/py.typed
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/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.9.0 → ducktools_classbuilder-0.9.1}/tests/prefab/dynamic/test_frozen.py
RENAMED
|
File without changes
|
{ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/prefab/dynamic/test_internals.py
RENAMED
|
File without changes
|
|
File without changes
|
{ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/prefab/dynamic/test_private.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/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.9.0 → ducktools_classbuilder-0.9.1}/tests/prefab/shared/test_creation.py
RENAMED
|
File without changes
|
{ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/prefab/shared/test_dunders.py
RENAMED
|
File without changes
|
{ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/prefab/shared/test_funcs.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/prefab/shared/test_init.py
RENAMED
|
File without changes
|
{ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/prefab/shared/test_kw_only.py
RENAMED
|
File without changes
|
{ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/prefab/shared/test_repr.py
RENAMED
|
File without changes
|
|
File without changes
|
{ducktools_classbuilder-0.9.0 → ducktools_classbuilder-0.9.1}/tests/py314_tests/_test_support.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|