classcore 1.5__tar.gz → 1.5.2__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.
Files changed (24) hide show
  1. {classcore-1.5 → classcore-1.5.2}/PKG-INFO +1 -1
  2. {classcore-1.5 → classcore-1.5.2}/sources/classcore/__init__.py +1 -1
  3. {classcore-1.5 → classcore-1.5.2}/sources/classcore/standard/behaviors.py +8 -6
  4. {classcore-1.5 → classcore-1.5.2}/sources/classcore/standard/decorators.py +46 -16
  5. {classcore-1.5 → classcore-1.5.2}/.gitignore +0 -0
  6. {classcore-1.5 → classcore-1.5.2}/LICENSE.txt +0 -0
  7. {classcore-1.5 → classcore-1.5.2}/README.rst +0 -0
  8. {classcore-1.5 → classcore-1.5.2}/pyproject.toml +0 -0
  9. {classcore-1.5 → classcore-1.5.2}/sources/classcore/__/__init__.py +0 -0
  10. {classcore-1.5 → classcore-1.5.2}/sources/classcore/__/doctab.py +0 -0
  11. {classcore-1.5 → classcore-1.5.2}/sources/classcore/__/imports.py +0 -0
  12. {classcore-1.5 → classcore-1.5.2}/sources/classcore/__/nomina.py +0 -0
  13. {classcore-1.5 → classcore-1.5.2}/sources/classcore/decorators.py +0 -0
  14. {classcore-1.5 → classcore-1.5.2}/sources/classcore/exceptions.py +0 -0
  15. {classcore-1.5 → classcore-1.5.2}/sources/classcore/factories.py +0 -0
  16. {classcore-1.5 → classcore-1.5.2}/sources/classcore/nomina.py +0 -0
  17. {classcore-1.5 → classcore-1.5.2}/sources/classcore/py.typed +0 -0
  18. {classcore-1.5 → classcore-1.5.2}/sources/classcore/standard/__.py +0 -0
  19. {classcore-1.5 → classcore-1.5.2}/sources/classcore/standard/__init__.py +0 -0
  20. {classcore-1.5 → classcore-1.5.2}/sources/classcore/standard/classes.py +0 -0
  21. {classcore-1.5 → classcore-1.5.2}/sources/classcore/standard/dynadoc.py +0 -0
  22. {classcore-1.5 → classcore-1.5.2}/sources/classcore/standard/modules.py +0 -0
  23. {classcore-1.5 → classcore-1.5.2}/sources/classcore/standard/nomina.py +0 -0
  24. {classcore-1.5 → classcore-1.5.2}/sources/classcore/utilities.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: classcore
3
- Version: 1.5
3
+ Version: 1.5.2
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
@@ -62,7 +62,7 @@ from .factories import *
62
62
 
63
63
 
64
64
  __version__: __.typx.Annotated[ str, __.ddoc.Visibilities.Reveal ]
65
- __version__ = '1.5'
65
+ __version__ = '1.5.2'
66
66
 
67
67
 
68
68
  standard.dynadoc.assign_module_docstring( __name__, table = __.fragments )
@@ -255,12 +255,6 @@ def produce_class_construction_postprocessor(
255
255
  ) -> None:
256
256
  arguments = getattr( cls, arguments_name, { } )
257
257
  clscls = type( cls )
258
- dynadoc_cfg = arguments.get( 'dynadoc_configuration', { } )
259
- if not dynadoc_cfg: # either metaclass argument or attribute
260
- dynadoc_cfg_name = (
261
- attributes_namer( 'classes', 'dynadoc_configuration' ) )
262
- dynadoc_cfg = getattr( clscls, dynadoc_cfg_name, { } )
263
- decorators.append( __.ddoc.with_docstring( **dynadoc_cfg ) )
264
258
  dcls_spec = getattr( cls, '__dataclass_transform__', None )
265
259
  if not dcls_spec: # either base class or metaclass may be marked
266
260
  dcls_spec = getattr( clscls, '__dataclass_transform__', None )
