Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/attr/exceptions.py: 79%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

19 statements  

1# SPDX-License-Identifier: MIT 

2 

3from __future__ import annotations 

4 

5from typing import ClassVar 

6 

7 

8class FrozenError(AttributeError): 

9 """ 

10 A frozen/immutable instance or attribute have been attempted to be 

11 modified. 

12 

13 It mirrors the behavior of ``namedtuples`` by using the same error message 

14 and subclassing `AttributeError`. 

15 

16 .. versionadded:: 20.1.0 

17 """ 

18 

19 msg = "can't set attribute" 

20 args: ClassVar[tuple[str]] = [msg] 

21 

22 

23class FrozenInstanceError(FrozenError): 

24 """ 

25 A frozen instance has been attempted to be modified. 

26 

27 .. versionadded:: 16.1.0 

28 """ 

29 

30 

31class FrozenAttributeError(FrozenError): 

32 """ 

33 A frozen attribute has been attempted to be modified. 

34 

35 .. versionadded:: 20.1.0 

36 """ 

37 

38 

39class AttrsAttributeNotFoundError(ValueError): 

40 """ 

41 An *attrs* function couldn't find an attribute that the user asked for. 

42 

43 .. versionadded:: 16.2.0 

44 """ 

45 

46 

47class NotAnAttrsClassError(ValueError): 

48 """ 

49 A non-*attrs* class has been passed into an *attrs* function. 

50 

51 .. versionadded:: 16.2.0 

52 """ 

53 

54 

55class DefaultAlreadySetError(RuntimeError): 

56 """ 

57 A default has been set when defining the field and is attempted to be reset 

58 using the decorator. 

59 

60 .. versionadded:: 17.1.0 

61 """ 

62 

63 

64class UnannotatedAttributeError(RuntimeError): 

65 """ 

66 A class with ``auto_attribs=True`` has a field without a type annotation. 

67 

68 .. versionadded:: 17.3.0 

69 """ 

70 

71 

72class PythonTooOldError(RuntimeError): 

73 """ 

74 It was attempted to use an *attrs* feature that requires a newer Python 

75 version. 

76 

77 .. versionadded:: 18.2.0 

78 """ 

79 

80 

81class NotCallableError(TypeError): 

82 """ 

83 A field requiring a callable has been set with a value that is not 

84 callable. 

85 

86 .. versionadded:: 19.2.0 

87 """ 

88 

89 def __init__(self, msg, value): 

90 super(TypeError, self).__init__(msg, value) 

91 self.msg = msg 

92 self.value = value 

93 

94 def __str__(self): 

95 return str(self.msg)