MCPcopy Index your code
hub / github.com/ipython/ipython / __init__

Method __init__

IPython/core/tbtools.py:388–433  ·  view source on GitHub ↗
(
        self,
        color_scheme: Any = _sentinel,
        call_pdb: bool = False,
        ostream: Any = None,
        *,
        debugger_cls: type | None = None,
        theme_name: str = "nocolor",
    )

Source from the content-addressed store, hash-verified

386 pdb: Any
387
388 def __init__(
389 self,
390 color_scheme: Any = _sentinel,
391 call_pdb: bool = False,
392 ostream: Any = None,
393 *,
394 debugger_cls: type | None = None,
395 theme_name: str = "nocolor",
396 ):
397 if color_scheme is not _sentinel:
398 assert isinstance(color_scheme, str), color_scheme
399 warnings.warn(
400 "color_scheme is deprecated since IPython 9.0, use theme_name instead, all lowercase",
401 DeprecationWarning,
402 stacklevel=2,
403 )
404 theme_name = color_scheme
405 if theme_name in ["Linux", "LightBG", "Neutral", "NoColor"]:
406 warnings.warn(
407 f"Theme names and color schemes are lowercase in IPython 9.0 use {theme_name.lower()} instead",
408 DeprecationWarning,
409 stacklevel=2,
410 )
411 theme_name = theme_name.lower()
412 # Whether to call the interactive pdb debugger after printing
413 # tracebacks or not
414 super().__init__()
415 self.call_pdb = call_pdb
416
417 # Output stream to write to. Note that we store the original value in
418 # a private attribute and then make the public ostream a property, so
419 # that we can delay accessing sys.stdout until runtime. The way
420 # things are written now, the sys.stdout object is dynamically managed
421 # so a reference to it should NEVER be stored statically. This
422 # property approach confines this detail to a single location, and all
423 # subclasses can simply access self.ostream for writing.
424 self._ostream = ostream
425
426 # Create color table
427 self.set_theme_name(theme_name)
428 self.debugger_cls = debugger_cls or debugger.Pdb
429
430 if call_pdb:
431 self.pdb = self.debugger_cls()
432 else:
433 self.pdb = None
434
435 def _get_ostream(self) -> Any:
436 """Output stream that exceptions are written to.

Callers

nothing calls this directly

Calls 3

set_theme_nameMethod · 0.95
warnMethod · 0.80
debugger_clsMethod · 0.80

Tested by

no test coverage detected