def _get_caller_vars()

in testslide/lib.py [0:0]


def _get_caller_vars() -> Tuple[Dict[str, Any], Dict[str, Any]]:
    """
    Retrieves the globals and locals of the first frame that is not from TestSlide code.
    """

    def _should_skip_frame(frame: FrameType) -> bool:
        is_testslide = (
            os.path.dirname(__file__) in frame.f_code.co_filename
            # we need not to skip tests
            and "/tests/" not in frame.f_code.co_filename
        )
        is_typeguard = os.path.dirname(typeguard.__file__) in frame.f_code.co_filename

        return is_testslide or is_typeguard

    next_stack_count = 1
    next_frame = sys._getframe(next_stack_count)
    while _should_skip_frame(next_frame):
        next_stack_count += 1
        next_frame = sys._getframe(next_stack_count)

    return (next_frame.f_globals, next_frame.f_locals)