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

17 statements  

« prev     ^ index     » next       coverage.py v7.5.4, created at 2024-07-07 15:48 +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''' Family of exceptions for package API. ''' 

22 

23 

24from . import __ # pylint: disable=cyclic-import 

25from . import _annotations as _a 

26from . import classes as _classes # pylint: disable=cyclic-import 

27from . import objects as _objects # pylint: disable=cyclic-import 

28 

29 

30class _Class( __.ClassConcealerExtension, _classes.Class ): pass 

31 

32 

33class Omniexception( 

34 __.ConcealerExtension, _objects.Object, BaseException, 

35 metaclass = _Class, 

36): 

37 ''' Base for exceptions raised by package API. ''' 

38 

39 _attribute_visibility_includes_: _a.Collection[ str ] = ( 

40 frozenset( ( '__cause__', '__context__', ) ) ) 

41 

42 

43class IndelibleAttributeError( Omniexception, AttributeError, TypeError ): 

44 ''' Attempt to reassign or delete indelible attribute. ''' 

45 

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

47 super( ).__init__( 

48 f"Cannot reassign or delete existing attribute {name!r}." ) 

49 

50 

51class IndelibleEntryError( Omniexception, TypeError ): 

52 ''' Attempt to update or remove indelible dictionary entry. ''' 

53 

54 def __init__( self, indicator: _a.Any ) -> None: 

55 super( ).__init__( 

56 f"Cannot update or remove existing entry for {indicator!r}." ) 

57 

58 

59class InvalidOperationError( Omniexception, RuntimeError, TypeError ): 

60 ''' Attempt to perform invalid operation. ''' 

61 

62 def __init__( self, name: str ) -> None: 

63 super( ).__init__( f"Cannot perform operation {name!r}." ) 

64 

65 

66__all__ = __.discover_public_attributes( globals( ) )