@@ -449,14 +449,13 @@ def _unwrap_descriptor(dobj):
449449 return getattr (obj , '__get__' , obj )
450450
451451
452- def _unwrap_object (obj : T , * , stop : Optional [ Callable [[ T ], bool ]] = None ) -> T :
452+ def _unwrap_object (obj : T ) -> T :
453453 """
454454 This is a modified version of `inspect.unwrap()` that properly handles classes.
455455
456456 Follows the chains of `__wrapped__` attributes, until either:
457457 1. `obj.__wrapped__` is missing or None
458458 2. `obj` is a class and `obj.__wrapped__` has a different name or module
459- 3. `stop` is given and `stop(obj)` is True
460459 """
461460
462461 orig = obj # remember the original func for error reporting
@@ -465,9 +464,6 @@ def _unwrap_object(obj: T, *, stop: Optional[Callable[[T], bool]] = None) -> T:
465464 memo = {id (orig ): orig }
466465 recursion_limit = sys .getrecursionlimit ()
467466 while hasattr (obj , '__wrapped__' ):
468- if stop is not None and stop (obj ):
469- break
470-
471467 candidate = obj .__wrapped__
472468 if candidate is None :
473469 break
@@ -477,7 +473,7 @@ def _unwrap_object(obj: T, *, stop: Optional[Callable[[T], bool]] = None) -> T:
477473 and candidate .__module__ == orig .__module__ ):
478474 break
479475
480- obj = candidate
476+ obj = typing . cast ( T , candidate )
481477 id_func = id (obj )
482478 if (id_func in memo ) or (len (memo ) >= recursion_limit ):
483479 raise ValueError ('wrapper loop when unwrapping {!r}' .format (orig ))
0 commit comments