Coverage for sources/classcore/standard/decorators.py: 100%
188 statements
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-15 02:08 +0000
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-15 02:08 +0000
1# vim: set filetype=python fileencoding=utf-8:
2# -*- coding: utf-8 -*-
4#============================================================================#
5# #
6# Licensed under the Apache License, Version 2.0 (the "License"); #
7# you may not use this file except in compliance with the License. #
8# You may obtain a copy of the License at #
9# #
10# http://www.apache.org/licenses/LICENSE-2.0 #
11# #
12# Unless required by applicable law or agreed to in writing, software #
13# distributed under the License is distributed on an "AS IS" BASIS, #
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
15# See the License for the specific language governing permissions and #
16# limitations under the License. #
17# #
18#============================================================================#
21''' Standard decorators. '''
22# TODO? Add attribute value transformer as standard decorator argument.
25from .. import factories as _factories
26from .. import utilities as _utilities
27from ..decorators import (
28 decoration_by,
29 produce_class_construction_decorator,
30 produce_class_initialization_decorator,
31)
32from . import __
33from . import behaviors as _behaviors
34from . import dynadoc as _dynadoc
35from . import nomina as _nomina
38_dataclass_core = __.dcls.dataclass( kw_only = True, slots = True )
39_dynadoc_configuration = _dynadoc.produce_dynadoc_configuration( )
42def prepare_dataclass_for_instances(
43 cls: type,
44 decorators: _nomina.DecoratorsMutable[ __.U ], /, *,
45 attributes_namer: _nomina.AttributesNamer,
46) -> None:
47 ''' Annotates dataclass in support of instantiation machinery. '''
48 annotations = __.inspect.get_annotations( cls )
49 behaviors_name = attributes_namer( 'instance', 'behaviors' )
50 # NOTE: The behaviors field is a dataclass field, so its name must
51 # stay unmangled; mangling would desynchronize the field from
52 # the slot or class attribute installed by the dataclass
53 # machinery, which addresses it by its plain name.
54 behaviors_name_ = behaviors_name
55 annotations[ behaviors_name_ ] = set[ str ]
56 setattr( cls, '__annotations__', annotations ) # in case of absence
57 setattr( cls, behaviors_name_, __.dcls.field(
58 compare = False, hash = False, init = False, repr = False ) )
61def apply_cfc_core_functions(
62 clscls: type[ __.T ], /,
63 attributes_namer: _nomina.AttributesNamer,
64 assigner_core: __.typx.Optional[ _nomina.AssignerCore ] = None,
65 deleter_core: __.typx.Optional[ _nomina.DeleterCore ] = None,
66 surveyor_core: __.typx.Optional[ _nomina.SurveyorCore ] = None,
67) -> None:
68 ''' Stores core functions on metaclass. '''
69 cores = dict(
70 classes_assigner_core = assigner_core,
71 classes_deleter_core = deleter_core,
72 classes_surveyor_core = surveyor_core )
73 cores_default = dict(
74 assigner = _behaviors.assign_attribute_if_mutable,
75 deleter = _behaviors.delete_attribute_if_mutable,
76 surveyor = _behaviors.survey_visible_attributes )
77 for core_name in ( 'assigner', 'deleter', 'surveyor' ):
78 core_function = _behaviors.access_core_function(
79 clscls,
80 attributes_namer = attributes_namer,
81 arguments = cores,
82 level = 'classes', name = core_name,
83 default = cores_default[ core_name ] )
84 core_aname = attributes_namer( 'classes', f"{core_name}_core" )
85 setattr( clscls, core_aname, core_function )
88def apply_internal_names(
89 cls: type, /,
90 attributes_namer: _nomina.AttributesNamer,
91) -> None:
92 ''' Records the namer's internal-name contribution, if any.
94 Works for metaclasses (contributions inherit to every class the
95 metaclass builds) and for decorator-path classes (contributions
96 ride the class itself, since plain decorated classes have no
97 custom metaclass). Parent wiring may already contribute the
98 same detector (e.g., a diamond re-running the factory with the
99 same namer); keep one of each by identity.
100 '''
101 detector: __.typx.Optional[ _nomina.InternalNameDetector ] = (
102 getattr( attributes_namer, 'is_internal_name', None ) )
103 if detector is None: return
104 detectors: _nomina.InternalNameDetectors = getattr(
105 cls, __.calculate_contribution_name( ), ( ) )
106 if any( __.is_same_detector( detector, d ) for d in detectors ): return
107 setattr(
108 cls, __.calculate_contribution_name( ),
109 ( *detectors, detector ) )
112def apply_cfc_dynadoc_configuration(
113 clscls: type[ __.T ], /,
114 attributes_namer: _nomina.AttributesNamer,
115 configuration: _nomina.DynadocConfiguration,
116) -> None:
117 ''' Stores Dynadoc configuration on metaclass. '''
118 configuration_name = attributes_namer( 'classes', 'dynadoc_configuration' )
119 setattr( clscls, configuration_name, configuration )
122def apply_cfc_constructor(
123 clscls: type[ __.T ], /,
124 attributes_namer: _nomina.AttributesNamer,
125 error_class_provider: _nomina.ErrorClassProvider,
126) -> None:
127 ''' Injects '__new__' method into metaclass. '''
128 preprocessors = (
129 _behaviors.produce_class_construction_preprocessor(
130 attributes_namer = attributes_namer ), )
131 postprocessors = (
132 _behaviors.produce_class_construction_postprocessor(
133 attributes_namer = attributes_namer,
134 error_class_provider = error_class_provider ), )
135 constructor: _nomina.ClassConstructor[ __.T ] = (
136 _factories.produce_class_constructor(
137 attributes_namer = attributes_namer,
138 preprocessors = preprocessors,
139 postprocessors = postprocessors ) )
140 decorator = produce_class_construction_decorator(
141 attributes_namer = attributes_namer, constructor = constructor )
142 decorator( clscls )
145def apply_cfc_initializer(
146 clscls: type[ __.T ], /, attributes_namer: _nomina.AttributesNamer
147) -> None:
148 ''' Injects '__init__' method into metaclass. '''
149 completers = (
150 _behaviors.produce_class_initialization_completer(
151 attributes_namer = attributes_namer ), )
152 initializer = (
153 _factories.produce_class_initializer(
154 attributes_namer = attributes_namer,
155 completers = completers ) )
156 decorator = produce_class_initialization_decorator(
157 attributes_namer = attributes_namer, initializer = initializer )
158 decorator( clscls )
161def apply_cfc_attributes_assigner(
162 clscls: type[ __.T ], /,
163 attributes_namer: _nomina.AttributesNamer,
164 error_class_provider: _nomina.ErrorClassProvider,
165 implementation_core: __.typx.Optional[ _nomina.AssignerCore ],
166) -> None:
167 ''' Injects '__setattr__' method into metaclass. '''
168 decorator = produce_attributes_assignment_decorator(
169 level = 'classes',
170 attributes_namer = attributes_namer,
171 error_class_provider = error_class_provider,
172 implementation_core = implementation_core )
173 decorator( clscls )
176def apply_cfc_attributes_deleter(
177 clscls: type[ __.T ], /,
178 attributes_namer: _nomina.AttributesNamer,
179 error_class_provider: _nomina.ErrorClassProvider,
180 implementation_core: __.typx.Optional[ _nomina.DeleterCore ],
181) -> None:
182 ''' Injects '__delattr__' method into metaclass. '''
183 decorator = produce_attributes_deletion_decorator(
184 level = 'classes',
185 attributes_namer = attributes_namer,
186 error_class_provider = error_class_provider,
187 implementation_core = implementation_core )
188 decorator( clscls )
191def apply_cfc_attributes_surveyor(
192 clscls: type[ __.T ],
193 attributes_namer: _nomina.AttributesNamer,
194 implementation_core: __.typx.Optional[ _nomina.SurveyorCore ],
195) -> None:
196 ''' Injects '__dir__' method into metaclass. '''
197 decorator = produce_attributes_surveillance_decorator(
198 level = 'classes',
199 attributes_namer = attributes_namer,
200 implementation_core = implementation_core )
201 decorator( clscls )
204def class_factory( # noqa: PLR0913, PLR0917
205 attributes_namer: _nomina.AttributesNamer = __.calculate_attrname,
206 error_class_provider: _nomina.ErrorClassProvider = __.provide_error_class,
207 assigner_core: __.typx.Optional[ _nomina.AssignerCore ] = None,
208 deleter_core: __.typx.Optional[ _nomina.DeleterCore ] = None,
209 surveyor_core: __.typx.Optional[ _nomina.SurveyorCore ] = None,
210 dynadoc_configuration: __.cabc.Mapping[ str, __.typx.Any ] = (
211 _dynadoc_configuration ),
212) -> _nomina.Decorator[ __.T ]:
213 ''' Produces decorator to apply standard behaviors to metaclass. '''
214 def decorate( clscls: type[ __.T ] ) -> type[ __.T ]:
215 apply_cfc_core_functions(
216 clscls,
217 attributes_namer = attributes_namer,
218 assigner_core = assigner_core,
219 deleter_core = deleter_core,
220 surveyor_core = surveyor_core )
221 apply_internal_names(
222 clscls, attributes_namer = attributes_namer )
223 apply_cfc_dynadoc_configuration(
224 clscls,
225 attributes_namer = attributes_namer,
226 configuration = dynadoc_configuration )
227 apply_cfc_constructor(
228 clscls,
229 attributes_namer = attributes_namer,
230 error_class_provider = error_class_provider )
231 apply_cfc_initializer( clscls, attributes_namer = attributes_namer )
232 apply_cfc_attributes_assigner(
233 clscls,
234 attributes_namer = attributes_namer,
235 error_class_provider = error_class_provider,
236 implementation_core = assigner_core )
237 apply_cfc_attributes_deleter(
238 clscls,
239 attributes_namer = attributes_namer,
240 error_class_provider = error_class_provider,
241 implementation_core = deleter_core )
242 apply_cfc_attributes_surveyor(
243 clscls,
244 attributes_namer = attributes_namer,
245 implementation_core = surveyor_core )
246 return clscls
248 return decorate
251def produce_instances_inception_decorator( # noqa: PLR0913, PLR0917
252 attributes_namer: _nomina.AttributesNamer,
253 assigner_core: __.typx.Optional[ _nomina.AssignerCore ],
254 deleter_core: __.typx.Optional[ _nomina.DeleterCore ],
255 surveyor_core: __.typx.Optional[ _nomina.SurveyorCore ],
256 ignore_init_arguments: bool,
257 mutables: _nomina.BehaviorExclusionVerifiersOmni,
258 visibles: _nomina.BehaviorExclusionVerifiersOmni,
259) -> _nomina.Decorator[ __.U ]:
260 ''' Produces decorator to inject '__new__' or '__init__' method.
262 Also handles common bookkeeping tasks.
263 '''
264 cores = dict(
265 instances_assigner_core = assigner_core,
266 instances_deleter_core = deleter_core,
267 instances_surveyor_core = surveyor_core )
268 cores_default = dict(
269 assigner = _behaviors.assign_attribute_if_mutable,
270 deleter = _behaviors.delete_attribute_if_mutable,
271 surveyor = _behaviors.survey_visible_attributes )
273 def decorate( cls: type[ __.U ] ) -> type[ __.U ]:
274 apply_internal_names(
275 cls, attributes_namer = attributes_namer )
276 for core_name in ( 'assigner', 'deleter', 'surveyor' ):
277 core_function = _behaviors.access_core_function(
278 cls,
279 attributes_namer = attributes_namer,
280 arguments = cores,
281 level = 'instances', name = core_name,
282 default = cores_default[ core_name ] )
283 core_aname = attributes_namer( 'instances', f"{core_name}_core" )
284 setattr( cls, core_aname, core_function )
285 behaviors: set[ str ] = set( )
286 _behaviors.record_behavior(
287 cls, attributes_namer = attributes_namer,
288 level = 'instances', basename = 'mutables',
289 label = _nomina.immutability_label, behaviors = behaviors,
290 verifiers = mutables )
291 _behaviors.record_behavior(
292 cls, attributes_namer = attributes_namer,
293 level = 'instances', basename = 'visibles',
294 label = _nomina.concealment_label, behaviors = behaviors,
295 verifiers = visibles )
296 decorator = produce_instances_initialization_decorator(
297 attributes_namer = attributes_namer,
298 behaviors = behaviors,
299 ignore_init_arguments = ignore_init_arguments )
300 return decorator( cls )
302 return decorate
305# def produce_instances_construction_decorator(
306# attributes_namer: _nomina.AttributesNamer,
307# behaviors: __.cabc.MutableSet[ str ],
308# ) -> _nomina.Decorator[ __.U ]:
309# ''' Produces decorator to inject '__new__' method. '''
310# def decorate( cls_: type[ __.U ] ) -> type[ __.U ]:
311# behaviors_name = attributes_namer( 'instance', 'behaviors' )
312# original = cls_.__dict__.get( '__new__' )
313#
314# if original is None:
315#
316# def initialize_with_super(
317# cls: type[ __.U ],
318# *posargs: __.typx.Any,
319# **nomargs: __.typx.Any,
320# ) -> __.U:
321# self = super( cls_, cls ).__new__( cls, *posargs, **nomargs )
322# _activate_instance_behaviors(
323# cls_, self, behaviors_name, behaviors )
324# return self
325#
326# cls_.__new__ = initialize_with_super
327#
328# else:
329#
330# @__.funct.wraps( original )
331# def initialize_with_original(
332# cls: type[ __.U ],
333# *posargs: __.typx.Any,
334# **nomargs: __.typx.Any,
335# ) -> __.U:
336# self = original( cls, *posargs, **nomargs )
337# _activate_instance_behaviors(
338# cls_, self, behaviors_name, behaviors )
339# return self
340#
341# cls_.__new__ = initialize_with_original
342#
343# return cls_
344#
345# return decorate
348def produce_instances_initialization_decorator(
349 attributes_namer: _nomina.AttributesNamer,
350 behaviors: __.cabc.MutableSet[ str ],
351 ignore_init_arguments: bool,
352) -> _nomina.Decorator[ __.U ]:
353 ''' Produces decorator to inject '__init__' method into class. '''
354 def decorate( cls: type[ __.U ] ) -> type[ __.U ]:
355 behaviors_name = attributes_namer( 'instance', 'behaviors' )
356 original = cls.__dict__.get( '__init__' )
358 if original is None:
360 def initialize_with_super(
361 self: object, *posargs: __.typx.Any, **nomargs: __.typx.Any
362 ) -> None:
363 if ignore_init_arguments: super( cls, self ).__init__( )
364 else: super( cls, self ).__init__( *posargs, **nomargs )
365 _activate_instance_behaviors(
366 cls, self, behaviors_name, behaviors )
368 cls.__init__ = initialize_with_super
370 else:
372 @__.funct.wraps( original )
373 def initialize_with_original(
374 self: object, *posargs: __.typx.Any, **nomargs: __.typx.Any
375 ) -> None:
376 if ignore_init_arguments: original( self )
377 else: original( self, *posargs, **nomargs )
378 _activate_instance_behaviors(
379 cls, self, behaviors_name, behaviors )
381 cls.__init__ = initialize_with_original
383 return cls
385 return decorate
388def produce_attributes_assignment_decorator(
389 level: str,
390 attributes_namer: _nomina.AttributesNamer,
391 error_class_provider: _nomina.ErrorClassProvider,
392 implementation_core: __.typx.Optional[ _nomina.AssignerCore ],
393) -> _nomina.Decorator[ __.U ]:
394 ''' Produces decorator to inject '__setattr__' method into class. '''
395 def decorate( cls: type[ __.U ] ) -> type[ __.U ]:
396 leveli = 'class' if level == 'classes' else level
397 original = cls.__dict__.get( '__setattr__' )
398 core = _behaviors.access_core_function(
399 cls,
400 attributes_namer = attributes_namer,
401 arguments = { f"{level}_assigner": implementation_core },
402 level = level, name = 'assigner',
403 default = _behaviors.assign_attribute_if_mutable )
405 if original is None:
407 def assign_with_super(
408 self: object, name: str, value: __.typx.Any
409 ) -> None:
410 ligation = super( cls, self ).__setattr__
411 # Only enforce behaviors at start of MRO.
412 if cls is not type( self ):
413 ligation( name, value )
414 return
415 core(
416 self,
417 ligation = ligation,
418 attributes_namer = attributes_namer,
419 error_class_provider = error_class_provider,
420 level = leveli,
421 name = name, value = value )
423 cls.__setattr__ = assign_with_super
425 else:
427 @__.funct.wraps( original )
428 def assign_with_original(
429 self: object, name: str, value: __.typx.Any
430 ) -> None:
431 ligation = __.funct.partial( original, self )
432 # Only enforce behaviors at start of MRO.
433 if cls is not type( self ):
434 ligation( name, value )
435 return
436 core(
437 self,
438 ligation = ligation,
439 attributes_namer = attributes_namer,
440 error_class_provider = error_class_provider,
441 level = leveli,
442 name = name, value = value )
444 cls.__setattr__ = assign_with_original
446 return cls
448 return decorate
451def produce_attributes_deletion_decorator(
452 level: str,
453 attributes_namer: _nomina.AttributesNamer,
454 error_class_provider: _nomina.ErrorClassProvider,
455 implementation_core: __.typx.Optional[ _nomina.DeleterCore ],
456) -> _nomina.Decorator[ __.U ]:
457 ''' Produces decorator to inject '__delattr__' method into class. '''
458 def decorate( cls: type[ __.U ] ) -> type[ __.U ]:
459 leveli = 'class' if level == 'classes' else level
460 original = cls.__dict__.get( '__delattr__' )
461 core = _behaviors.access_core_function(
462 cls,
463 attributes_namer = attributes_namer,
464 arguments = { f"{level}_deleter": implementation_core },
465 level = level, name = 'deleter',
466 default = _behaviors.delete_attribute_if_mutable )
468 if original is None:
470 def delete_with_super( self: object, name: str ) -> None:
471 ligation = super( cls, self ).__delattr__
472 # Only enforce behaviors at start of MRO.
473 if cls is not type( self ):
474 ligation( name )
475 return
476 core(
477 self,
478 ligation = ligation,
479 attributes_namer = attributes_namer,
480 error_class_provider = error_class_provider,
481 level = leveli,
482 name = name )
484 cls.__delattr__ = delete_with_super
486 else:
488 @__.funct.wraps( original )
489 def delete_with_original( self: object, name: str ) -> None:
490 ligation = __.funct.partial( original, self )
491 # Only enforce behaviors at start of MRO.
492 if cls is not type( self ):
493 ligation( name )
494 return
495 core(
496 self,
497 ligation = ligation,
498 attributes_namer = attributes_namer,
499 error_class_provider = error_class_provider,
500 level = leveli,
501 name = name )
503 cls.__delattr__ = delete_with_original
505 return cls
507 return decorate
510def produce_attributes_surveillance_decorator(
511 level: str,
512 attributes_namer: _nomina.AttributesNamer,
513 implementation_core: __.typx.Optional[ _nomina.SurveyorCore ],
514) -> _nomina.Decorator[ __.U ]:
515 ''' Produces decorator to inject '__dir__' method into class. '''
516 def decorate( cls: type[ __.U ] ) -> type[ __.U ]:
517 leveli = 'class' if level == 'classes' else level
518 original = cls.__dict__.get( '__dir__' )
519 core = _behaviors.access_core_function(
520 cls,
521 attributes_namer = attributes_namer,
522 arguments = { f"{level}_surveyor": implementation_core },
523 level = level, name = 'surveyor',
524 default = _behaviors.survey_visible_attributes )
526 if original is None:
528 def survey_with_super(
529 self: object
530 ) -> __.cabc.Iterable[ str ]:
531 ligation = super( cls, self ).__dir__
532 # Only enforce behaviors at start of MRO.
533 if cls is not type( self ): return ligation( )
534 return core(
535 self,
536 ligation = ligation,
537 attributes_namer = attributes_namer,
538 level = leveli )
540 cls.__dir__ = survey_with_super
542 else:
544 @__.funct.wraps( original )
545 def survey_with_original(
546 self: object
547 ) -> __.cabc.Iterable[ str ]:
548 ligation = __.funct.partial( original, self )
549 # Only enforce behaviors at start of MRO.
550 if cls is not type( self ): return ligation( )
551 return core(
552 self,
553 ligation = ligation,
554 attributes_namer = attributes_namer,
555 level = leveli )
557 cls.__dir__ = survey_with_original
559 return cls
561 return decorate
564@__.typx.dataclass_transform( frozen_default = True, kw_only_default = True )
565def dataclass_with_standard_behaviors( # noqa: PLR0913, PLR0917
566 attributes_namer: _nomina.AttributesNamer = __.calculate_attrname,
567 error_class_provider: _nomina.ErrorClassProvider = __.provide_error_class,
568 decorators: _nomina.Decorators[ __.U ] = ( ),
569 assigner_core: __.typx.Optional[ _nomina.AssignerCore ] = None,
570 deleter_core: __.typx.Optional[ _nomina.DeleterCore ] = None,
571 surveyor_core: __.typx.Optional[ _nomina.SurveyorCore ] = None,
572 ignore_init_arguments: bool = False,
573 mutables: _nomina.BehaviorExclusionVerifiersOmni = __.mutables_default,
574 visibles: _nomina.BehaviorExclusionVerifiersOmni = __.visibles_default,
575) -> _nomina.Decorator[ __.U ]:
576 # https://github.com/microsoft/pyright/discussions/10344
577 ''' Dataclass decorator factory. '''
578 decorators_: _nomina.Decorators[ __.U ] = (
579 _produce_instances_decorators(
580 attributes_namer = attributes_namer,
581 error_class_provider = error_class_provider,
582 assigner_core = assigner_core,
583 deleter_core = deleter_core,
584 surveyor_core = surveyor_core,
585 ignore_init_arguments = ignore_init_arguments,
586 mutables = mutables,
587 visibles = visibles ) )
588 preparers: _nomina.DecorationPreparers[ __.U ] = (
589 _produce_instances_decoration_preparers(
590 attributes_namer = attributes_namer,
591 error_class_provider = error_class_provider,
592 class_preparer = prepare_dataclass_for_instances ) )
593 return decoration_by(
594 *decorators, _dataclass_core, *decorators_, preparers = preparers )
597def with_standard_behaviors( # noqa: PLR0913, PLR0917
598 attributes_namer: _nomina.AttributesNamer = __.calculate_attrname,
599 error_class_provider: _nomina.ErrorClassProvider = __.provide_error_class,
600 decorators: _nomina.Decorators[ __.U ] = ( ),
601 assigner_core: __.typx.Optional[ _nomina.AssignerCore ] = None,
602 deleter_core: __.typx.Optional[ _nomina.DeleterCore ] = None,
603 surveyor_core: __.typx.Optional[ _nomina.SurveyorCore ] = None,
604 ignore_init_arguments: bool = False,
605 mutables: _nomina.BehaviorExclusionVerifiersOmni = __.mutables_default,
606 visibles: _nomina.BehaviorExclusionVerifiersOmni = __.visibles_default,
607) -> _nomina.Decorator[ __.U ]:
608 ''' Class decorator factory. '''
609 decorators_: _nomina.Decorators[ __.U ] = (
610 _produce_instances_decorators(
611 attributes_namer = attributes_namer,
612 error_class_provider = error_class_provider,
613 assigner_core = assigner_core,
614 deleter_core = deleter_core,
615 surveyor_core = surveyor_core,
616 ignore_init_arguments = ignore_init_arguments,
617 mutables = mutables,
618 visibles = visibles ) )
619 preparers: _nomina.DecorationPreparers[ __.U ] = (
620 _produce_instances_decoration_preparers(
621 attributes_namer = attributes_namer,
622 error_class_provider = error_class_provider ) )
623 return decoration_by( *decorators, *decorators_, preparers = preparers )
626def _activate_instance_behaviors(
627 cls: type[ __.U ],
628 self: object,
629 behaviors_name: str,
630 behaviors: __.cabc.MutableSet[ str ],
631) -> None:
632 # Only record behaviors at start of MRO.
633 if cls is not type( self ): return
634 behaviors_: set[ str ] = (
635 _utilities.getattr0( self, behaviors_name, set( ) ) )
636 behaviors_.update( behaviors )
637 _utilities.setattr0( self, behaviors_name, frozenset( behaviors_ ) )
640def _produce_instances_decoration_preparers(
641 attributes_namer: _nomina.AttributesNamer,
642 error_class_provider: _nomina.ErrorClassProvider,
643 class_preparer: __.typx.Optional[ _nomina.ClassPreparer ] = None,
644) -> _nomina.DecorationPreparers[ __.U ]:
645 ''' Produces processors for standard decorators. '''
646 preprocessors: list[ _nomina.DecorationPreparer[ __.U ] ] = [ ]
647 if class_preparer is not None:
648 preprocessors.append(
649 __.funct.partial(
650 class_preparer, attributes_namer = attributes_namer ) )
651 return tuple( preprocessors )
654def _produce_instances_decorators( # noqa: PLR0913, PLR0917
655 attributes_namer: _nomina.AttributesNamer,
656 error_class_provider: _nomina.ErrorClassProvider,
657 assigner_core: __.typx.Optional[ _nomina.AssignerCore ],
658 deleter_core: __.typx.Optional[ _nomina.DeleterCore ],
659 surveyor_core: __.typx.Optional[ _nomina.SurveyorCore ],
660 ignore_init_arguments: bool,
661 mutables: _nomina.BehaviorExclusionVerifiersOmni,
662 visibles: _nomina.BehaviorExclusionVerifiersOmni,
663) -> _nomina.Decorators[ __.U ]:
664 ''' Produces standard decorators. '''
665 decorators: list[ _nomina.Decorator[ __.U ] ] = [ ]
666 decorators.append(
667 produce_instances_inception_decorator(
668 attributes_namer = attributes_namer,
669 assigner_core = assigner_core,
670 deleter_core = deleter_core,
671 surveyor_core = surveyor_core,
672 ignore_init_arguments = ignore_init_arguments,
673 mutables = mutables, visibles = visibles ) )
674 decorators.append(
675 produce_attributes_assignment_decorator(
676 level = 'instances',
677 attributes_namer = attributes_namer,
678 error_class_provider = error_class_provider,
679 implementation_core = assigner_core ) )
680 decorators.append(
681 produce_attributes_deletion_decorator(
682 level = 'instances',
683 attributes_namer = attributes_namer,
684 error_class_provider = error_class_provider,
685 implementation_core = deleter_core ) )
686 decorators.append(
687 produce_attributes_surveillance_decorator(
688 level = 'instances',
689 attributes_namer = attributes_namer,
690 implementation_core = surveyor_core ) )
691 return decorators