classcore 1.6__tar.gz → 1.7__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.
- {classcore-1.6 → classcore-1.7}/.gitignore +1 -0
- {classcore-1.6 → classcore-1.7}/PKG-INFO +30 -10
- {classcore-1.6 → classcore-1.7}/README.rst +29 -9
- {classcore-1.6 → classcore-1.7}/sources/classcore/__init__.py +1 -1
- {classcore-1.6 → classcore-1.7}/sources/classcore/standard/behaviors.py +4 -0
- {classcore-1.6 → classcore-1.7}/sources/classcore/standard/classes.py +1 -0
- {classcore-1.6 → classcore-1.7}/sources/classcore/standard/decorators.py +95 -20
- {classcore-1.6 → classcore-1.7}/sources/classcore/standard/modules.py +42 -3
- {classcore-1.6 → classcore-1.7}/LICENSE.txt +0 -0
- {classcore-1.6 → classcore-1.7}/pyproject.toml +0 -0
- {classcore-1.6 → classcore-1.7}/sources/classcore/__/__init__.py +0 -0
- {classcore-1.6 → classcore-1.7}/sources/classcore/__/doctab.py +0 -0
- {classcore-1.6 → classcore-1.7}/sources/classcore/__/imports.py +0 -0
- {classcore-1.6 → classcore-1.7}/sources/classcore/__/nomina.py +0 -0
- {classcore-1.6 → classcore-1.7}/sources/classcore/decorators.py +0 -0
- {classcore-1.6 → classcore-1.7}/sources/classcore/exceptions.py +0 -0
- {classcore-1.6 → classcore-1.7}/sources/classcore/factories.py +0 -0
- {classcore-1.6 → classcore-1.7}/sources/classcore/nomina.py +0 -0
- {classcore-1.6 → classcore-1.7}/sources/classcore/py.typed +0 -0
- {classcore-1.6 → classcore-1.7}/sources/classcore/standard/__.py +0 -0
- {classcore-1.6 → classcore-1.7}/sources/classcore/standard/__init__.py +0 -0
- {classcore-1.6 → classcore-1.7}/sources/classcore/standard/dynadoc.py +0 -0
- {classcore-1.6 → classcore-1.7}/sources/classcore/standard/nomina.py +0 -0
- {classcore-1.6 → classcore-1.7}/sources/classcore/utilities.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: classcore
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.7
|
|
4
4
|
Summary: Foundational class factories and decorators.
|
|
5
5
|
Project-URL: Homepage, https://github.com/emcd/python-classcore
|
|
6
6
|
Project-URL: Documentation, https://emcd.github.io/python-classcore
|
|
@@ -110,14 +110,17 @@ modules.
|
|
|
110
110
|
Installation 📦
|
|
111
111
|
===============================================================================
|
|
112
112
|
|
|
113
|
-
|
|
113
|
+
Method: Install Python Package
|
|
114
|
+
-------------------------------------------------------------------------------
|
|
115
|
+
|
|
116
|
+
Install via `uv <https://github.com/astral-sh/uv/blob/main/README.md>`_ ``pip``
|
|
114
117
|
command:
|
|
115
118
|
|
|
116
119
|
::
|
|
117
120
|
|
|
118
121
|
uv pip install classcore
|
|
119
122
|
|
|
120
|
-
Or, via ``pip``:
|
|
123
|
+
Or, install via ``pip``:
|
|
121
124
|
|
|
122
125
|
::
|
|
123
126
|
|
|
@@ -217,6 +220,23 @@ Use Cases 🎯
|
|
|
217
220
|
* 📦 **Frameworks**: Frameworks with controlled extension and modification.
|
|
218
221
|
|
|
219
222
|
|
|
223
|
+
Contribution 🤝
|
|
224
|
+
===============================================================================
|
|
225
|
+
|
|
226
|
+
Contribution to this project is welcome! However, it must follow the `code of
|
|
227
|
+
conduct
|
|
228
|
+
<https://emcd.github.io/python-project-common/stable/sphinx-html/common/conduct.html>`_
|
|
229
|
+
for the project.
|
|
230
|
+
|
|
231
|
+
Please file bug reports and feature requests in the `issue tracker
|
|
232
|
+
<https://github.com/emcd/python-classcore/issues>`_ or submit `pull
|
|
233
|
+
requests <https://github.com/emcd/python-classcore/pulls>`_ to
|
|
234
|
+
improve the source code or documentation.
|
|
235
|
+
|
|
236
|
+
For development guidance and standards, please see the `development guide
|
|
237
|
+
<https://emcd.github.io/python-classcore/stable/sphinx-html/contribution.html#development>`_.
|
|
238
|
+
|
|
239
|
+
|
|
220
240
|
`More Flair <https://www.imdb.com/title/tt0151804/characters/nm0431918>`_
|
|
221
241
|
===============================================================================
|
|
222
242
|
|
|
@@ -257,24 +277,24 @@ Other Projects by This Author 🌟
|
|
|
257
277
|
===============================================================================
|
|
258
278
|
|
|
259
279
|
|
|
260
|
-
* `python-absence <https://github.com/emcd/python-absence>`_ (`absence <https://pypi.org/project/absence/>`_ on PyPI)
|
|
280
|
+
* `python-absence <https://github.com/emcd/python-absence>`_ (`absence <https://pypi.org/project/absence/>`_ on PyPI)
|
|
261
281
|
|
|
262
282
|
🕳️ A Python library package which provides a **sentinel for absent values** - a falsey, immutable singleton that represents the absence of a value in contexts where ``None`` or ``False`` may be valid values.
|
|
263
|
-
* `python-accretive <https://github.com/emcd/python-accretive>`_ (`accretive <https://pypi.org/project/accretive/>`_ on PyPI)
|
|
283
|
+
* `python-accretive <https://github.com/emcd/python-accretive>`_ (`accretive <https://pypi.org/project/accretive/>`_ on PyPI)
|
|
264
284
|
|
|
265
285
|
🌌 A Python library package which provides **accretive data structures** - collections which can grow but never shrink.
|
|
266
|
-
* `python-dynadoc <https://github.com/emcd/python-dynadoc>`_ (`dynadoc <https://pypi.org/project/dynadoc/>`_ on PyPI)
|
|
286
|
+
* `python-dynadoc <https://github.com/emcd/python-dynadoc>`_ (`dynadoc <https://pypi.org/project/dynadoc/>`_ on PyPI)
|
|
267
287
|
|
|
268
288
|
📝 A Python library package which bridges the gap between **rich annotations** and **automatic documentation generation** with configurable renderers and support for reusable fragments.
|
|
269
|
-
* `python-falsifier <https://github.com/emcd/python-falsifier>`_ (`falsifier <https://pypi.org/project/falsifier/>`_ on PyPI)
|
|
289
|
+
* `python-falsifier <https://github.com/emcd/python-falsifier>`_ (`falsifier <https://pypi.org/project/falsifier/>`_ on PyPI)
|
|
270
290
|
|
|
271
291
|
🎭 A very simple Python library package which provides a **base class for falsey objects** - objects that evaluate to ``False`` in boolean contexts.
|
|
272
|
-
* `python-frigid <https://github.com/emcd/python-frigid>`_ (`frigid <https://pypi.org/project/frigid/>`_ on PyPI)
|
|
292
|
+
* `python-frigid <https://github.com/emcd/python-frigid>`_ (`frigid <https://pypi.org/project/frigid/>`_ on PyPI)
|
|
273
293
|
|
|
274
294
|
🔒 A Python library package which provides **immutable data structures** - collections which cannot be modified after creation.
|
|
275
|
-
* `python-icecream-truck <https://github.com/emcd/python-icecream-truck>`_ (`icecream-truck <https://pypi.org/project/icecream-truck/>`_ on PyPI)
|
|
295
|
+
* `python-icecream-truck <https://github.com/emcd/python-icecream-truck>`_ (`icecream-truck <https://pypi.org/project/icecream-truck/>`_ on PyPI)
|
|
276
296
|
|
|
277
297
|
🍦 **Flavorful Debugging** - A Python library which enhances the powerful and well-known ``icecream`` package with flavored traces, configuration hierarchies, customized outputs, ready-made recipes, and more.
|
|
278
|
-
* `python-mimeogram <https://github.com/emcd/python-mimeogram>`_ (`mimeogram <https://pypi.org/project/mimeogram/>`_ on PyPI)
|
|
298
|
+
* `python-mimeogram <https://github.com/emcd/python-mimeogram>`_ (`mimeogram <https://pypi.org/project/mimeogram/>`_ on PyPI)
|
|
279
299
|
|
|
280
300
|
📨 A command-line tool for **exchanging collections of files with Large Language Models** - bundle multiple files into a single clipboard-ready document while preserving directory structure and metadata... good for code reviews, project sharing, and LLM interactions.
|
|
@@ -81,14 +81,17 @@ modules.
|
|
|
81
81
|
Installation 📦
|
|
82
82
|
===============================================================================
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
Method: Install Python Package
|
|
85
|
+
-------------------------------------------------------------------------------
|
|
86
|
+
|
|
87
|
+
Install via `uv <https://github.com/astral-sh/uv/blob/main/README.md>`_ ``pip``
|
|
85
88
|
command:
|
|
86
89
|
|
|
87
90
|
::
|
|
88
91
|
|
|
89
92
|
uv pip install classcore
|
|
90
93
|
|
|
91
|
-
Or, via ``pip``:
|
|
94
|
+
Or, install via ``pip``:
|
|
92
95
|
|
|
93
96
|
::
|
|
94
97
|
|
|
@@ -188,6 +191,23 @@ Use Cases 🎯
|
|
|
188
191
|
* 📦 **Frameworks**: Frameworks with controlled extension and modification.
|
|
189
192
|
|
|
190
193
|
|
|
194
|
+
Contribution 🤝
|
|
195
|
+
===============================================================================
|
|
196
|
+
|
|
197
|
+
Contribution to this project is welcome! However, it must follow the `code of
|
|
198
|
+
conduct
|
|
199
|
+
<https://emcd.github.io/python-project-common/stable/sphinx-html/common/conduct.html>`_
|
|
200
|
+
for the project.
|
|
201
|
+
|
|
202
|
+
Please file bug reports and feature requests in the `issue tracker
|
|
203
|
+
<https://github.com/emcd/python-classcore/issues>`_ or submit `pull
|
|
204
|
+
requests <https://github.com/emcd/python-classcore/pulls>`_ to
|
|
205
|
+
improve the source code or documentation.
|
|
206
|
+
|
|
207
|
+
For development guidance and standards, please see the `development guide
|
|
208
|
+
<https://emcd.github.io/python-classcore/stable/sphinx-html/contribution.html#development>`_.
|
|
209
|
+
|
|
210
|
+
|
|
191
211
|
`More Flair <https://www.imdb.com/title/tt0151804/characters/nm0431918>`_
|
|
192
212
|
===============================================================================
|
|
193
213
|
|
|
@@ -228,24 +248,24 @@ Other Projects by This Author 🌟
|
|
|
228
248
|
===============================================================================
|
|
229
249
|
|
|
230
250
|
|
|
231
|
-
* `python-absence <https://github.com/emcd/python-absence>`_ (`absence <https://pypi.org/project/absence/>`_ on PyPI)
|
|
251
|
+
* `python-absence <https://github.com/emcd/python-absence>`_ (`absence <https://pypi.org/project/absence/>`_ on PyPI)
|
|
232
252
|
|
|
233
253
|
🕳️ A Python library package which provides a **sentinel for absent values** - a falsey, immutable singleton that represents the absence of a value in contexts where ``None`` or ``False`` may be valid values.
|
|
234
|
-
* `python-accretive <https://github.com/emcd/python-accretive>`_ (`accretive <https://pypi.org/project/accretive/>`_ on PyPI)
|
|
254
|
+
* `python-accretive <https://github.com/emcd/python-accretive>`_ (`accretive <https://pypi.org/project/accretive/>`_ on PyPI)
|
|
235
255
|
|
|
236
256
|
🌌 A Python library package which provides **accretive data structures** - collections which can grow but never shrink.
|
|
237
|
-
* `python-dynadoc <https://github.com/emcd/python-dynadoc>`_ (`dynadoc <https://pypi.org/project/dynadoc/>`_ on PyPI)
|
|
257
|
+
* `python-dynadoc <https://github.com/emcd/python-dynadoc>`_ (`dynadoc <https://pypi.org/project/dynadoc/>`_ on PyPI)
|
|
238
258
|
|
|
239
259
|
📝 A Python library package which bridges the gap between **rich annotations** and **automatic documentation generation** with configurable renderers and support for reusable fragments.
|
|
240
|
-
* `python-falsifier <https://github.com/emcd/python-falsifier>`_ (`falsifier <https://pypi.org/project/falsifier/>`_ on PyPI)
|
|
260
|
+
* `python-falsifier <https://github.com/emcd/python-falsifier>`_ (`falsifier <https://pypi.org/project/falsifier/>`_ on PyPI)
|
|
241
261
|
|
|
242
262
|
🎭 A very simple Python library package which provides a **base class for falsey objects** - objects that evaluate to ``False`` in boolean contexts.
|
|
243
|
-
* `python-frigid <https://github.com/emcd/python-frigid>`_ (`frigid <https://pypi.org/project/frigid/>`_ on PyPI)
|
|
263
|
+
* `python-frigid <https://github.com/emcd/python-frigid>`_ (`frigid <https://pypi.org/project/frigid/>`_ on PyPI)
|
|
244
264
|
|
|
245
265
|
🔒 A Python library package which provides **immutable data structures** - collections which cannot be modified after creation.
|
|
246
|
-
* `python-icecream-truck <https://github.com/emcd/python-icecream-truck>`_ (`icecream-truck <https://pypi.org/project/icecream-truck/>`_ on PyPI)
|
|
266
|
+
* `python-icecream-truck <https://github.com/emcd/python-icecream-truck>`_ (`icecream-truck <https://pypi.org/project/icecream-truck/>`_ on PyPI)
|
|
247
267
|
|
|
248
268
|
🍦 **Flavorful Debugging** - A Python library which enhances the powerful and well-known ``icecream`` package with flavored traces, configuration hierarchies, customized outputs, ready-made recipes, and more.
|
|
249
|
-
* `python-mimeogram <https://github.com/emcd/python-mimeogram>`_ (`mimeogram <https://pypi.org/project/mimeogram/>`_ on PyPI)
|
|
269
|
+
* `python-mimeogram <https://github.com/emcd/python-mimeogram>`_ (`mimeogram <https://pypi.org/project/mimeogram/>`_ on PyPI)
|
|
250
270
|
|
|
251
271
|
📨 A command-line tool for **exchanging collections of files with Large Language Models** - bundle multiple files into a single clipboard-ready document while preserving directory structure and metadata... good for code reviews, project sharing, and LLM interactions.
|
|
@@ -272,6 +272,8 @@ def produce_class_construction_postprocessor(
|
|
|
272
272
|
'instances_mutables', __.mutables_default )
|
|
273
273
|
instances_visibles = arguments.get(
|
|
274
274
|
'instances_visibles', __.visibles_default )
|
|
275
|
+
instances_ignore_init_arguments = arguments.get(
|
|
276
|
+
'instances_ignore_init_arguments', False )
|
|
275
277
|
if dcls_spec and dcls_spec.get( 'kw_only_default', False ):
|
|
276
278
|
from .decorators import dataclass_with_standard_behaviors
|
|
277
279
|
decorator_factory = dataclass_with_standard_behaviors
|
|
@@ -289,6 +291,7 @@ def produce_class_construction_postprocessor(
|
|
|
289
291
|
_nomina.DeleterCore, cores[ 'deleter' ] ),
|
|
290
292
|
surveyor_core = __.typx.cast(
|
|
291
293
|
_nomina.SurveyorCore, cores[ 'surveyor' ] ),
|
|
294
|
+
ignore_init_arguments = instances_ignore_init_arguments,
|
|
292
295
|
mutables = instances_mutables,
|
|
293
296
|
visibles = instances_visibles )
|
|
294
297
|
decorators.append( decorator )
|
|
@@ -391,6 +394,7 @@ def record_class_construction_arguments(
|
|
|
391
394
|
'instances_assigner_core',
|
|
392
395
|
'instances_deleter_core',
|
|
393
396
|
'instances_surveyor_core',
|
|
397
|
+
'instances_ignore_init_arguments',
|
|
394
398
|
'instances_mutables', 'instances_visibles',
|
|
395
399
|
):
|
|
396
400
|
if name not in arguments: continue
|
|
@@ -42,6 +42,7 @@ class ClassFactoryExtraArguments( __.typx.TypedDict, total = False ):
|
|
|
42
42
|
instances_assigner_core: _nomina.AssignerCore
|
|
43
43
|
instances_deleter_core: _nomina.DeleterCore
|
|
44
44
|
instances_surveyor_core: _nomina.SurveyorCore
|
|
45
|
+
instances_ignore_init_arguments: bool
|
|
45
46
|
instances_mutables: _nomina.BehaviorExclusionVerifiersOmni
|
|
46
47
|
instances_visibles: _nomina.BehaviorExclusionVerifiersOmni
|
|
47
48
|
|
|
@@ -220,15 +220,19 @@ def class_factory( # noqa: PLR0913
|
|
|
220
220
|
return decorate
|
|
221
221
|
|
|
222
222
|
|
|
223
|
-
def
|
|
223
|
+
def produce_instances_inception_decorator( # noqa: PLR0913
|
|
224
224
|
attributes_namer: _nomina.AttributesNamer,
|
|
225
225
|
assigner_core: __.typx.Optional[ _nomina.AssignerCore ],
|
|
226
226
|
deleter_core: __.typx.Optional[ _nomina.DeleterCore ],
|
|
227
227
|
surveyor_core: __.typx.Optional[ _nomina.SurveyorCore ],
|
|
228
|
+
ignore_init_arguments: bool,
|
|
228
229
|
mutables: _nomina.BehaviorExclusionVerifiersOmni,
|
|
229
230
|
visibles: _nomina.BehaviorExclusionVerifiersOmni,
|
|
230
231
|
) -> _nomina.Decorator[ __.U ]:
|
|
231
|
-
''' Produces decorator to inject '__init__' method
|
|
232
|
+
''' Produces decorator to inject '__new__' or '__init__' method.
|
|
233
|
+
|
|
234
|
+
Also handles common bookkeeping tasks.
|
|
235
|
+
'''
|
|
232
236
|
cores = dict(
|
|
233
237
|
instances_assigner_core = assigner_core,
|
|
234
238
|
instances_deleter_core = deleter_core,
|
|
@@ -249,7 +253,6 @@ def produce_instances_initialization_decorator( # noqa: PLR0913
|
|
|
249
253
|
core_aname = attributes_namer( 'instances', f"{core_name}_core" )
|
|
250
254
|
setattr( cls, core_aname, core_function )
|
|
251
255
|
behaviors: set[ str ] = set( )
|
|
252
|
-
behaviors_name = attributes_namer( 'instance', 'behaviors' )
|
|
253
256
|
_behaviors.record_behavior(
|
|
254
257
|
cls, attributes_namer = attributes_namer,
|
|
255
258
|
level = 'instances', basename = 'mutables',
|
|
@@ -260,6 +263,66 @@ def produce_instances_initialization_decorator( # noqa: PLR0913
|
|
|
260
263
|
level = 'instances', basename = 'visibles',
|
|
261
264
|
label = _nomina.concealment_label, behaviors = behaviors,
|
|
262
265
|
verifiers = visibles )
|
|
266
|
+
decorator = produce_instances_initialization_decorator(
|
|
267
|
+
attributes_namer = attributes_namer,
|
|
268
|
+
behaviors = behaviors,
|
|
269
|
+
ignore_init_arguments = ignore_init_arguments )
|
|
270
|
+
return decorator( cls )
|
|
271
|
+
|
|
272
|
+
return decorate
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
# def produce_instances_construction_decorator(
|
|
276
|
+
# attributes_namer: _nomina.AttributesNamer,
|
|
277
|
+
# behaviors: __.cabc.MutableSet[ str ],
|
|
278
|
+
# ) -> _nomina.Decorator[ __.U ]:
|
|
279
|
+
# ''' Produces decorator to inject '__new__' method. '''
|
|
280
|
+
# def decorate( cls_: type[ __.U ] ) -> type[ __.U ]:
|
|
281
|
+
# behaviors_name = attributes_namer( 'instance', 'behaviors' )
|
|
282
|
+
# original = cls_.__dict__.get( '__new__' )
|
|
283
|
+
#
|
|
284
|
+
# if original is None:
|
|
285
|
+
#
|
|
286
|
+
# def initialize_with_super(
|
|
287
|
+
# cls: type[ __.U ],
|
|
288
|
+
# *posargs: __.typx.Any,
|
|
289
|
+
# **nomargs: __.typx.Any,
|
|
290
|
+
# ) -> __.U:
|
|
291
|
+
# self = super( cls_, cls ).__new__( cls, *posargs, **nomargs )
|
|
292
|
+
# _activate_instance_behaviors(
|
|
293
|
+
# cls_, self, behaviors_name, behaviors )
|
|
294
|
+
# return self
|
|
295
|
+
#
|
|
296
|
+
# cls_.__new__ = initialize_with_super
|
|
297
|
+
#
|
|
298
|
+
# else:
|
|
299
|
+
#
|
|
300
|
+
# @__.funct.wraps( original )
|
|
301
|
+
# def initialize_with_original(
|
|
302
|
+
# cls: type[ __.U ],
|
|
303
|
+
# *posargs: __.typx.Any,
|
|
304
|
+
# **nomargs: __.typx.Any,
|
|
305
|
+
# ) -> __.U:
|
|
306
|
+
# self = original( cls, *posargs, **nomargs )
|
|
307
|
+
# _activate_instance_behaviors(
|
|
308
|
+
# cls_, self, behaviors_name, behaviors )
|
|
309
|
+
# return self
|
|
310
|
+
#
|
|
311
|
+
# cls_.__new__ = initialize_with_original
|
|
312
|
+
#
|
|
313
|
+
# return cls_
|
|
314
|
+
#
|
|
315
|
+
# return decorate
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
def produce_instances_initialization_decorator(
|
|
319
|
+
attributes_namer: _nomina.AttributesNamer,
|
|
320
|
+
behaviors: __.cabc.MutableSet[ str ],
|
|
321
|
+
ignore_init_arguments: bool,
|
|
322
|
+
) -> _nomina.Decorator[ __.U ]:
|
|
323
|
+
''' Produces decorator to inject '__init__' method into class. '''
|
|
324
|
+
def decorate( cls: type[ __.U ] ) -> type[ __.U ]:
|
|
325
|
+
behaviors_name = attributes_namer( 'instance', 'behaviors' )
|
|
263
326
|
original = cls.__dict__.get( '__init__' )
|
|
264
327
|
|
|
265
328
|
if original is None:
|
|
@@ -267,14 +330,10 @@ def produce_instances_initialization_decorator( # noqa: PLR0913
|
|
|
267
330
|
def initialize_with_super(
|
|
268
331
|
self: object, *posargs: __.typx.Any, **nomargs: __.typx.Any
|
|
269
332
|
) -> None:
|
|
270
|
-
super( cls, self ).__init__(
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
_utilities.getattr0( self, behaviors_name, set( ) ) )
|
|
275
|
-
behaviors_.update( behaviors )
|
|
276
|
-
_utilities.setattr0(
|
|
277
|
-
self, behaviors_name, frozenset( behaviors_ ) )
|
|
333
|
+
if ignore_init_arguments: super( cls, self ).__init__( )
|
|
334
|
+
else: super( cls, self ).__init__( *posargs, **nomargs )
|
|
335
|
+
_activate_instance_behaviors(
|
|
336
|
+
cls, self, behaviors_name, behaviors )
|
|
278
337
|
|
|
279
338
|
cls.__init__ = initialize_with_super
|
|
280
339
|
|
|
@@ -284,14 +343,10 @@ def produce_instances_initialization_decorator( # noqa: PLR0913
|
|
|
284
343
|
def initialize_with_original(
|
|
285
344
|
self: object, *posargs: __.typx.Any, **nomargs: __.typx.Any
|
|
286
345
|
) -> None:
|
|
287
|
-
original( self
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
_utilities.getattr0( self, behaviors_name, set( ) ) )
|
|
292
|
-
behaviors_.update( behaviors )
|
|
293
|
-
_utilities.setattr0(
|
|
294
|
-
self, behaviors_name, frozenset( behaviors_ ) )
|
|
346
|
+
if ignore_init_arguments: original( self )
|
|
347
|
+
else: original( self, *posargs, **nomargs )
|
|
348
|
+
_activate_instance_behaviors(
|
|
349
|
+
cls, self, behaviors_name, behaviors )
|
|
295
350
|
|
|
296
351
|
cls.__init__ = initialize_with_original
|
|
297
352
|
|
|
@@ -484,6 +539,7 @@ def dataclass_with_standard_behaviors( # noqa: PLR0913
|
|
|
484
539
|
assigner_core: __.typx.Optional[ _nomina.AssignerCore ] = None,
|
|
485
540
|
deleter_core: __.typx.Optional[ _nomina.DeleterCore ] = None,
|
|
486
541
|
surveyor_core: __.typx.Optional[ _nomina.SurveyorCore ] = None,
|
|
542
|
+
ignore_init_arguments: bool = False,
|
|
487
543
|
mutables: _nomina.BehaviorExclusionVerifiersOmni = __.mutables_default,
|
|
488
544
|
visibles: _nomina.BehaviorExclusionVerifiersOmni = __.visibles_default,
|
|
489
545
|
) -> _nomina.Decorator[ __.U ]:
|
|
@@ -496,6 +552,7 @@ def dataclass_with_standard_behaviors( # noqa: PLR0913
|
|
|
496
552
|
assigner_core = assigner_core,
|
|
497
553
|
deleter_core = deleter_core,
|
|
498
554
|
surveyor_core = surveyor_core,
|
|
555
|
+
ignore_init_arguments = ignore_init_arguments,
|
|
499
556
|
mutables = mutables,
|
|
500
557
|
visibles = visibles ) )
|
|
501
558
|
preparers: _nomina.DecorationPreparers[ __.U ] = (
|
|
@@ -514,6 +571,7 @@ def with_standard_behaviors( # noqa: PLR0913
|
|
|
514
571
|
assigner_core: __.typx.Optional[ _nomina.AssignerCore ] = None,
|
|
515
572
|
deleter_core: __.typx.Optional[ _nomina.DeleterCore ] = None,
|
|
516
573
|
surveyor_core: __.typx.Optional[ _nomina.SurveyorCore ] = None,
|
|
574
|
+
ignore_init_arguments: bool = False,
|
|
517
575
|
mutables: _nomina.BehaviorExclusionVerifiersOmni = __.mutables_default,
|
|
518
576
|
visibles: _nomina.BehaviorExclusionVerifiersOmni = __.visibles_default,
|
|
519
577
|
) -> _nomina.Decorator[ __.U ]:
|
|
@@ -525,6 +583,7 @@ def with_standard_behaviors( # noqa: PLR0913
|
|
|
525
583
|
assigner_core = assigner_core,
|
|
526
584
|
deleter_core = deleter_core,
|
|
527
585
|
surveyor_core = surveyor_core,
|
|
586
|
+
ignore_init_arguments = ignore_init_arguments,
|
|
528
587
|
mutables = mutables,
|
|
529
588
|
visibles = visibles ) )
|
|
530
589
|
preparers: _nomina.DecorationPreparers[ __.U ] = (
|
|
@@ -534,6 +593,20 @@ def with_standard_behaviors( # noqa: PLR0913
|
|
|
534
593
|
return decoration_by( *decorators, *decorators_, preparers = preparers )
|
|
535
594
|
|
|
536
595
|
|
|
596
|
+
def _activate_instance_behaviors(
|
|
597
|
+
cls: type[ __.U ],
|
|
598
|
+
self: object,
|
|
599
|
+
behaviors_name: str,
|
|
600
|
+
behaviors: __.cabc.MutableSet[ str ],
|
|
601
|
+
) -> None:
|
|
602
|
+
# Only record behaviors at start of MRO.
|
|
603
|
+
if cls is not type( self ): return
|
|
604
|
+
behaviors_: set[ str ] = (
|
|
605
|
+
_utilities.getattr0( self, behaviors_name, set( ) ) )
|
|
606
|
+
behaviors_.update( behaviors )
|
|
607
|
+
_utilities.setattr0( self, behaviors_name, frozenset( behaviors_ ) )
|
|
608
|
+
|
|
609
|
+
|
|
537
610
|
def _produce_instances_decoration_preparers(
|
|
538
611
|
attributes_namer: _nomina.AttributesNamer,
|
|
539
612
|
error_class_provider: _nomina.ErrorClassProvider,
|
|
@@ -554,17 +627,19 @@ def _produce_instances_decorators( # noqa: PLR0913
|
|
|
554
627
|
assigner_core: __.typx.Optional[ _nomina.AssignerCore ],
|
|
555
628
|
deleter_core: __.typx.Optional[ _nomina.DeleterCore ],
|
|
556
629
|
surveyor_core: __.typx.Optional[ _nomina.SurveyorCore ],
|
|
630
|
+
ignore_init_arguments: bool,
|
|
557
631
|
mutables: _nomina.BehaviorExclusionVerifiersOmni,
|
|
558
632
|
visibles: _nomina.BehaviorExclusionVerifiersOmni,
|
|
559
633
|
) -> _nomina.Decorators[ __.U ]:
|
|
560
634
|
''' Produces standard decorators. '''
|
|
561
635
|
decorators: list[ _nomina.Decorator[ __.U ] ] = [ ]
|
|
562
636
|
decorators.append(
|
|
563
|
-
|
|
637
|
+
produce_instances_inception_decorator(
|
|
564
638
|
attributes_namer = attributes_namer,
|
|
565
639
|
assigner_core = assigner_core,
|
|
566
640
|
deleter_core = deleter_core,
|
|
567
641
|
surveyor_core = surveyor_core,
|
|
642
|
+
ignore_init_arguments = ignore_init_arguments,
|
|
568
643
|
mutables = mutables, visibles = visibles ) )
|
|
569
644
|
decorators.append(
|
|
570
645
|
produce_attributes_assignment_decorator(
|
|
@@ -81,7 +81,7 @@ def finalize_module( # noqa: PLR0913
|
|
|
81
81
|
*fragments,
|
|
82
82
|
introspection = introspection,
|
|
83
83
|
table = dynadoc_table )
|
|
84
|
-
|
|
84
|
+
_reclassify_module(
|
|
85
85
|
module,
|
|
86
86
|
attributes_namer = attributes_namer,
|
|
87
87
|
recursive = recursive,
|
|
@@ -108,7 +108,6 @@ def reclassify_modules(
|
|
|
108
108
|
__.ddoc.Doc( ''' New class for module. ''' ),
|
|
109
109
|
] = Module,
|
|
110
110
|
) -> None:
|
|
111
|
-
# TODO? Ensure correct operation with namespace packages.
|
|
112
111
|
''' Reclassifies modules to have attributes concealment and immutability.
|
|
113
112
|
|
|
114
113
|
Can operate on individual modules or entire package hierarchies.
|
|
@@ -121,6 +120,46 @@ def reclassify_modules(
|
|
|
121
120
|
|
|
122
121
|
Has no effect on already-reclassified modules.
|
|
123
122
|
'''
|
|
123
|
+
_reclassify_module(
|
|
124
|
+
attributes,
|
|
125
|
+
attributes_namer = attributes_namer,
|
|
126
|
+
recursive = recursive,
|
|
127
|
+
replacement_class = replacement_class )
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def _reclassify_module(
|
|
131
|
+
attributes: __.typx.Annotated[
|
|
132
|
+
__.cabc.Mapping[ str, __.typx.Any ] | __.types.ModuleType | str,
|
|
133
|
+
__.ddoc.Doc(
|
|
134
|
+
''' Module, module name, or dictionary of object attributes. ''' ),
|
|
135
|
+
], /, *,
|
|
136
|
+
attributes_namer: __.typx.Annotated[
|
|
137
|
+
_nomina.AttributesNamer,
|
|
138
|
+
__.ddoc.Doc(
|
|
139
|
+
''' Attributes namer function with which to seal class. ''' ),
|
|
140
|
+
] = __.calculate_attrname,
|
|
141
|
+
recursive: __.typx.Annotated[
|
|
142
|
+
bool, __.ddoc.Doc( ''' Recursively reclassify package modules? ''' )
|
|
143
|
+
] = False,
|
|
144
|
+
replacement_class: __.typx.Annotated[
|
|
145
|
+
type[ __.types.ModuleType ],
|
|
146
|
+
__.ddoc.Doc( ''' New class for module. ''' ),
|
|
147
|
+
] = Module,
|
|
148
|
+
) -> None:
|
|
149
|
+
# TODO? Ensure correct operation with namespace packages.
|
|
150
|
+
''' Core implementation for module reclassification.
|
|
151
|
+
|
|
152
|
+
Reclassifies modules to have attributes concealment and immutability.
|
|
153
|
+
Can operate on individual modules or entire package hierarchies.
|
|
154
|
+
|
|
155
|
+
Only converts modules within the same package to prevent unintended
|
|
156
|
+
modifications to external modules.
|
|
157
|
+
|
|
158
|
+
When used with a dictionary, converts any module objects found as
|
|
159
|
+
values if they belong to the same package.
|
|
160
|
+
|
|
161
|
+
Has no effect on already-reclassified modules.
|
|
162
|
+
'''
|
|
124
163
|
if isinstance( attributes, str ):
|
|
125
164
|
attributes = __.sys.modules[ attributes ]
|
|
126
165
|
if isinstance( attributes, __.types.ModuleType ):
|
|
@@ -134,7 +173,7 @@ def reclassify_modules(
|
|
|
134
173
|
if not __.inspect.ismodule( value ): continue
|
|
135
174
|
if not value.__name__.startswith( f"{package_name}." ): continue
|
|
136
175
|
if recursive:
|
|
137
|
-
|
|
176
|
+
_reclassify_module(
|
|
138
177
|
value,
|
|
139
178
|
attributes_namer = attributes_namer,
|
|
140
179
|
recursive = True,
|
|
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
|
|
File without changes
|