@@ -68,14 +68,15 @@ def __call__( # noqa: C901, WPS210
6868 return value
6969
7070 try :
71- return pydantic .parse_obj_as (definition , value )
71+ return pydantic .TypeAdapter (definition ). validate_python ( value )
7272 except pydantic .ValidationError as err :
73- errors = err .errors ()
73+ errors = err .errors (include_url = False )
7474 for error in errors :
7575 error ["loc" ] = (
7676 "header" ,
7777 header_name ,
7878 ) + error ["loc" ]
79+ error .pop ("input" , None ) # type: ignore
7980 raise web .HTTPBadRequest (
8081 headers = {"Content-Type" : "application/json" },
8182 text = json .dumps (errors ),
@@ -120,11 +121,12 @@ async def __call__( # noqa: C901
120121 return body
121122
122123 try :
123- return pydantic .parse_obj_as (definition , body )
124+ return pydantic .TypeAdapter (definition ). validate_python ( body )
124125 except pydantic .ValidationError as err :
125- errors = err .errors ()
126+ errors = err .errors (include_url = False )
126127 for error in errors :
127128 error ["loc" ] = ("body" ,) + error ["loc" ]
129+ error .pop ("input" , None ) # type: ignore
128130 raise web .HTTPBadRequest (
129131 headers = {"Content-Type" : "application/json" },
130132 text = json .dumps (errors ),
@@ -192,14 +194,15 @@ def __call__( # noqa: C901, WPS210
192194 return value
193195
194196 try :
195- return pydantic .parse_obj_as (definition , value )
197+ return pydantic .TypeAdapter (definition ). validate_python ( value )
196198 except pydantic .ValidationError as err :
197- errors = err .errors ()
199+ errors = err .errors (include_url = False )
198200 for error in errors :
199201 error ["loc" ] = (
200202 "query" ,
201203 param_name ,
202204 ) + error ["loc" ]
205+ error .pop ("input" , None ) # type: ignore
203206 raise web .HTTPBadRequest (
204207 headers = {"Content-Type" : "application/json" },
205208 text = json .dumps (errors ),
@@ -242,10 +245,11 @@ async def __call__(
242245 return form_data
243246
244247 try :
245- return pydantic .parse_obj_as (definition , form_data )
248+ return pydantic .TypeAdapter (definition ). validate_python ( form_data )
246249 except pydantic .ValidationError as err :
247- errors = err .errors ()
250+ errors = err .errors (include_url = False )
248251 for error in errors :
252+ error .pop ("input" , None ) # type: ignore
249253 error ["loc" ] = ("form" ,) + error ["loc" ]
250254 raise web .HTTPBadRequest (
251255 headers = {"Content-Type" : "application/json" },
@@ -299,10 +303,11 @@ def __call__(
299303 return matched_data
300304
301305 try :
302- return pydantic .parse_obj_as (definition , matched_data )
306+ return pydantic .TypeAdapter (definition ). validate_python ( matched_data )
303307 except pydantic .ValidationError as err :
304- errors = err .errors ()
308+ errors = err .errors (include_url = False )
305309 for error in errors :
310+ error .pop ("input" , None ) # type: ignore
306311 error ["loc" ] = ("path" ,) + error ["loc" ]
307312 raise web .HTTPBadRequest (
308313 headers = {"Content-Type" : "application/json" },
0 commit comments