From 59f4024242818a222bb3dd8c6ada9c9da79673dd Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 22 Aug 2024 20:19:55 -0400 Subject: [PATCH] Add `indent: str` suport to `Context.pformat()` using `textwrap` --- tractor/_context.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tractor/_context.py b/tractor/_context.py index ff44a34..167aad6 100644 --- a/tractor/_context.py +++ b/tractor/_context.py @@ -46,6 +46,7 @@ from dataclasses import ( from functools import partial import inspect from pprint import pformat +import textwrap from typing import ( Any, AsyncGenerator, @@ -335,6 +336,7 @@ class Context: extra_fields: dict[str, Any]|None = None, # ^-TODO-^ some built-in extra state fields # we'll want in some devx specific cases? + indent: str|None = None, ) -> str: ds: str = '=' @@ -354,7 +356,6 @@ class Context: show_error_fields=True ) fmtstr: str = ( - f'\n' + f'{indent})>\n' ) + # NOTE: making this return a value that can be passed to # `eval()` is entirely **optional** dawggg B) # https://docs.python.org/3/library/functions.html#repr