MCPcopy Create free account
hub / github.com/ipython/ipython / pop

Method pop

IPython/core/formatters.py:509–548  ·  view source on GitHub ↗

Pop a formatter for the given type. Parameters ---------- typ : type or '__module__.__name__' string for a type default : object value to be returned if no formatter is registered for typ. Returns ------- obj : object

(self, typ, default=_raise_key_error)

Source from the content-addressed store, hash-verified

507 return oldfunc
508
509 def pop(self, typ, default=_raise_key_error):
510 """Pop a formatter for the given type.
511
512 Parameters
513 ----------
514 typ : type or '__module__.__name__' string for a type
515 default : object
516 value to be returned if no formatter is registered for typ.
517
518 Returns
519 -------
520 obj : object
521 The last registered object for the type.
522
523 Raises
524 ------
525 KeyError if the type is not registered and default is not specified.
526 """
527
528 if isinstance(typ, str):
529 typ_key = tuple(typ.rsplit('.',1))
530 if typ_key not in self.deferred_printers:
531 # We may have it cached in the type map. We will have to
532 # iterate over all of the types to check.
533 for cls in self.type_printers:
534 if _mod_name_key(cls) == typ_key:
535 old = self.type_printers.pop(cls)
536 break
537 else:
538 old = default
539 else:
540 old = self.deferred_printers.pop(typ_key)
541 else:
542 if typ in self.type_printers:
543 old = self.type_printers.pop(typ)
544 else:
545 old = self.deferred_printers.pop(_mod_name_key(typ), default)
546 if old is _raise_key_error:
547 raise KeyError("No registered value for {0!r}".format(typ))
548 return old
549
550 def _in_deferred_types(self, cls):
551 """

Callers 15

setup.pyFile · 0.80
iter_fieldsFunction · 0.80
__exit__Method · 0.80
token_at_cursorFunction · 0.80
__init__Method · 0.80
test_get_home_dir_8Function · 0.80
test_get_xdg_dir_0Function · 0.80
test_get_xdg_dir_1Function · 0.80
test_get_xdg_dir_2Function · 0.80
test_get_xdg_dir_3Function · 0.80
test_shim_warningFunction · 0.80

Calls 2

_mod_name_keyFunction · 0.85
formatMethod · 0.45

Tested by 15

test_get_home_dir_8Function · 0.64
test_get_xdg_dir_0Function · 0.64
test_get_xdg_dir_1Function · 0.64
test_get_xdg_dir_2Function · 0.64
test_get_xdg_dir_3Function · 0.64
test_shim_warningFunction · 0.64
test_popFunction · 0.64
test_pop_stringFunction · 0.64
test_pasteMethod · 0.64
test_paste_pypromptMethod · 0.64
test_paste_py_multi_rMethod · 0.64