1from __future__ import absolute_import, division, print_function 2 3 4class FrozenError(AttributeError): 5 """ 6 A frozen/immutable instance or attribute haave been attempted to be 7 modified. 8 9 It mirrors the behavior of ``namedtuples`` by using the same error message 10 and subclassing `AttributeError`. 11 12 .. versionadded:: 20.1.0 13 """ 14 15 msg = "can't set attribute" 16 args = [msg] 17 18 19class FrozenInstanceError(FrozenError): 20 """ 21 A frozen instance has been attempted to be modified. 22 23 .. versionadded:: 16.1.0 24 """ 25 26 27class FrozenAttributeError(FrozenError): 28 """ 29 A frozen attribute has been attempted to be modified. 30 31 .. versionadded:: 20.1.0 32 """ 33 34 35class AttrsAttributeNotFoundError(ValueError): 36 """ 37 An ``attrs`` function couldn't find an attribute that the user asked for. 38 39 .. versionadded:: 16.2.0 40 """ 41 42 43class NotAnAttrsClassError(ValueError): 44 """ 45 A non-``attrs`` class has been passed into an ``attrs`` function. 46 47 .. versionadded:: 16.2.0 48 """ 49 50 51class DefaultAlreadySetError(RuntimeError): 52 """ 53 A default has been set using ``attr.ib()`` and is attempted to be reset 54 using the decorator. 55 56 .. versionadded:: 17.1.0 57 """ 58 59 60class UnannotatedAttributeError(RuntimeError): 61 """ 62 A class with ``auto_attribs=True`` has an ``attr.ib()`` without a type 63 annotation. 64 65 .. versionadded:: 17.3.0 66 """ 67 68 69class PythonTooOldError(RuntimeError): 70 """ 71 It was attempted to use an ``attrs`` feature that requires a newer Python 72 version. 73 74 .. versionadded:: 18.2.0 75 """ 76 77 78class NotCallableError(TypeError): 79 """ 80 A ``attr.ib()`` requiring a callable has been set with a value 81 that is not callable. 82 83 .. versionadded:: 19.2.0 84 """ 85 86 def __init__(self, msg, value): 87 super(TypeError, self).__init__(msg, value) 88 self.msg = msg 89 self.value = value 90 91 def __str__(self): 92 return str(self.msg) 93