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
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
1# SPDX-License-Identifier: MIT
3from __future__ import annotations
5from typing import ClassVar
8class FrozenError(AttributeError):
9 """
10 A frozen/immutable instance or attribute have been attempted to be
11 modified.
13 It mirrors the behavior of ``namedtuples`` by using the same error message
14 and subclassing `AttributeError`.
16 .. versionadded:: 20.1.0
17 """
19 msg = "can't set attribute"
20 args: ClassVar[tuple[str]] = [msg]
23class FrozenInstanceError(FrozenError):
24 """
25 A frozen instance has been attempted to be modified.
27 .. versionadded:: 16.1.0
28 """
31class FrozenAttributeError(FrozenError):
32 """
33 A frozen attribute has been attempted to be modified.
35 .. versionadded:: 20.1.0
36 """
39class AttrsAttributeNotFoundError(ValueError):
40 """
41 An *attrs* function couldn't find an attribute that the user asked for.
43 .. versionadded:: 16.2.0
44 """
47class NotAnAttrsClassError(ValueError):
48 """
49 A non-*attrs* class has been passed into an *attrs* function.
51 .. versionadded:: 16.2.0
52 """
55class DefaultAlreadySetError(RuntimeError):
56 """
57 A default has been set when defining the field and is attempted to be reset
58 using the decorator.
60 .. versionadded:: 17.1.0
61 """
64class UnannotatedAttributeError(RuntimeError):
65 """
66 A class with ``auto_attribs=True`` has a field without a type annotation.
68 .. versionadded:: 17.3.0
69 """
72class PythonTooOldError(RuntimeError):
73 """
74 It was attempted to use an *attrs* feature that requires a newer Python
75 version.
77 .. versionadded:: 18.2.0
78 """
81class NotCallableError(TypeError):
82 """
83 A field requiring a callable has been set with a value that is not
84 callable.
86 .. versionadded:: 19.2.0
87 """
89 def __init__(self, msg, value):
90 super(TypeError, self).__init__(msg, value)
91 self.msg = msg
92 self.value = value
94 def __str__(self):
95 return str(self.msg)