@@ -297,6 +291,14 @@ def produce_class_construction_postprocessor(
297
291
  mutables = instances_mutables,
298
292
  visibles = instances_visibles )
299
293
  decorators.append( decorator )
294
+ # Dynadoc tracks objects in weakset.
295
+ # Must decorate after any potential class replacements.
296
+ dynadoc_cfg = arguments.get( 'dynadoc_configuration', { } )
297
+ if not dynadoc_cfg: # either metaclass argument or attribute
298
+ dynadoc_cfg_name = (
299
+ attributes_namer( 'classes', 'dynadoc_configuration' ) )
300
+ dynadoc_cfg = getattr( clscls, dynadoc_cfg_name, { } )
301
+ decorators.append( __.ddoc.with_docstring( **dynadoc_cfg ) )
300
302
 
301
303
  return postprocess
302
304
 
@@ -54,6 +54,33 @@ def prepare_dataclass_for_instances(
54
54
  setattr( cls, behaviors_name_m, __.dcls.field( init = False ) )
55
55
 
56
56
 
57
+ def apply_cfc_core_functions(
58
+ clscls: type[ __.T ], /,
59
+ attributes_namer: _nomina.AttributesNamer,
60
+ assigner_core: __.typx.Optional[ _nomina.AssignerCore ] = None,
61
+ deleter_core: __.typx.Optional[ _nomina.DeleterCore ] = None,
62
+ surveyor_core: __.typx.Optional[ _nomina.SurveyorCore ] = None,
63
+ ) -> None:
64
+ ''' Stores core functions on metaclass. '''
65
+ cores = dict(
66
+ classes_assigner_core = assigner_core,
67
+ classes_deleter_core = deleter_core,
68
+ classes_surveyor_core = surveyor_core )
69
+ cores_default = dict(
70
+ assigner = _behaviors.assign_attribute_if_mutable,
71
+ deleter = _behaviors.delete_attribute_if_mutable,
72
+ surveyor = _behaviors.survey_visible_attributes )
73
+ for core_name in ( 'assigner', 'deleter', 'surveyor' ):
74
+ core_function = _behaviors.access_core_function(
75
+ clscls,
76
+ attributes_namer = attributes_namer,
77
+ arguments = cores,
78
+ level = 'classes', name = core_name,
79
+ default = cores_default[ core_name ] )
80
+ core_aname = attributes_namer( 'classes', f"{core_name}_core" )
81
+ setattr( clscls, core_aname, core_function )
82
+
83
+
57
84
  def apply_cfc_dynadoc_configuration(
58
85
  clscls: type[ __.T ], /,
59
86
  attributes_namer: _nomina.AttributesNamer,
@@ -107,7 +134,7 @@ def apply_cfc_attributes_assigner(
107
134
  clscls: type[ __.T ], /,
108
135
  attributes_namer: _nomina.AttributesNamer,
109
136
  error_class_provider: _nomina.ErrorClassProvider,
110
- implementation_core: _nomina.AssignerCore,
137
+ implementation_core: __.typx.Optional[ _nomina.AssignerCore ],
111
138
  ) -> None:
112
139
  ''' Injects '__setattr__' method into metaclass. '''
113
140
  decorator = produce_attributes_assignment_decorator(
@@ -122,7 +149,7 @@ def apply_cfc_attributes_deleter(
122
149
  clscls: type[ __.T ], /,
123
150
  attributes_namer: _nomina.AttributesNamer,
124
151
  error_class_provider: _nomina.ErrorClassProvider,
125
- implementation_core: _nomina.DeleterCore,
152
+ implementation_core: __.typx.Optional[ _nomina.DeleterCore ],
126
153
  ) -> None:
127
154
  ''' Injects '__delattr__' method into metaclass. '''
128
155
  decorator = produce_attributes_deletion_decorator(
@@ -136,7 +163,7 @@ def apply_cfc_attributes_deleter(
136
163
  def apply_cfc_attributes_surveyor(
137
164
  clscls: type[ __.T ],
138
165
  attributes_namer: _nomina.AttributesNamer,
139
- implementation_core: _nomina.SurveyorCore,
166
+ implementation_core: __.typx.Optional[ _nomina.SurveyorCore ],
140
167
  ) -> None:
141
168
  ''' Injects '__dir__' method into metaclass. '''
142
169
  decorator = produce_attributes_surveillance_decorator(
@@ -149,17 +176,20 @@ def apply_cfc_attributes_surveyor(
149
176
  def class_factory( # noqa: PLR0913
150
177
  attributes_namer: _nomina.AttributesNamer = __.calculate_attrname,
151
178
  error_class_provider: _nomina.ErrorClassProvider = __.provide_error_class,
152
- assigner_core: _nomina.AssignerCore = (
153
- _behaviors.assign_attribute_if_mutable ),
154
- deleter_core: _nomina.DeleterCore = (
155
- _behaviors.delete_attribute_if_mutable ),
156
- surveyor_core: _nomina.SurveyorCore = (
157
- _behaviors.survey_visible_attributes ),
179
+ assigner_core: __.typx.Optional[ _nomina.AssignerCore ] = None,
180
+ deleter_core: __.typx.Optional[ _nomina.DeleterCore ] = None,
181
+ surveyor_core: __.typx.Optional[ _nomina.SurveyorCore ] = None,
158
182
  dynadoc_configuration: __.cabc.Mapping[ str, __.typx.Any ] = (
159
183
  _dynadoc_configuration ),
160
184
  ) -> _nomina.Decorator[ __.T ]:
161
185
  ''' Produces decorator to apply standard behaviors to metaclass. '''
162
186
  def decorate( clscls: type[ __.T ] ) -> type[ __.T ]:
187
+ apply_cfc_core_functions(
188
+ clscls,
189
+ attributes_namer = attributes_namer,
190
+ assigner_core = assigner_core,
191
+ deleter_core = deleter_core,
192
+ surveyor_core = surveyor_core )
163
193
  apply_cfc_dynadoc_configuration(
164
194
  clscls,
165
195
  attributes_namer = attributes_namer,
@@ -281,8 +311,8 @@ def produce_attributes_assignment_decorator(
281
311
  core = _behaviors.access_core_function(
282
312
  cls,
283
313
  attributes_namer = attributes_namer,
284
- arguments = { f"{leveli}_assigner": implementation_core },
285
- level = leveli, name = 'assigner',
314
+ arguments = { f"{level}_assigner": implementation_core },
315
+ level = level, name = 'assigner',
286
316
  default = _behaviors.assign_attribute_if_mutable )
287
317
 
288
318
  if original is None:
@@ -344,8 +374,8 @@ def produce_attributes_deletion_decorator(
344
374
  core = _behaviors.access_core_function(
345
375
  cls,
346
376
  attributes_namer = attributes_namer,
347
- arguments = { f"{leveli}_deleter": implementation_core },
348
- level = leveli, name = 'deleter',
377
+ arguments = { f"{level}_deleter": implementation_core },
378
+ level = level, name = 'deleter',
349
379
  default = _behaviors.delete_attribute_if_mutable )
350
380
 
351
381
  if original is None:
@@ -402,8 +432,8 @@ def produce_attributes_surveillance_decorator(
402
432
  core = _behaviors.access_core_function(
403
433
  cls,
404
434
  attributes_namer = attributes_namer,
405
- arguments = { f"{leveli}_surveyor": implementation_core },
406
- level = leveli, name = 'surveyor',
435
+ arguments = { f"{level}_surveyor": implementation_core },
436
+ level = level, name = 'surveyor',
407
437
  default = _behaviors.survey_visible_attributes )
408
438
 
409
439
  if original is None:
@@ -512,7 +542,7 @@ def _produce_instances_decoration_preparers(
512
542
  if class_preparer is not None:
513
543
  preprocessors.append(
514
544
  __.funct.partial(
515
- class_preparer, attributes_namer = attributes_namer ) )
545
+ class_preparer, attributes_namer = attributes_namer ) )
516
546
  return tuple( preprocessors )
517
547
 
518
548
 
File without changes
File without changes
File without changes
File without changes