mirror of https://github.com/Textualize/rich.git
allow disable pprint
This commit is contained in:
parent
6e7d81d8c5
commit
dff665e33c
|
@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
- Fixed an edge case bug when console module try to detect if they are in a tty at the end of a pytest run
|
||||
- Fixed issue with TERM env vars that have more than one hyphen https://github.com/willmcgugan/rich/issues/1640
|
||||
- Fixed exception in IPython when disabling pprint with %pprint https://github.com/willmcgugan/rich/issues/1646
|
||||
|
||||
## [10.12.0] - 2021-10-06
|
||||
|
||||
|
|
|
@ -166,9 +166,17 @@ def install(
|
|||
ip = get_ipython() # type: ignore
|
||||
from IPython.core.formatters import BaseFormatter
|
||||
|
||||
class RichFormatter(BaseFormatter):
|
||||
pprint: bool = True
|
||||
|
||||
def __call__(self, value: Any) -> Any:
|
||||
if self.pprint:
|
||||
return ipy_display_hook(value)
|
||||
else:
|
||||
return repr(value)
|
||||
|
||||
# replace plain text formatter with rich formatter
|
||||
rich_formatter = BaseFormatter()
|
||||
rich_formatter.for_type(object, func=ipy_display_hook)
|
||||
rich_formatter = RichFormatter()
|
||||
ip.display_formatter.formatters["text/plain"] = rich_formatter
|
||||
except Exception:
|
||||
sys.displayhook = display_hook
|
||||
|
|
Loading…
Reference in New Issue