Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/attr/exceptions.py: 76%
17 statements
« prev ^ index » next coverage.py v7.3.2, created at 2023-12-08 06:51 +0000
« prev ^ index » next coverage.py v7.3.2, created at 2023-12-08 06:51 +0000
1# SPDX-License-Identifier: MIT
4class FrozenError(AttributeError):
5 """
6 A frozen/immutable instance or attribute have been attempted to be
7 modified.
9 It mirrors the behavior of ``namedtuples`` by using the same error message
10 and subclassing `AttributeError`.
12 .. versionadded:: 20.1.0
13 """
15 msg = "can't set attribute"
16 args = [msg]
19class FrozenInstanceError(FrozenError):
20 """
21 A frozen instance has been attempted to be modified.
23 .. versionadded:: 16.1.0
24 """
27class FrozenAttributeError(FrozenError):
28 """
29 A frozen attribute has been attempted to be modified.
31 .. versionadded:: 20.1.0
32 """
35class AttrsAttributeNotFoundError(ValueError):
36 """
37 An *attrs* function couldn't find an attribute that the user asked for.
39 .. versionadded:: 16.2.0
40 """
43class NotAnAttrsClassError(ValueError):
44 """
45 A non-*attrs* class has been passed into an *attrs* function.
47 .. versionadded:: 16.2.0
48 """
51class DefaultAlreadySetError(RuntimeError):
52 """
53 A default has been set when defining the field and is attempted to be reset
54 using the decorator.
56 .. versionadded:: 17.1.0
57 """
60class UnannotatedAttributeError(RuntimeError):
61 """
62 A class with ``auto_attribs=True`` has a field without a type annotation.
64 .. versionadded:: 17.3.0
65 """
68class PythonTooOldError(RuntimeError):
69 """
70 It was attempted to use an *attrs* feature that requires a newer Python
71 version.
73 .. versionadded:: 18.2.0
74 """
77class NotCallableError(TypeError):
78 """
79 A field requiring a callable has been set with a value that is not
80 callable.
82 .. versionadded:: 19.2.0
83 """
85 def __init__(self, msg, value):
86 super(TypeError, self).__init__(msg, value)
87 self.msg = msg
88 self.value = value
90 def __str__(self):
91 return str(self.msg)