From 5835a76e1eb6c528c0d7ffba0ee808036ad064ac 2017-01-23 18:13:20 From: Srinivas Reddy Thatiparthy Date: 2017-01-23 18:13:20 Subject: [PATCH] remove dict() function call and replace it with dict literal - {} --- diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index 0b96152..a22e5bb 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -1139,7 +1139,7 @@ class InteractiveShell(SingletonConfigurable): # For more details: # http://mail.python.org/pipermail/python-dev/2001-April/014068.html - ns = dict() + ns = {} # make global variables for user access to the histories ns['_ih'] = self.history_manager.input_hist_parsed @@ -1367,7 +1367,7 @@ class InteractiveShell(SingletonConfigurable): if not oname.startswith(ESC_MAGIC) and \ not oname.startswith(ESC_MAGIC2) and \ not py3compat.isidentifier(oname, dotted=True): - return dict(found=False) + return {'found': False} if namespaces is None: # Namespaces to search in: diff --git a/IPython/core/pylabtools.py b/IPython/core/pylabtools.py index 30ca16b..11807ea 100644 --- a/IPython/core/pylabtools.py +++ b/IPython/core/pylabtools.py @@ -109,13 +109,13 @@ def print_figure(fig, fmt='png', bbox_inches='tight', **kwargs): fmt = 'png' # build keyword args - kw = dict( - format=fmt, - facecolor=fig.get_facecolor(), - edgecolor=fig.get_edgecolor(), - dpi=dpi, - bbox_inches=bbox_inches, - ) + kw = { + "format":fmt, + "facecolor":fig.get_facecolor(), + "edgecolor":fig.get_edgecolor(), + "dpi":dpi, + "bbox_inches":bbox_inches, + } # **kwargs get higher priority kw.update(kwargs) @@ -134,7 +134,7 @@ def retina_figure(fig, **kwargs): if pngdata is None: return w, h = _pngxy(pngdata) - metadata = dict(width=w//2, height=h//2) + metadata = {"width": w//2, "height":h//2} return pngdata, metadata # We need a little factory function here to create the closure where @@ -383,7 +383,7 @@ def configure_inline_support(shell, backend): shell.events.register('post_execute', flush_figures) # Save rcParams that will be overwrittern - shell._saved_rcParams = dict() + shell._saved_rcParams = {} for k in cfg.rc: shell._saved_rcParams[k] = matplotlib.rcParams[k] # load inline_rc diff --git a/IPython/sphinxext/ipython_directive.py b/IPython/sphinxext/ipython_directive.py index b2df66d..b612b8c 100644 --- a/IPython/sphinxext/ipython_directive.py +++ b/IPython/sphinxext/ipython_directive.py @@ -1162,7 +1162,7 @@ array([[ inf, nan, 2., 3.], #ipython_directive.DEBUG = True # dbg #options = dict(suppress=True) # dbg - options = dict() + options = {} for example in examples: content = example.split('\n') IPythonDirective('debug', arguments=None, options=options, diff --git a/docs/autogen_shortcuts.py b/docs/autogen_shortcuts.py index b65ad99..95c8d60 100755 --- a/docs/autogen_shortcuts.py +++ b/docs/autogen_shortcuts.py @@ -39,7 +39,7 @@ def multi_filter_str(flt): yield name(flt) -log_filters = dict(_AndList='And', _OrList='Or') +log_filters = {'_AndList': 'And', '_OrList': 'Or'} log_invert = {'_Invert'} kbm = KeyBindingManager.for_prompt() @@ -53,8 +53,8 @@ if common_docs: dummy_docs = list(set(dummy_docs)) -single_filter = dict() -multi_filter = dict() +single_filter = {} +multi_filter = {} for kb in ipy_bindings: doc = kb.handler.__doc__ if not doc or doc in dummy_docs: