11import fnmatch
22import inspect
33from collections .abc import Iterable , Mapping
4- from typing import Protocol , TypeVar , cast , overload
4+ from typing import Protocol , TypeVar , overload
55
66import attrs
77import cattrs
@@ -117,7 +117,7 @@ def narrow(self, *patterns: str, obj: Mapping | object = Empty) -> dict[str, obj
117117 pattern = pattern [1 :]
118118 for n in self .keys_from (obj ):
119119 if progress .obj_is_mapping :
120- v = cast ( Mapping , obj )[ n ]
120+ v = obj [ n ] # type: ignore[index ]
121121 else :
122122 v = getattr (obj , n )
123123
@@ -202,7 +202,7 @@ def find_by_type(
202202 if data is Empty :
203203 data = self .data
204204
205- data = cast ( dict [str , object ], data )
205+ data : dict [str , object ] = data # type: ignore[assignment]
206206
207207 if typ is object :
208208 return False , data
@@ -288,15 +288,15 @@ def retrieve_one(
288288 if with_patterns or typ is object :
289289 data = with_patterns
290290 elif default is not inspect ._empty :
291- return cast ( T , default )
291+ return default # type: ignore[return-value]
292292
293293 optional , found = self .find_by_type (typ , data = data , type_cache = type_cache )
294294
295295 if patterns and data and not found and not optional :
296296 raise errors .FoundWithWrongType (patterns = list (patterns ), want = typ )
297297
298298 if optional and not found :
299- return cast ( T , None )
299+ return None # type: ignore[return-value]
300300
301301 if len (found ) == 1 :
302302 for thing in found .values ():
@@ -306,7 +306,7 @@ def retrieve_one(
306306 raise errors .MultipleNamesForType (want = typ , found = sorted (found ))
307307
308308 if default is not inspect ._empty :
309- return cast ( T , default )
309+ return default # type: ignore[return-value]
310310
311311 raise errors .NoDataByTypeName (
312312 want = typ ,
0 commit comments