@@ -67,7 +67,7 @@ def __init__(
67
67
for error in context :
68
68
error .parent = self
69
69
70
- def __repr__ (self ):
70
+ def __repr__ (self ) -> str :
71
71
return f"<{ self .__class__ .__name__ } : { self .message !r} >"
72
72
73
73
def __str__ (self ) -> str :
@@ -104,11 +104,11 @@ def __str__(self) -> str:
104
104
)
105
105
106
106
@classmethod
107
- def create_from (cls , other ):
107
+ def create_from (cls , other : _Error ):
108
108
return cls (** other ._contents ())
109
109
110
110
@property
111
- def absolute_path (self ):
111
+ def absolute_path (self ) -> deque [ str ] :
112
112
parent = self .parent
113
113
if parent is None :
114
114
return self .relative_path
@@ -118,7 +118,7 @@ def absolute_path(self):
118
118
return path
119
119
120
120
@property
121
- def absolute_schema_path (self ):
121
+ def absolute_schema_path (self ) -> deque [ str ] :
122
122
parent = self .parent
123
123
if parent is None :
124
124
return self .relative_schema_path
@@ -128,7 +128,7 @@ def absolute_schema_path(self):
128
128
return path
129
129
130
130
@property
131
- def json_path (self ):
131
+ def json_path (self ) -> str :
132
132
path = "$"
133
133
for elem in self .absolute_path :
134
134
if isinstance (elem , int ):
@@ -137,7 +137,9 @@ def json_path(self):
137
137
path += "." + elem
138
138
return path
139
139
140
- def _set (self , type_checker = None , ** kwargs ):
140
+ def _set (
141
+ self , type_checker : _types .TypeChecker | None = None , ** kwargs : Any
142
+ ) -> None :
141
143
if type_checker is not None and self ._type_checker is _unset :
142
144
self ._type_checker = type_checker
143
145
@@ -199,7 +201,7 @@ class RefResolutionError(Exception):
199
201
200
202
_cause = attr .ib ()
201
203
202
- def __str__ (self ):
204
+ def __str__ (self ) -> str :
203
205
return str (self ._cause )
204
206
205
207
@@ -208,10 +210,10 @@ class UndefinedTypeCheck(Exception):
208
210
A type checker was asked to check a type it did not have registered.
209
211
"""
210
212
211
- def __init__ (self , type ) :
213
+ def __init__ (self , type : str ) -> None :
212
214
self .type = type
213
215
214
- def __str__ (self ):
216
+ def __str__ (self ) -> str :
215
217
return f"Type { self .type !r} is unknown to this type checker"
216
218
217
219
0 commit comments