Coverage for sources/accretive/modules.py: 100%
16 statements
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-10 22:24 +0000
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-10 22:24 +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''' Accretive modules. '''
24from . import __
27class Module( __.Module ): # type: ignore[misc]
28 ''' Accretive modules. '''
30 def __delattr__( self, name: str ) -> None:
31 from .exceptions import IndelibleAttributeError
32 raise IndelibleAttributeError( name )
34 def __setattr__( self, name: str, value: __.a.Any ) -> None:
35 from .exceptions import IndelibleAttributeError
36 if hasattr( self, name ): raise IndelibleAttributeError( name )
37 super( ).__setattr__( name, value )
39Module.__doc__ = __.generate_docstring(
40 Module, 'description of module', 'module attributes accretion' )
43def reclassify_modules(
44 attributes: __.cabc.Mapping[ str, __.a.Any ],
45 to_class: type[ Module ] = Module
46) -> None:
47 ''' Reclassifies modules in dictionary with custom module type. '''
48 from inspect import ismodule
49 for attribute in attributes.values( ):
50 if not ismodule( attribute ): continue
51 if isinstance( attribute, to_class ): continue
52 attribute.__class__ = to_class