22
33from  dataclasses  import  dataclass 
44from  pathlib  import  Path 
5+ from  typing  import  Any 
56from  typing  import  Iterable 
67from  typing  import  Optional 
78from  typing  import  Protocol 
@@ -271,7 +272,7 @@ def limit_leaks(
271272class  _TrackedObjectsInfo :
272273    """Type that holds information about objects that survived tracking.""" 
273274
274-     surviving_objects : list 
275+     surviving_objects : list [ Any ] 
275276    num_stacks : int 
276277    native_stacks : bool 
277278
@@ -330,7 +331,7 @@ def track_leaked_objects(
330331    _result_file : Path ,
331332    _config : Config ,
332333    _test_id : str ,
333-     _surviving_objects : list  |  None  =  None ,
334+     _surviving_objects : list [ Any ]  |  None  =  None ,
334335) ->  _TrackedObjectsInfo  |  None :
335336    """Track objects that survive the test execution.""" 
336337    if  _surviving_objects  is  None :
@@ -364,17 +365,17 @@ def track_leaked_objects(
364365class  GetLeakedObjectsFunction (Protocol ):
365366    """A callable that retrieves the leaked objects from a test.""" 
366367
367-     def  __call__ (self ) ->  list :
368+     def  __call__ (self ) ->  list [ Any ] :
368369        """Return the list of objects that leaked during the test.""" 
369370        ...
370371
371372
372373def  get_leaked_objects (
373374    callback : GetLeakedObjectsFunction  |  None  =  None ,
374-     _result_file : Path  =  None ,
375-     _config : Config  =  None ,
376-     _test_id : str  =  None ,
377-     _surviving_objects : list  |  None  =  None ,
375+     _result_file : Optional [ Path ]  =  None ,
376+     _config : Optional [ Config ]  =  None ,
377+     _test_id : Optional [ str ]  =  None ,
378+     _surviving_objects : list [ Any ]  |  None  =  None ,
378379) ->  None :
379380    """Decorator to allow tests to retrieve leaked objects programmatically. 
380381
@@ -395,7 +396,7 @@ def test_inspect_leaks(get_leaked_objects):
395396    """ 
396397    if  callback  and  _surviving_objects  is  not None :
397398        # Inject the function into the test 
398-         callback ._leaked_objects  =  _surviving_objects 
399+         callback ._leaked_objects  =  _surviving_objects    # type: ignore[attr-defined] 
399400
400401
401402__all__  =  [
0 commit comments