ducktools-classbuilder 0.9.1__tar.gz → 0.10.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.1 → ducktools_classbuilder-0.10.1}/.github/workflows/auto_test.yml +5 -5
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/.github/workflows/publish_to_pypi.yml +2 -2
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/.github/workflows/publish_to_testpypi.yml +2 -2
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/PKG-INFO +7 -17
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/docs/tutorial.md +5 -6
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/docs_code/docs_ex9_annotated.py +14 -14
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/docs_code/tutorial_code.py +5 -7
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/pyproject.toml +24 -7
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/src/ducktools/classbuilder/__init__.py +178 -77
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/src/ducktools/classbuilder/__init__.pyi +19 -11
- ducktools_classbuilder-0.10.1/src/ducktools/classbuilder/_version.py +2 -0
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/src/ducktools/classbuilder/annotations.py +25 -13
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/src/ducktools/classbuilder/annotations.pyi +4 -0
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/src/ducktools/classbuilder/prefab.py +6 -5
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/src/ducktools/classbuilder/prefab.pyi +3 -1
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/src/ducktools_classbuilder.egg-info/PKG-INFO +7 -17
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/src/ducktools_classbuilder.egg-info/SOURCES.txt +19 -32
- ducktools_classbuilder-0.10.1/src/ducktools_classbuilder.egg-info/requires.txt +5 -0
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/tests/annotations/test_annotated.py +5 -3
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/tests/annotations/test_annotations_module.py +7 -7
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/tests/annotations/test_future_annotations.py +3 -0
- ducktools_classbuilder-0.10.1/tests/conftest.py +20 -0
- ducktools_classbuilder-0.10.1/tests/helpers/utils.py +7 -0
- {ducktools_classbuilder-0.9.1/tests/prefab/dynamic → ducktools_classbuilder-0.10.1/tests/prefab}/test_construction.py +4 -0
- ducktools_classbuilder-0.10.1/tests/prefab/test_creation.py +300 -0
- ducktools_classbuilder-0.10.1/tests/prefab/test_dunders.py +188 -0
- {ducktools_classbuilder-0.9.1/tests/prefab/shared → ducktools_classbuilder-0.10.1/tests/prefab}/test_funcs.py +22 -8
- {ducktools_classbuilder-0.9.1/tests/prefab/shared → ducktools_classbuilder-0.10.1/tests/prefab}/test_hint_syntax.py +23 -6
- ducktools_classbuilder-0.10.1/tests/prefab/test_inheritance.py +123 -0
- {ducktools_classbuilder-0.9.1/tests/prefab/shared → ducktools_classbuilder-0.10.1/tests/prefab}/test_init.py +149 -42
- ducktools_classbuilder-0.9.1/tests/prefab/dynamic/test_internals.py → ducktools_classbuilder-0.10.1/tests/prefab/test_internals_dict.py +1 -1
- {ducktools_classbuilder-0.9.1/tests/prefab/shared → ducktools_classbuilder-0.10.1/tests/prefab}/test_kw_only.py +51 -14
- {ducktools_classbuilder-0.9.1/tests/prefab/shared → ducktools_classbuilder-0.10.1/tests/prefab}/test_repr.py +48 -14
- {ducktools_classbuilder-0.9.1/tests/prefab/dynamic → ducktools_classbuilder-0.10.1/tests/prefab}/test_slotted_class.py +11 -2
- {ducktools_classbuilder-0.9.1/tests/prefab/dynamic → ducktools_classbuilder-0.10.1/tests/prefab}/test_subclass_implementation.py +7 -2
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/tests/py314_tests/test_forwardref_annotations.py +12 -1
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/tests/test_core.py +14 -0
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/tests/test_field_flags.py +6 -0
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/tests/test_slotmakermeta.py +31 -18
- ducktools_classbuilder-0.10.1/uv.lock +939 -0
- ducktools_classbuilder-0.9.1/src/ducktools/classbuilder/_version.py +0 -2
- ducktools_classbuilder-0.9.1/src/ducktools_classbuilder.egg-info/requires.txt +0 -17
- ducktools_classbuilder-0.9.1/tests/conftest.py +0 -10
- ducktools_classbuilder-0.9.1/tests/prefab/shared/conftest.py +0 -17
- ducktools_classbuilder-0.9.1/tests/prefab/shared/examples/creation.py +0 -144
- ducktools_classbuilder-0.9.1/tests/prefab/shared/examples/creation_empty.py +0 -17
- ducktools_classbuilder-0.9.1/tests/prefab/shared/examples/dunders.py +0 -66
- ducktools_classbuilder-0.9.1/tests/prefab/shared/examples/fails/creation_2.py +0 -7
- ducktools_classbuilder-0.9.1/tests/prefab/shared/examples/fails/creation_3.py +0 -7
- ducktools_classbuilder-0.9.1/tests/prefab/shared/examples/fails/creation_5.py +0 -6
- ducktools_classbuilder-0.9.1/tests/prefab/shared/examples/fails/inheritance_1.py +0 -11
- ducktools_classbuilder-0.9.1/tests/prefab/shared/examples/fails/inheritance_2.py +0 -12
- ducktools_classbuilder-0.9.1/tests/prefab/shared/examples/funcs_prefabs.py +0 -20
- ducktools_classbuilder-0.9.1/tests/prefab/shared/examples/hint_syntax.py +0 -19
- ducktools_classbuilder-0.9.1/tests/prefab/shared/examples/inheritance.py +0 -65
- ducktools_classbuilder-0.9.1/tests/prefab/shared/examples/init_ex.py +0 -117
- ducktools_classbuilder-0.9.1/tests/prefab/shared/examples/kw_only.py +0 -49
- ducktools_classbuilder-0.9.1/tests/prefab/shared/examples/repr_func.py +0 -45
- ducktools_classbuilder-0.9.1/tests/prefab/shared/test_creation.py +0 -237
- ducktools_classbuilder-0.9.1/tests/prefab/shared/test_dunders.py +0 -120
- ducktools_classbuilder-0.9.1/tests/prefab/shared/test_inheritance.py +0 -61
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/.github/dependabot.yml +0 -0
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/.gitignore +0 -0
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/.readthedocs.yaml +0 -0
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/LICENSE +0 -0
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/MANIFEST.in +0 -0
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/README.md +0 -0
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/docs/Makefile +0 -0
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/docs/api.md +0 -0
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/docs/approach_vs_tool.md +0 -0
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/docs/conf.py +0 -0
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/docs/extension_examples.md +0 -0
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/docs/generated_code.md +0 -0
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/docs/index.md +0 -0
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/docs/make.bat +0 -0
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/docs/perf/performance_tests.md +0 -0
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/docs/prefab/index.md +0 -0
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/docs_code/docs_ex10_frozen_attributes.py +0 -0
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/docs_code/docs_ex1_basic.py +0 -0
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/docs_code/docs_ex2_register.py +0 -0
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/docs_code/docs_ex3_iterable.py +0 -0
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/docs_code/docs_ex5_frozen.py +0 -0
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/docs_code/docs_ex7_posonly.py +0 -0
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/docs_code/docs_ex8_converters.py +0 -0
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/docs_code/index_example.py +0 -0
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/setup.cfg +0 -0
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/src/ducktools/classbuilder/py.typed +0 -0
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/src/ducktools_classbuilder.egg-info/dependency_links.txt +0 -0
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/src/ducktools_classbuilder.egg-info/top_level.txt +0 -0
- {ducktools_classbuilder-0.9.1/tests/prefab/dynamic → ducktools_classbuilder-0.10.1/tests/prefab}/test_compare_attrib.py +0 -0
- {ducktools_classbuilder-0.9.1/tests/prefab/dynamic → ducktools_classbuilder-0.10.1/tests/prefab}/test_frozen.py +0 -0
- {ducktools_classbuilder-0.9.1/tests/prefab/dynamic → ducktools_classbuilder-0.10.1/tests/prefab}/test_pre_post_init.py +0 -0
- {ducktools_classbuilder-0.9.1/tests/prefab/dynamic → ducktools_classbuilder-0.10.1/tests/prefab}/test_private.py +0 -0
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/tests/prefab/test_replace.py +0 -0
- {ducktools_classbuilder-0.9.1/tests/prefab/dynamic → ducktools_classbuilder-0.10.1/tests/prefab}/test_slots_novalues.py +0 -0
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/tests/py312_tests/test_generic_annotations.py +0 -0
- {ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/tests/py314_tests/_test_support.py +0 -0
{ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.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", "pypy-3.11", "3.10"
|
|
17
|
+
python-version: ["3.14-dev", "3.13", "3.12", "3.11", "pypy-3.11", "3.10"]
|
|
18
18
|
|
|
19
19
|
steps:
|
|
20
20
|
- uses: actions/checkout@v4
|
|
@@ -25,7 +25,7 @@ jobs:
|
|
|
25
25
|
- name: Install dependencies
|
|
26
26
|
run: |
|
|
27
27
|
python -m pip install --upgrade pip
|
|
28
|
-
python -m pip install -e .
|
|
28
|
+
python -m pip install -e . --group dev
|
|
29
29
|
- name: Test with pytest
|
|
30
30
|
run: |
|
|
31
31
|
pytest tests/ --cov=src/ --cov-report=term-missing
|
|
@@ -35,14 +35,14 @@ jobs:
|
|
|
35
35
|
|
|
36
36
|
steps:
|
|
37
37
|
- uses: actions/checkout@v4
|
|
38
|
-
- name: Set up Python 3.
|
|
38
|
+
- name: Set up Python 3.10
|
|
39
39
|
uses: actions/setup-python@v5
|
|
40
40
|
with:
|
|
41
|
-
python-version: "3.
|
|
41
|
+
python-version: "3.10"
|
|
42
42
|
- name: Install dependencies
|
|
43
43
|
run: |
|
|
44
44
|
python -m pip install --upgrade pip
|
|
45
|
-
python -m pip install -e .
|
|
45
|
+
python -m pip install -e . --group dev
|
|
46
46
|
- name: Check type stub files
|
|
47
47
|
run: |
|
|
48
48
|
python -m mypy.stubtest ducktools.classbuilder
|
{ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/.github/workflows/publish_to_pypi.yml
RENAMED
|
@@ -14,7 +14,7 @@ jobs:
|
|
|
14
14
|
- name: Set up Python
|
|
15
15
|
uses: actions/setup-python@v5
|
|
16
16
|
with:
|
|
17
|
-
python-version: "3.
|
|
17
|
+
python-version: "3.10"
|
|
18
18
|
- name: Install pypa/build
|
|
19
19
|
run: >-
|
|
20
20
|
python3 -m
|
|
@@ -69,7 +69,7 @@ jobs:
|
|
|
69
69
|
name: python-package-distributions
|
|
70
70
|
path: dist/
|
|
71
71
|
- name: Sign the dists with Sigstore
|
|
72
|
-
uses: sigstore/gh-action-sigstore-python@v3.0.
|
|
72
|
+
uses: sigstore/gh-action-sigstore-python@v3.0.1
|
|
73
73
|
with:
|
|
74
74
|
release-signing-artifacts: false
|
|
75
75
|
inputs: >-
|
|
@@ -15,7 +15,7 @@ jobs:
|
|
|
15
15
|
- name: Set up Python
|
|
16
16
|
uses: actions/setup-python@v5
|
|
17
17
|
with:
|
|
18
|
-
python-version: "3.
|
|
18
|
+
python-version: "3.10"
|
|
19
19
|
- name: Install pypa/build
|
|
20
20
|
run: >-
|
|
21
21
|
python3 -m
|
|
@@ -52,4 +52,4 @@ jobs:
|
|
|
52
52
|
- name: Publish distribution 📦 to TestPyPI
|
|
53
53
|
uses: pypa/gh-action-pypi-publish@release/v1
|
|
54
54
|
with:
|
|
55
|
-
repository-url: https://test.pypi.org/legacy/
|
|
55
|
+
repository-url: https://test.pypi.org/legacy/
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: ducktools-classbuilder
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.10.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
|
|
7
7
|
Classifier: Development Status :: 4 - Beta
|
|
8
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
9
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
10
8
|
Classifier: Programming Language :: Python :: 3.10
|
|
11
9
|
Classifier: Programming Language :: Python :: 3.11
|
|
12
10
|
Classifier: Programming Language :: Python :: 3.12
|
|
@@ -14,22 +12,14 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
14
12
|
Classifier: Programming Language :: Python :: 3.14
|
|
15
13
|
Classifier: Operating System :: OS Independent
|
|
16
14
|
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
-
Requires-Python: >=3.
|
|
15
|
+
Requires-Python: >=3.10
|
|
18
16
|
Description-Content-Type: text/markdown
|
|
19
17
|
License-File: LICENSE
|
|
20
|
-
Provides-Extra: testing
|
|
21
|
-
Requires-Dist: pytest>=8.2; extra == "testing"
|
|
22
|
-
Requires-Dist: pytest-cov; extra == "testing"
|
|
23
|
-
Requires-Dist: typing_extensions; extra == "testing"
|
|
24
|
-
Provides-Extra: type-checking
|
|
25
|
-
Requires-Dist: mypy; extra == "type-checking"
|
|
26
|
-
Provides-Extra: performance-tests
|
|
27
|
-
Requires-Dist: attrs; extra == "performance-tests"
|
|
28
|
-
Requires-Dist: pydantic; extra == "performance-tests"
|
|
29
18
|
Provides-Extra: docs
|
|
30
|
-
Requires-Dist: sphinx; extra == "docs"
|
|
31
|
-
Requires-Dist: myst-parser; extra == "docs"
|
|
32
|
-
Requires-Dist: sphinx_rtd_theme; extra == "docs"
|
|
19
|
+
Requires-Dist: sphinx>=8.1; extra == "docs"
|
|
20
|
+
Requires-Dist: myst-parser>=4.0; extra == "docs"
|
|
21
|
+
Requires-Dist: sphinx_rtd_theme>=3.0; extra == "docs"
|
|
22
|
+
Dynamic: license-file
|
|
33
23
|
|
|
34
24
|
# Ducktools: Class Builder #
|
|
35
25
|
|
|
@@ -191,14 +191,13 @@ def reportclass(cls):
|
|
|
191
191
|
slot_gatherer = dtbuild.make_slot_gatherer(CustomField)
|
|
192
192
|
|
|
193
193
|
|
|
194
|
-
class ReportClass(metaclass=dtbuild.SlotMakerMeta):
|
|
194
|
+
class ReportClass(metaclass=dtbuild.SlotMakerMeta, gatherer=fields_attribute_gatherer):
|
|
195
195
|
__slots__ = {}
|
|
196
|
-
|
|
197
|
-
|
|
196
|
+
|
|
198
197
|
def __init_subclass__(cls):
|
|
199
|
-
# Check if the metaclass has
|
|
200
|
-
|
|
201
|
-
gatherer =
|
|
198
|
+
# Check if the metaclass has pre-gathered data
|
|
199
|
+
pre_gathered = dtbuild.GATHERED_DATA in vars(cls)
|
|
200
|
+
gatherer = dtbuild.pre_gathered_gatherer if pre_gathered else fields_attribute_gatherer
|
|
202
201
|
methods = {
|
|
203
202
|
dtbuild.eq_maker,
|
|
204
203
|
dtbuild.repr_maker,
|
{ducktools_classbuilder-0.9.1 → ducktools_classbuilder-0.10.1}/docs_code/docs_ex9_annotated.py
RENAMED
|
@@ -6,9 +6,10 @@ from ducktools.classbuilder import (
|
|
|
6
6
|
default_methods,
|
|
7
7
|
get_fields,
|
|
8
8
|
get_methods,
|
|
9
|
-
|
|
9
|
+
pre_gathered_gatherer,
|
|
10
10
|
Field,
|
|
11
11
|
SlotMakerMeta,
|
|
12
|
+
GATHERED_DATA,
|
|
12
13
|
NOTHING,
|
|
13
14
|
)
|
|
14
15
|
|
|
@@ -110,16 +111,15 @@ def annotatedclass(cls=None, *, kw_only=False):
|
|
|
110
111
|
|
|
111
112
|
|
|
112
113
|
# As a base class with slots
|
|
113
|
-
class AnnotatedClass(metaclass=SlotMakerMeta):
|
|
114
|
-
|
|
115
|
-
_meta_gatherer = annotated_gatherer
|
|
116
|
-
|
|
114
|
+
class AnnotatedClass(metaclass=SlotMakerMeta, gatherer=annotated_gatherer):
|
|
115
|
+
|
|
117
116
|
def __init_subclass__(cls, kw_only=False, **kwargs):
|
|
117
|
+
pre_gathered = GATHERED_DATA in cls.__dict__
|
|
118
118
|
slots = "__slots__" in cls.__dict__
|
|
119
119
|
|
|
120
120
|
# if slots is True then fields will already be present in __slots__
|
|
121
121
|
# Use the slot_gatherer for this case
|
|
122
|
-
gatherer =
|
|
122
|
+
gatherer = pre_gathered_gatherer if pre_gathered else annotated_gatherer
|
|
123
123
|
|
|
124
124
|
builder(
|
|
125
125
|
cls,
|
|
@@ -139,10 +139,10 @@ if __name__ == "__main__":
|
|
|
139
139
|
class X:
|
|
140
140
|
x: str
|
|
141
141
|
y: ClassVar[str] = "This should be ignored"
|
|
142
|
-
z: Annotated[ClassVar[str], "Should be ignored"] = "This should also be ignored"
|
|
143
|
-
a: Annotated[int, NO_INIT] = "Not In __init__ signature"
|
|
142
|
+
z: Annotated[ClassVar[str], "Should be ignored"] = "This should also be ignored" # type: ignore
|
|
143
|
+
a: Annotated[int, NO_INIT] = "Not In __init__ signature" # type: ignore
|
|
144
144
|
b: Annotated[str, NO_REPR] = "Not In Repr"
|
|
145
|
-
c: Annotated[list[str], NO_COMPARE] = Field(default_factory=list)
|
|
145
|
+
c: Annotated[list[str], NO_COMPARE] = Field(default_factory=list) # type: ignore
|
|
146
146
|
d: Annotated[str, IGNORE_ALL] = "Not Anywhere"
|
|
147
147
|
e: Annotated[str, KW_ONLY, NO_COMPARE]
|
|
148
148
|
|
|
@@ -150,23 +150,23 @@ if __name__ == "__main__":
|
|
|
150
150
|
class Y(AnnotatedClass):
|
|
151
151
|
x: str
|
|
152
152
|
y: ClassVar[str] = "This should be ignored"
|
|
153
|
-
z: Annotated[ClassVar[str], "Should be ignored"] = "This should also be ignored"
|
|
154
|
-
a: Annotated[int, NO_INIT] = "Not In __init__ signature"
|
|
153
|
+
z: Annotated[ClassVar[str], "Should be ignored"] = "This should also be ignored" # type: ignore
|
|
154
|
+
a: Annotated[int, NO_INIT] = "Not In __init__ signature" # type: ignore
|
|
155
155
|
b: Annotated[str, NO_REPR] = "Not In Repr"
|
|
156
|
-
c: Annotated[list[str], NO_COMPARE] = Field(default_factory=list)
|
|
156
|
+
c: Annotated[list[str], NO_COMPARE] = Field(default_factory=list) # type: ignore
|
|
157
157
|
d: Annotated[str, IGNORE_ALL] = "Not Anywhere"
|
|
158
158
|
e: Annotated[str, KW_ONLY, NO_COMPARE]
|
|
159
159
|
|
|
160
160
|
|
|
161
161
|
# Unslotted Demo
|
|
162
|
-
ex = X("Value of x", e="Value of e")
|
|
162
|
+
ex = X("Value of x", e="Value of e") # type: ignore
|
|
163
163
|
print(ex, "\n")
|
|
164
164
|
|
|
165
165
|
pp(get_fields(X))
|
|
166
166
|
print("\n")
|
|
167
167
|
|
|
168
168
|
# Slotted Demo
|
|
169
|
-
ex = Y("Value of x", e="Value of e")
|
|
169
|
+
ex = Y("Value of x", e="Value of e") # type: ignore
|
|
170
170
|
print(ex, "\n")
|
|
171
171
|
|
|
172
172
|
print(f"Slots: {Y.__dict__.get('__slots__')}")
|
|
@@ -115,14 +115,13 @@ def reportclass(cls):
|
|
|
115
115
|
slot_gatherer = dtbuild.make_slot_gatherer(CustomField)
|
|
116
116
|
|
|
117
117
|
|
|
118
|
-
class ReportClass(metaclass=dtbuild.SlotMakerMeta):
|
|
118
|
+
class ReportClass(metaclass=dtbuild.SlotMakerMeta, gatherer=fields_attribute_gatherer):
|
|
119
119
|
__slots__ = {}
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
|
|
122
121
|
def __init_subclass__(cls):
|
|
123
|
-
# Check if the metaclass has
|
|
124
|
-
|
|
125
|
-
gatherer =
|
|
122
|
+
# Check if the metaclass has pre-gathered data
|
|
123
|
+
pre_gathered = dtbuild.GATHERED_DATA in vars(cls)
|
|
124
|
+
gatherer = dtbuild.pre_gathered_gatherer if pre_gathered else fields_attribute_gatherer
|
|
126
125
|
methods = {
|
|
127
126
|
dtbuild.eq_maker,
|
|
128
127
|
dtbuild.repr_maker,
|
|
@@ -130,7 +129,6 @@ class ReportClass(metaclass=dtbuild.SlotMakerMeta):
|
|
|
130
129
|
report_maker
|
|
131
130
|
}
|
|
132
131
|
|
|
133
|
-
# The class may still have slots unrelated to code generation
|
|
134
132
|
slotted = "__slots__" in vars(cls)
|
|
135
133
|
flags = {"slotted": slotted}
|
|
136
134
|
|
|
@@ -12,11 +12,9 @@ authors = [
|
|
|
12
12
|
{ name="David C Ellis" },
|
|
13
13
|
]
|
|
14
14
|
readme="README.md"
|
|
15
|
-
requires-python = ">=3.
|
|
15
|
+
requires-python = ">=3.10"
|
|
16
16
|
classifiers = [
|
|
17
17
|
"Development Status :: 4 - Beta",
|
|
18
|
-
"Programming Language :: Python :: 3.8",
|
|
19
|
-
"Programming Language :: Python :: 3.9",
|
|
20
18
|
"Programming Language :: Python :: 3.10",
|
|
21
19
|
"Programming Language :: Python :: 3.11",
|
|
22
20
|
"Programming Language :: Python :: 3.12",
|
|
@@ -28,10 +26,24 @@ classifiers = [
|
|
|
28
26
|
dynamic = ['version']
|
|
29
27
|
|
|
30
28
|
[project.optional-dependencies]
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
# Needed for the current readthedocs.yaml
|
|
30
|
+
docs = [
|
|
31
|
+
"sphinx>=8.1",
|
|
32
|
+
"myst-parser>=4.0",
|
|
33
|
+
"sphinx_rtd_theme>=3.0",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
[dependency-groups]
|
|
37
|
+
dev = [
|
|
38
|
+
"pytest>=8.4",
|
|
39
|
+
"pytest-cov>=6.1",
|
|
40
|
+
"mypy>=1.16",
|
|
41
|
+
"typing-extensions>=4.14",
|
|
42
|
+
]
|
|
43
|
+
performance = [
|
|
44
|
+
"attrs>=25.0",
|
|
45
|
+
"pydantic>=2.11",
|
|
46
|
+
]
|
|
35
47
|
|
|
36
48
|
[tool.setuptools.packages.find]
|
|
37
49
|
where = ["src"]
|
|
@@ -51,3 +63,8 @@ addopts= "--cov=src/ --cov-report=term-missing"
|
|
|
51
63
|
testpaths = [
|
|
52
64
|
"tests",
|
|
53
65
|
]
|
|
66
|
+
|
|
67
|
+
[tool.mypy]
|
|
68
|
+
# A combination of types in stubs and tests using dataclass syntax
|
|
69
|
+
# means that there are a number of annotations in otherwise unannotated areas
|
|
70
|
+
disable_error_code = ["annotation-unchecked"]
|
|
@@ -38,7 +38,7 @@ from ._version import __version__, __version_tuple__ # noqa: F401
|
|
|
38
38
|
# Change this name if you make heavy modifications
|
|
39
39
|
INTERNALS_DICT = "__classbuilder_internals__"
|
|
40
40
|
META_GATHERER_NAME = "_meta_gatherer"
|
|
41
|
-
|
|
41
|
+
GATHERED_DATA = "__classbuilder_gathered_fields__"
|
|
42
42
|
|
|
43
43
|
# If testing, make Field classes frozen to make sure attributes are not
|
|
44
44
|
# overwritten. When running this is a performance penalty so it is not required.
|
|
@@ -114,12 +114,16 @@ FIELD_NOTHING = _NothingType("FIELD")
|
|
|
114
114
|
# KW_ONLY sentinel 'type' to use to indicate all subsequent attributes are
|
|
115
115
|
# keyword only
|
|
116
116
|
# noinspection PyPep8Naming
|
|
117
|
-
class
|
|
117
|
+
class _KW_ONLY_META(type):
|
|
118
118
|
def __repr__(self):
|
|
119
|
-
return "<KW_ONLY Sentinel
|
|
119
|
+
return "<KW_ONLY Sentinel>"
|
|
120
120
|
|
|
121
121
|
|
|
122
|
-
KW_ONLY
|
|
122
|
+
class KW_ONLY(metaclass=_KW_ONLY_META):
|
|
123
|
+
"""
|
|
124
|
+
Sentinel Class to indicate that variables declared after
|
|
125
|
+
this sentinel are to be converted to KW_ONLY arguments.
|
|
126
|
+
"""
|
|
123
127
|
|
|
124
128
|
|
|
125
129
|
class GeneratedCode:
|
|
@@ -213,15 +217,23 @@ class _SignatureMaker:
|
|
|
213
217
|
# help(cls) will fail along with inspect.signature(cls)
|
|
214
218
|
# This signature maker descriptor is placed to override __signature__ and force
|
|
215
219
|
# the `__init__` signature to be generated first if the signature is requested.
|
|
216
|
-
def __get__(self, instance, cls):
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
#
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
220
|
+
def __get__(self, instance, cls=None):
|
|
221
|
+
if cls is None:
|
|
222
|
+
cls = type(instance)
|
|
223
|
+
|
|
224
|
+
# force generation of `__init__` function
|
|
225
|
+
_ = cls.__init__
|
|
226
|
+
|
|
227
|
+
if instance is None:
|
|
228
|
+
raise AttributeError(
|
|
229
|
+
f"type object {cls.__name__!r} "
|
|
230
|
+
"has no attribute '__signature__'"
|
|
231
|
+
)
|
|
232
|
+
else:
|
|
233
|
+
raise AttributeError(
|
|
234
|
+
f"{cls.__name__!r} object"
|
|
235
|
+
"has no attribute '__signature__'"
|
|
236
|
+
)
|
|
225
237
|
|
|
226
238
|
|
|
227
239
|
signature_maker = _SignatureMaker()
|
|
@@ -389,7 +401,7 @@ def replace_generator(cls, funcname="__replace__"):
|
|
|
389
401
|
# Generate the replace method for built classes
|
|
390
402
|
# unlike the dataclasses implementation this is generated
|
|
391
403
|
attribs = get_fields(cls)
|
|
392
|
-
|
|
404
|
+
|
|
393
405
|
# This is essentially the as_dict generator for prefabs
|
|
394
406
|
# except based on attrib.init instead of .serialize
|
|
395
407
|
vals = ", ".join(
|
|
@@ -403,7 +415,7 @@ def replace_generator(cls, funcname="__replace__"):
|
|
|
403
415
|
f"def {funcname}(self, /, **changes):\n"
|
|
404
416
|
f" new_kwargs = {init_dict}\n"
|
|
405
417
|
f" for name, value in changes.items():\n"
|
|
406
|
-
f" if name not in new_kwargs:\n"
|
|
418
|
+
f" if name not in new_kwargs:\n"
|
|
407
419
|
f" raise TypeError(\n"
|
|
408
420
|
f" f\"{{name!r}} is not a valid replacable \"\n"
|
|
409
421
|
f" f\"field on {{self.__class__.__name__!r}}\"\n"
|
|
@@ -571,21 +583,25 @@ class SlotMakerMeta(type):
|
|
|
571
583
|
|
|
572
584
|
Will not convert `ClassVar` hinted values.
|
|
573
585
|
"""
|
|
574
|
-
def __new__(cls, name, bases, ns, slots=True, **kwargs):
|
|
586
|
+
def __new__(cls, name, bases, ns, slots=True, gatherer=None, **kwargs):
|
|
575
587
|
# This should only run if slots=True is declared
|
|
576
588
|
# and __slots__ have not already been defined
|
|
577
589
|
if slots and "__slots__" not in ns:
|
|
578
590
|
# Check if a different gatherer has been set in any base classes
|
|
579
591
|
# Default to unified gatherer
|
|
580
|
-
gatherer
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
592
|
+
if gatherer is None:
|
|
593
|
+
gatherer = ns.get(META_GATHERER_NAME, None)
|
|
594
|
+
if not gatherer:
|
|
595
|
+
for base in bases:
|
|
596
|
+
if g := getattr(base, META_GATHERER_NAME, None):
|
|
597
|
+
gatherer = g
|
|
598
|
+
break
|
|
599
|
+
|
|
600
|
+
if not gatherer:
|
|
601
|
+
gatherer = unified_gatherer
|
|
586
602
|
|
|
587
|
-
|
|
588
|
-
|
|
603
|
+
# Set the gatherer in the namespace
|
|
604
|
+
ns[META_GATHERER_NAME] = gatherer
|
|
589
605
|
|
|
590
606
|
# Obtain slots from annotations or attributes
|
|
591
607
|
cls_fields, cls_modifications = gatherer(ns)
|
|
@@ -595,14 +611,54 @@ class SlotMakerMeta(type):
|
|
|
595
611
|
else:
|
|
596
612
|
ns[k] = v
|
|
597
613
|
|
|
614
|
+
slots = {}
|
|
615
|
+
fields = {}
|
|
616
|
+
|
|
617
|
+
for k, v in cls_fields.items():
|
|
618
|
+
slots[k] = v.doc
|
|
619
|
+
if k not in {"__weakref__", "__dict__"}:
|
|
620
|
+
fields[k] = v
|
|
621
|
+
|
|
598
622
|
# Place slots *after* everything else to be safe
|
|
599
|
-
ns["__slots__"] =
|
|
623
|
+
ns["__slots__"] = slots
|
|
624
|
+
|
|
625
|
+
# Place pre-gathered field data - modifications are already applied
|
|
626
|
+
modifications = {}
|
|
627
|
+
ns[GATHERED_DATA] = fields, modifications
|
|
628
|
+
|
|
629
|
+
else:
|
|
630
|
+
if gatherer is not None:
|
|
631
|
+
ns[META_GATHERER_NAME] = gatherer
|
|
600
632
|
|
|
601
633
|
new_cls = super().__new__(cls, name, bases, ns, **kwargs)
|
|
602
634
|
|
|
603
635
|
return new_cls
|
|
604
636
|
|
|
605
637
|
|
|
638
|
+
# This class is set up before fields as it will be used to generate the Fields
|
|
639
|
+
# for Field itself so Field can have generated __eq__, __repr__ and other methods
|
|
640
|
+
class GatheredFields:
|
|
641
|
+
"""
|
|
642
|
+
Helper class to store gathered field data
|
|
643
|
+
"""
|
|
644
|
+
__slots__ = ("fields", "modifications")
|
|
645
|
+
|
|
646
|
+
def __init__(self, fields, modifications):
|
|
647
|
+
self.fields = fields
|
|
648
|
+
self.modifications = modifications
|
|
649
|
+
|
|
650
|
+
def __eq__(self, other):
|
|
651
|
+
if type(self) is type(other):
|
|
652
|
+
return self.fields == other.fields and self.modifications == other.modifications
|
|
653
|
+
|
|
654
|
+
def __repr__(self):
|
|
655
|
+
return f"{type(self).__name__}(fields={self.fields!r}, modifications={self.modifications!r})"
|
|
656
|
+
|
|
657
|
+
def __call__(self, cls_dict):
|
|
658
|
+
# cls_dict will be provided, but isn't needed
|
|
659
|
+
return self.fields, self.modifications
|
|
660
|
+
|
|
661
|
+
|
|
606
662
|
# The Field class can finally be defined.
|
|
607
663
|
# The __init__ method has to be written manually so Fields can be created
|
|
608
664
|
# However after this, the other methods can be generated.
|
|
@@ -628,17 +684,18 @@ class Field(metaclass=SlotMakerMeta):
|
|
|
628
684
|
:param compare: Include in the class __eq__.
|
|
629
685
|
:param kw_only: Make this a keyword only parameter in __init__.
|
|
630
686
|
"""
|
|
631
|
-
|
|
632
|
-
#
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
687
|
+
|
|
688
|
+
# Plain slots are required as part of bootstrapping
|
|
689
|
+
# This prevents SlotMakerMeta from trying to generate 'Field's
|
|
690
|
+
__slots__ = (
|
|
691
|
+
"default",
|
|
692
|
+
"default_factory",
|
|
693
|
+
"type",
|
|
694
|
+
"doc",
|
|
695
|
+
"init",
|
|
696
|
+
"repr",
|
|
697
|
+
"compare",
|
|
698
|
+
"kw_only",
|
|
642
699
|
)
|
|
643
700
|
|
|
644
701
|
# noinspection PyShadowingBuiltins
|
|
@@ -672,6 +729,7 @@ class Field(metaclass=SlotMakerMeta):
|
|
|
672
729
|
self.validate_field()
|
|
673
730
|
|
|
674
731
|
def __init_subclass__(cls, frozen=False):
|
|
732
|
+
# Subclasses of Field can be created as if they are dataclasses
|
|
675
733
|
field_methods = {_field_init_maker, repr_maker, eq_maker}
|
|
676
734
|
if frozen or _UNDER_TESTING:
|
|
677
735
|
field_methods.update({frozen_setattr_maker, frozen_delattr_maker})
|
|
@@ -707,6 +765,66 @@ class Field(metaclass=SlotMakerMeta):
|
|
|
707
765
|
return cls(**argument_dict)
|
|
708
766
|
|
|
709
767
|
|
|
768
|
+
def _build_field():
|
|
769
|
+
# Complete the construction of the Field class
|
|
770
|
+
field_docs = {
|
|
771
|
+
"default": "Standard default value to be used for attributes with this field.",
|
|
772
|
+
"default_factory":
|
|
773
|
+
"A zero-argument function to be called to generate a default value, "
|
|
774
|
+
"useful for mutable obects like lists.",
|
|
775
|
+
"type": "The type of the attribute to be assigned by this field.",
|
|
776
|
+
"doc":
|
|
777
|
+
"The documentation for the attribute that appears when calling "
|
|
778
|
+
"help(...) on the class. (Only in slotted classes).",
|
|
779
|
+
"init": "Include this attribute in the class __init__ parameters.",
|
|
780
|
+
"repr": "Include this attribute in the class __repr__",
|
|
781
|
+
"compare": "Include this attribute in the class __eq__ method",
|
|
782
|
+
"kw_only": "Make this a keyword only parameter in __init__",
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
fields = {
|
|
786
|
+
"default": Field(default=NOTHING, doc=field_docs["default"]),
|
|
787
|
+
"default_factory": Field(default=NOTHING, doc=field_docs["default_factory"]),
|
|
788
|
+
"type": Field(default=NOTHING, doc=field_docs["type"]),
|
|
789
|
+
"doc": Field(default=None, doc=field_docs["doc"]),
|
|
790
|
+
"init": Field(default=True, doc=field_docs["init"]),
|
|
791
|
+
"repr": Field(default=True, doc=field_docs["repr"]),
|
|
792
|
+
"compare": Field(default=True, doc=field_docs["compare"]),
|
|
793
|
+
"kw_only": Field(default=False, doc=field_docs["kw_only"])
|
|
794
|
+
}
|
|
795
|
+
modifications = {"__slots__": field_docs}
|
|
796
|
+
|
|
797
|
+
field_methods = {repr_maker, eq_maker}
|
|
798
|
+
if _UNDER_TESTING:
|
|
799
|
+
field_methods.update({frozen_setattr_maker, frozen_delattr_maker})
|
|
800
|
+
|
|
801
|
+
builder(
|
|
802
|
+
Field,
|
|
803
|
+
gatherer=GatheredFields(fields, modifications),
|
|
804
|
+
methods=field_methods,
|
|
805
|
+
flags={"slotted": True, "kw_only": True},
|
|
806
|
+
)
|
|
807
|
+
|
|
808
|
+
|
|
809
|
+
_build_field()
|
|
810
|
+
del _build_field
|
|
811
|
+
|
|
812
|
+
|
|
813
|
+
def pre_gathered_gatherer(cls_or_ns):
|
|
814
|
+
"""
|
|
815
|
+
Retrieve fields previously gathered by SlotMakerMeta
|
|
816
|
+
|
|
817
|
+
:param cls_or_ns: Class to gather field information from (or class namespace)
|
|
818
|
+
:return: dict of field_name: Field(...) and modifications to be performed by the builder
|
|
819
|
+
"""
|
|
820
|
+
if isinstance(cls_or_ns, (_MappingProxyType, dict)):
|
|
821
|
+
cls_dict = cls_or_ns
|
|
822
|
+
else:
|
|
823
|
+
cls_dict = cls_or_ns.__dict__
|
|
824
|
+
|
|
825
|
+
return cls_dict[GATHERED_DATA]
|
|
826
|
+
|
|
827
|
+
|
|
710
828
|
def make_slot_gatherer(field_type=Field):
|
|
711
829
|
"""
|
|
712
830
|
Create a new annotation gatherer that will work with `Field` instances
|
|
@@ -721,7 +839,7 @@ def make_slot_gatherer(field_type=Field):
|
|
|
721
839
|
Gather field information for class generation based on __slots__
|
|
722
840
|
|
|
723
841
|
:param cls_or_ns: Class to gather field information from (or class namespace)
|
|
724
|
-
:return: dict of field_name: Field(...)
|
|
842
|
+
:return: dict of field_name: Field(...) and modifications to be performed by the builder
|
|
725
843
|
"""
|
|
726
844
|
if isinstance(cls_or_ns, (_MappingProxyType, dict)):
|
|
727
845
|
cls_dict = cls_or_ns
|
|
@@ -883,6 +1001,7 @@ def make_field_gatherer(
|
|
|
883
1001
|
def make_unified_gatherer(
|
|
884
1002
|
field_type=Field,
|
|
885
1003
|
leave_default_values=False,
|
|
1004
|
+
ignore_annotations=False,
|
|
886
1005
|
):
|
|
887
1006
|
"""
|
|
888
1007
|
Create a gatherer that will work via first slots, then
|
|
@@ -891,6 +1010,7 @@ def make_unified_gatherer(
|
|
|
891
1010
|
|
|
892
1011
|
:param field_type: The field class to use for gathering
|
|
893
1012
|
:param leave_default_values: leave default values in place
|
|
1013
|
+
:param ignore_annotations: don't attempt to read annotations
|
|
894
1014
|
:return: gatherer function
|
|
895
1015
|
"""
|
|
896
1016
|
slot_g = make_slot_gatherer(field_type)
|
|
@@ -903,27 +1023,35 @@ def make_unified_gatherer(
|
|
|
903
1023
|
else:
|
|
904
1024
|
cls_dict = cls_or_ns.__dict__
|
|
905
1025
|
|
|
1026
|
+
cls_gathered = cls_dict.get(GATHERED_DATA)
|
|
1027
|
+
if cls_gathered:
|
|
1028
|
+
return pre_gathered_gatherer(cls_dict)
|
|
1029
|
+
|
|
906
1030
|
cls_slots = cls_dict.get("__slots__")
|
|
907
1031
|
|
|
908
1032
|
if isinstance(cls_slots, SlotFields):
|
|
909
1033
|
return slot_g(cls_dict)
|
|
910
1034
|
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
1035
|
+
if ignore_annotations:
|
|
1036
|
+
return attrib_g(cls_dict)
|
|
1037
|
+
else:
|
|
1038
|
+
# To choose between annotation and attribute gatherers
|
|
1039
|
+
# compare sets of names.
|
|
1040
|
+
# Don't bother evaluating string annotations, as we only need names
|
|
1041
|
+
cls_annotations = get_ns_annotations(cls_dict)
|
|
1042
|
+
cls_attributes = {
|
|
1043
|
+
k: v for k, v in cls_dict.items() if isinstance(v, field_type)
|
|
1044
|
+
}
|
|
918
1045
|
|
|
919
|
-
|
|
920
|
-
|
|
1046
|
+
cls_annotation_names = cls_annotations.keys()
|
|
1047
|
+
cls_attribute_names = cls_attributes.keys()
|
|
921
1048
|
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
1049
|
+
if set(cls_annotation_names).issuperset(set(cls_attribute_names)):
|
|
1050
|
+
# All `Field` values have annotations, so use annotation gatherer
|
|
1051
|
+
return anno_g(cls_dict)
|
|
1052
|
+
|
|
1053
|
+
return attrib_g(cls_dict)
|
|
925
1054
|
|
|
926
|
-
return attrib_g(cls_dict)
|
|
927
1055
|
return field_unified_gatherer
|
|
928
1056
|
|
|
929
1057
|
|
|
@@ -935,19 +1063,6 @@ annotation_gatherer = make_annotation_gatherer()
|
|
|
935
1063
|
unified_gatherer = make_unified_gatherer()
|
|
936
1064
|
|
|
937
1065
|
|
|
938
|
-
# Now the gatherers have been defined, add __repr__ and __eq__ to Field.
|
|
939
|
-
_field_methods = {repr_maker, eq_maker}
|
|
940
|
-
if _UNDER_TESTING:
|
|
941
|
-
_field_methods.update({frozen_setattr_maker, frozen_delattr_maker})
|
|
942
|
-
|
|
943
|
-
builder(
|
|
944
|
-
Field,
|
|
945
|
-
gatherer=slot_gatherer,
|
|
946
|
-
methods=_field_methods,
|
|
947
|
-
flags={"slotted": True, "kw_only": True},
|
|
948
|
-
)
|
|
949
|
-
|
|
950
|
-
|
|
951
1066
|
def check_argument_order(cls):
|
|
952
1067
|
"""
|
|
953
1068
|
Raise a SyntaxError if the argument order will be invalid for a generated
|
|
@@ -990,17 +1105,3 @@ def slotclass(cls=None, /, *, methods=default_methods, syntax_check=True):
|
|
|
990
1105
|
check_argument_order(cls)
|
|
991
1106
|
|
|
992
1107
|
return cls
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
@slotclass
|
|
996
|
-
class GatheredFields:
|
|
997
|
-
"""
|
|
998
|
-
A helper gatherer for fields that have been gathered externally.
|
|
999
|
-
"""
|
|
1000
|
-
__slots__ = SlotFields(
|
|
1001
|
-
fields=Field(),
|
|
1002
|
-
modifications=Field(),
|
|
1003
|
-
)
|
|
1004
|
-
|
|
1005
|
-
def __call__(self, cls):
|
|
1006
|
-
return self.fields, self.modifications
|