From 1cb3dbb25871e6ba4af1195723fc4190af489ee6 2016-05-17 01:17:07 From: Matthias Bussonnier Date: 2016-05-17 01:17:07 Subject: [PATCH] Update IPython/core/formatters.py to use new traitlets API. Also remove an unused import. --- diff --git a/IPython/core/formatters.py b/IPython/core/formatters.py index 62d296f..237a2d7 100644 --- a/IPython/core/formatters.py +++ b/IPython/core/formatters.py @@ -11,7 +11,6 @@ Inheritance diagram: # Distributed under the terms of the Modified BSD License. import abc -import inspect import json import sys import traceback @@ -36,7 +35,7 @@ from IPython.utils.py3compat import ( class DisplayFormatter(Configurable): # When set to true only the default plain text formatter will be used. - plain_text_only = Bool(False, config=True) + plain_text_only = Bool(False).tag(config=True) def _plain_text_only_changed(self, name, old, new): warnings.warn("""DisplayFormatter.plain_text_only is deprecated. @@ -50,7 +49,7 @@ class DisplayFormatter(Configurable): else: self.active_types = self.format_types - active_types = List(Unicode(), config=True, + active_types = List(Unicode()).tag(config=True, help="""List of currently active mime-types to display. You can use this to set a white-list for formats to display. @@ -288,21 +287,21 @@ class BaseFormatter(Configurable): format_type = Unicode('text/plain') _return_type = string_types - enabled = Bool(True, config=True) + enabled = Bool(True).tag(config=True) print_method = ObjectName('__repr__') # The singleton printers. # Maps the IDs of the builtin singleton objects to the format functions. - singleton_printers = Dict(config=True) + singleton_printers = Dict().tag(config=True) # The type-specific printers. # Map type objects to the format functions. - type_printers = Dict(config=True) + type_printers = Dict().tag(config=True) # The deferred-import type-specific printers. # Map (modulename, classname) pairs to the format functions. - deferred_printers = Dict(config=True) + deferred_printers = Dict().tag(config=True) @catch_format_error def __call__(self, obj): @@ -569,9 +568,9 @@ class PlainTextFormatter(BaseFormatter): # This subclass ignores this attribute as it always need to return # something. - enabled = Bool(True, config=False) + enabled = Bool(True).tag(config=False) - max_seq_length = Integer(pretty.MAX_SEQ_LENGTH, config=True, + max_seq_length = Integer(pretty.MAX_SEQ_LENGTH).tag(config=True, help="""Truncate large collections (lists, dicts, tuples, sets) to this size. Set to 0 to disable truncation. @@ -582,21 +581,21 @@ class PlainTextFormatter(BaseFormatter): print_method = ObjectName('_repr_pretty_') # Whether to pretty-print or not. - pprint = Bool(True, config=True) + pprint = Bool(True).tag(config=True) # Whether to be verbose or not. - verbose = Bool(False, config=True) + verbose = Bool(False).tag(config=True) # The maximum width. - max_width = Integer(79, config=True) + max_width = Integer(79).tag(config=True) # The newline character. - newline = Unicode('\n', config=True) + newline = Unicode('\n').tag(config=True) # format-string for pprinting floats float_format = Unicode('%r') # setter for float precision, either int or direct format-string - float_precision = CUnicode('', config=True) + float_precision = CUnicode('').tag(config=True) def _float_precision_changed(self, name, old, new): """float_precision changed, set float_format accordingly.