Coverage for sources/accretive/objects.py: 100%

19 statements  

« prev     ^ index     » next       coverage.py v7.6.4, created at 2024-11-10 23:02 +0000

1# vim: set filetype=python fileencoding=utf-8: 

2# -*- coding: utf-8 -*- 

3 

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#============================================================================# 

19 

20 

21''' Accretive objects. ''' 

22 

23 

24from . import __ 

25from . import classes as _classes 

26 

27 

28class _Dictionary( # type: ignore 

29 __.CoreDictionary, metaclass = _classes.Class 

30): pass 

31 

32 

33class Object: 

34 ''' Accretive objects. ''' 

35 

36 __slots__ = ( '__dict__', ) 

37 

38 def __init__( self, *posargs: __.a.Any, **nomargs: __.a.Any ) -> None: 

39 super( ).__setattr__( '__dict__', _Dictionary( ) ) 

40 # Pass all arguments down MRO chain without consuming any. 

41 super( ).__init__( *posargs, **nomargs ) 

42 

43 def __repr__( self ) -> str: 

44 return "{fqname}( )".format( fqname = __.calculate_fqname( self ) ) 

45 

46 def __delattr__( self, name: str ) -> None: 

47 from .exceptions import IndelibleAttributeError 

48 raise IndelibleAttributeError( name ) 

49 

50 def __setattr__( self, name: str, value: __.a.Any ) -> None: 

51 if hasattr( self, name ): 

52 from .exceptions import IndelibleAttributeError 

53 raise IndelibleAttributeError( name ) 

54 super( ).__setattr__( name, value ) 

55 

56Object.__doc__ = __.generate_docstring( 

57 Object, 'instance attributes accretion' )