@@ -70,7 +70,7 @@ def __init__(
70
70
for error in context :
71
71
error .parent = self
72
72
73
- def __repr__ (self ):
73
+ def __repr__ (self ) -> str :
74
74
return f"<{ self .__class__ .__name__ } : { self .message !r} >"
75
75
76
76
def __str__ (self ) -> str :
@@ -107,11 +107,11 @@ def __str__(self) -> str:
107
107
)
108
108
109
109
@classmethod
110
- def create_from (cls , other ):
110
+ def create_from (cls , other : _Error ):
111
111
return cls (** other ._contents ())
112
112
113
113
@property
114
- def absolute_path (self ):
114
+ def absolute_path (self ) -> deque [ str | int ] :
115
115
parent = self .parent
116
116
if parent is None :
117
117
return self .relative_path
@@ -121,7 +121,7 @@ def absolute_path(self):
121
121
return path
122
122
123
123
@property
124
- def absolute_schema_path (self ):
124
+ def absolute_schema_path (self ) -> deque [ str | int ] :
125
125
parent = self .parent
126
126
if parent is None :
127
127
return self .relative_schema_path
@@ -131,7 +131,7 @@ def absolute_schema_path(self):
131
131
return path
132
132
133
133
@property
134
- def json_path (self ):
134
+ def json_path (self ) -> str :
135
135
path = "$"
136
136
for elem in self .absolute_path :
137
137
if isinstance (elem , int ):
@@ -140,7 +140,11 @@ def json_path(self):
140
140
path += "." + elem
141
141
return path
142
142
143
- def _set (self , type_checker = None , ** kwargs ):
143
+ def _set (
144
+ self ,
145
+ type_checker : _types .TypeChecker | None = None ,
146
+ ** kwargs : Any ,
147
+ ) -> None :
144
148
if type_checker is not None and self ._type_checker is _unset :
145
149
self ._type_checker = type_checker
146
150
@@ -202,7 +206,7 @@ class RefResolutionError(Exception):
202
206
203
207
_cause = attr .ib ()
204
208
205
- def __str__ (self ):
209
+ def __str__ (self ) -> str :
206
210
return str (self ._cause )
207
211
208
212
@@ -211,10 +215,10 @@ class UndefinedTypeCheck(Exception):
211
215
A type checker was asked to check a type it did not have registered.
212
216
"""
213
217
214
- def __init__ (self , type ) :
218
+ def __init__ (self , type : str ) -> None :
215
219
self .type = type
216
220
217
- def __str__ (self ):
221
+ def __str__ (self ) -> str :
218
222
return f"Type { self .type !r} is unknown to this type checker"
219
223
220
224
0 commit comments