Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save thepabloaguilar/2e1b61f2b83a64210f88c62d213cf4b3 to your computer and use it in GitHub Desktop.
Save thepabloaguilar/2e1b61f2b83a64210f88c62d213cf4b3 to your computer and use it in GitHub Desktop.
[Article] Monkey Patching is not too bad - `collect_traces` example
from returns.result import Failure, Result
from returns.primitives.tracing import collect_traces
@collect_traces
def get_failure(argument: str) -> Result[str, str]:
return Failure(argument)
failure = get_failure('example')
for trace_line in failure.trace:
print(f"{trace_line.filename}:{trace_line.lineno} in `{trace_line.function}`")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment