@@ -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,9 @@ 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 , type_checker : _types .TypeChecker | None = None , ** kwargs : Any
145
+ ) -> None :
144
146
if type_checker is not None and self ._type_checker is _unset :
145
147
self ._type_checker = type_checker
146
148
@@ -202,7 +204,7 @@ class RefResolutionError(Exception):
202
204
203
205
_cause = attr .ib ()
204
206
205
- def __str__ (self ):
207
+ def __str__ (self ) -> str :
206
208
return str (self ._cause )
207
209
208
210
@@ -211,10 +213,10 @@ class UndefinedTypeCheck(Exception):
211
213
A type checker was asked to check a type it did not have registered.
212
214
"""
213
215
214
- def __init__ (self , type ) :
216
+ def __init__ (self , type : str ) -> None :
215
217
self .type = type
216
218
217
- def __str__ (self ):
219
+ def __str__ (self ) -> str :
218
220
return f"Type { self .type !r} is unknown to this type checker"
219
221
220
222
0 commit comments