comparison mercurial/thirdparty/attr/exceptions.py @ 49643:e1c586b9a43c

attr: vendor 22.1.0 The previous version was 5 years old, and pytype 2022.06.30 started complaining about various uses (e.g. seeing `mercurial.thirdparty.attr._make._CountingAttr` instead of `bytearray`). Hopefully this helps. Additionally, this has official python 3.11 support. The `attrs` package is left out, because it is simply a bunch of *.pyi stubs and `from attr.X import *`, and that's not how they've been used up to this point. We'd probably need to customize those anyway to `from mercurial.thirdparty.attr import *`.
author Matt Harbison <matt_harbison@yahoo.com>
date Mon, 21 Nov 2022 15:04:42 -0500
parents 765eb17a7eb8
children
comparison
equal deleted inserted replaced
49642:7e6f3c69c0fb 49643:e1c586b9a43c
1 from __future__ import absolute_import, division, print_function 1 # SPDX-License-Identifier: MIT
2 2
3 3
4 class FrozenInstanceError(AttributeError): 4 class FrozenError(AttributeError):
5 """ 5 """
6 A frozen/immutable instance has been attempted to be modified. 6 A frozen/immutable instance or attribute have been attempted to be
7 modified.
7 8
8 It mirrors the behavior of ``namedtuples`` by using the same error message 9 It mirrors the behavior of ``namedtuples`` by using the same error message
9 and subclassing :exc:`AttributeError`. 10 and subclassing `AttributeError`.
11
12 .. versionadded:: 20.1.0
13 """
14
15 msg = "can't set attribute"
16 args = [msg]
17
18
19 class FrozenInstanceError(FrozenError):
20 """
21 A frozen instance has been attempted to be modified.
10 22
11 .. versionadded:: 16.1.0 23 .. versionadded:: 16.1.0
12 """ 24 """
13 msg = "can't set attribute" 25
14 args = [msg] 26
27 class FrozenAttributeError(FrozenError):
28 """
29 A frozen attribute has been attempted to be modified.
30
31 .. versionadded:: 20.1.0
32 """
15 33
16 34
17 class AttrsAttributeNotFoundError(ValueError): 35 class AttrsAttributeNotFoundError(ValueError):
18 """ 36 """
19 An ``attrs`` function couldn't find an attribute that the user asked for. 37 An ``attrs`` function couldn't find an attribute that the user asked for.
35 A default has been set using ``attr.ib()`` and is attempted to be reset 53 A default has been set using ``attr.ib()`` and is attempted to be reset
36 using the decorator. 54 using the decorator.
37 55
38 .. versionadded:: 17.1.0 56 .. versionadded:: 17.1.0
39 """ 57 """
58
59
60 class 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
69 class 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
78 class 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)