How to use snoop - 10 common examples

To help you get started, we’ve selected a few snoop examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alexmojaki / snoop / tests / samples / with_block_depth.py View on Github external
def main():
    str(3)
    with snoop.snoop(depth=3):
        result1 = f2(5)
    return result1
github alexmojaki / snoop / tests / samples / confusing_decorator_lines.py View on Github external
@snoop.snoop(
    depth=2)  # Multi-line decorator for extra confusion!
@empty_decorator
@empty_decorator
def main():
    str(3)
github alexmojaki / snoop / tests / samples / lambda_function.py View on Github external
def main():
    my_function = snoop.snoop()(lambda x: x ** 2)
    my_function(3)
github alexmojaki / snoop / tests / samples / generator.py View on Github external
@snoop.snoop()
def f(x1):
    assert not original_tracer_active()
    _x2 = (yield x1)
    assert not original_tracer_active()
    _x3 = 'foo'
    assert not original_tracer_active()
    _x4 = (yield 2)
    assert not original_tracer_active()
github alexmojaki / snoop / tests / samples / long_variable.py View on Github external
@snoop.snoop()
def main():
    foo = list(range(1000))
    return foo
github alexmojaki / snoop / tests / samples / multiline.py View on Github external
@snoop.snoop()
def main():
    x = (
        [
            bar(),  # 1
            bar(),  # 2
        ]
    )

    with context(
            bar(),  # 1
            bar(),  # 2
    ):
        try:
            for _ in [
                bar(
                    bar(),  # 1
github alexmojaki / snoop / tests / samples / var_order.py View on Github external
@snoop.snoop()
def f(_one, _two, _three, _four):
    _five = None
    _six = None
    _seven = None

    _five, _six, _seven = 5, 6, 7
github alexmojaki / executing / tests / samples / tracer2.py View on Github external
def trace(self, frame, event, arg):
        if not self._is_traced_frame(frame):
            if (
                    self.depth == 1
                    or self._is_internal_frame(frame)
            ) and not is_comprehension_frame(frame):
                return None
            else:
                candidate = frame
                i = 0
                while True:
                    if is_comprehension_frame(candidate):
                        candidate = candidate.f_back
                        continue
                    i += 1
                    if self._is_traced_frame(candidate):
                        break
                    candidate = candidate.f_back
                    if i >= self.depth or candidate is None or self._is_internal_frame(candidate):
                        return None

        thread_local = self.config.thread_local
        thread_local.__dict__.setdefault('depth', -1)
        frame_info = self.frame_infos[frame]
        if event in ('call', 'enter'):
            thread_local.depth += 1
        elif self.config.last_frame and self.config.last_frame is not frame:
            line_no = frame_info.last_line_no
github alexmojaki / executing / tests / samples / tracer2.py View on Github external
def trace(self, frame, event, arg):
        if not self._is_traced_frame(frame):
            if (
                    self.depth == 1
                    or self._is_internal_frame(frame)
            ) and not is_comprehension_frame(frame):
                return None
            else:
                candidate = frame
                i = 0
                while True:
                    if is_comprehension_frame(candidate):
                        candidate = candidate.f_back
                        continue
                    i += 1
                    if self._is_traced_frame(candidate):
                        break
                    candidate = candidate.f_back
                    if i >= self.depth or candidate is None or self._is_internal_frame(candidate):
                        return None

        thread_local = self.config.thread_local