Only pprint our struct when we detect a py REPL

open_order_loading
Tyler Goodlet 2022-08-11 15:56:28 -04:00
parent bec32956a8
commit 2aec1c5f1d
1 changed files with 7 additions and 1 deletions

View File

@ -18,6 +18,7 @@
Built-in (extension) types. Built-in (extension) types.
""" """
import sys
from typing import Optional from typing import Optional
from pprint import pformat from pprint import pformat
@ -42,8 +43,13 @@ class Struct(
} }
def __repr__(self): def __repr__(self):
# only turn on pprint when we detect a python REPL
# at runtime B)
if hasattr(sys, 'ps1'):
return f'Struct({pformat(self.to_dict())})' return f'Struct({pformat(self.to_dict())})'
return super().__repr__()
def copy( def copy(
self, self,
update: Optional[dict] = None, update: Optional[dict] = None,