3636is_iterator = lib .is_iterator
3737
3838
39- def is_number (obj ) -> TypeGuard [Number | np .number ]:
39+ def is_number (obj : object ) -> TypeGuard [Number | np .number ]:
4040 """
4141 Check if the object is a number.
4242
@@ -77,7 +77,7 @@ def is_number(obj) -> TypeGuard[Number | np.number]:
7777 return isinstance (obj , (Number , np .number ))
7878
7979
80- def iterable_not_string (obj ) -> bool :
80+ def iterable_not_string (obj : object ) -> bool :
8181 """
8282 Check if the object is an iterable but not a string.
8383
@@ -102,7 +102,7 @@ def iterable_not_string(obj) -> bool:
102102 return isinstance (obj , abc .Iterable ) and not isinstance (obj , str )
103103
104104
105- def is_file_like (obj ) -> bool :
105+ def is_file_like (obj : object ) -> bool :
106106 """
107107 Check if the object is a file-like object.
108108
@@ -138,7 +138,7 @@ def is_file_like(obj) -> bool:
138138 return bool (hasattr (obj , "__iter__" ))
139139
140140
141- def is_re (obj ) -> TypeGuard [Pattern ]:
141+ def is_re (obj : object ) -> TypeGuard [Pattern ]:
142142 """
143143 Check if the object is a regex pattern instance.
144144
@@ -163,7 +163,7 @@ def is_re(obj) -> TypeGuard[Pattern]:
163163 return isinstance (obj , Pattern )
164164
165165
166- def is_re_compilable (obj ) -> bool :
166+ def is_re_compilable (obj : object ) -> bool :
167167 """
168168 Check if the object can be compiled into a regex pattern instance.
169169
@@ -185,14 +185,14 @@ def is_re_compilable(obj) -> bool:
185185 False
186186 """
187187 try :
188- re .compile (obj )
188+ re .compile (obj ) # type: ignore[call-overload]
189189 except TypeError :
190190 return False
191191 else :
192192 return True
193193
194194
195- def is_array_like (obj ) -> bool :
195+ def is_array_like (obj : object ) -> bool :
196196 """
197197 Check if the object is array-like.
198198
@@ -224,7 +224,7 @@ def is_array_like(obj) -> bool:
224224 return is_list_like (obj ) and hasattr (obj , "dtype" )
225225
226226
227- def is_nested_list_like (obj ) -> bool :
227+ def is_nested_list_like (obj : object ) -> bool :
228228 """
229229 Check if the object is list-like, and that all of its elements
230230 are also list-like.
@@ -265,12 +265,13 @@ def is_nested_list_like(obj) -> bool:
265265 return (
266266 is_list_like (obj )
267267 and hasattr (obj , "__len__" )
268- and len (obj ) > 0
269- and all (is_list_like (item ) for item in obj )
268+ # need PEP 724 to handle these typing errors
269+ and len (obj ) > 0 # pyright: ignore[reportGeneralTypeIssues]
270+ and all (is_list_like (item ) for item in obj ) # type: ignore[attr-defined]
270271 )
271272
272273
273- def is_dict_like (obj ) -> bool :
274+ def is_dict_like (obj : object ) -> bool :
274275 """
275276 Check if the object is dict-like.
276277
@@ -303,7 +304,7 @@ def is_dict_like(obj) -> bool:
303304 )
304305
305306
306- def is_named_tuple (obj ) -> bool :
307+ def is_named_tuple (obj : object ) -> bool :
307308 """
308309 Check if the object is a named tuple.
309310
@@ -331,7 +332,7 @@ def is_named_tuple(obj) -> bool:
331332 return isinstance (obj , abc .Sequence ) and hasattr (obj , "_fields" )
332333
333334
334- def is_hashable (obj ) -> TypeGuard [Hashable ]:
335+ def is_hashable (obj : object ) -> TypeGuard [Hashable ]:
335336 """
336337 Return True if hash(obj) will succeed, False otherwise.
337338
@@ -370,7 +371,7 @@ def is_hashable(obj) -> TypeGuard[Hashable]:
370371 return True
371372
372373
373- def is_sequence (obj ) -> bool :
374+ def is_sequence (obj : object ) -> bool :
374375 """
375376 Check if the object is a sequence of objects.
376377 String types are not included as sequences here.
@@ -394,14 +395,16 @@ def is_sequence(obj) -> bool:
394395 False
395396 """
396397 try :
397- iter (obj ) # Can iterate over it.
398- len (obj ) # Has a length associated with it.
398+ # Can iterate over it.
399+ iter (obj ) # type: ignore[call-overload]
400+ # Has a length associated with it.
401+ len (obj ) # type: ignore[arg-type]
399402 return not isinstance (obj , (str , bytes ))
400403 except (TypeError , AttributeError ):
401404 return False
402405
403406
404- def is_dataclass (item ) -> bool :
407+ def is_dataclass (item : object ) -> bool :
405408 """
406409 Checks if the object is a data-class instance
407410
0 commit comments