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

Method __init__

bpython/repl.py:470–534  ·  view source on GitHub ↗

Initialise the repl. interp is a Python code.InteractiveInterpreter instance config is a populated bpython.config.Struct.

(self, interp: Interpreter, config: Config)

Source from the content-addressed store, hash-verified

468 cpos: int
469
470 def __init__(self, interp: Interpreter, config: Config):
471 """Initialise the repl.
472
473 interp is a Python code.InteractiveInterpreter instance
474
475 config is a populated bpython.config.Struct.
476 """
477 self.config = config
478 self.cut_buffer = ""
479 self.buffer: list[str] = []
480 self.interp = interp
481 self.interp.syntaxerror_callback = self.clear_current_line
482 self.match = False
483 self.rl_history = History(
484 duplicates=config.hist_duplicates, hist_size=config.hist_length
485 )
486 # all input and output, stored as old style format strings
487 # (\x01, \x02, ...) for cli.py
488 self.screen_hist: list[str] = []
489 # commands executed since beginning of session
490 self.history: list[str] = []
491 self.redo_stack: list[str] = []
492 self.evaluating = False
493 self.matches_iter = MatchesIterator()
494 self.funcprops = None
495 self.arg_pos: str | int | None = None
496 self.current_func = None
497 self.highlighted_paren: None | (
498 tuple[Any, list[tuple[_TokenType, str]]]
499 ) = None
500 self._C: dict[str, int] = {}
501 self.prev_block_finished: int = 0
502 self.interact: Interaction = NoInteraction(self.config)
503 # previous pastebin content to prevent duplicate pastes, filled on call
504 # to repl.pastebin
505 self.prev_pastebin_content = ""
506 self.prev_pastebin_url = ""
507 self.prev_removal_url = ""
508 # Necessary to fix mercurial.ui.ui expecting sys.stderr to have this
509 # attribute
510 self.closed = False
511 self.paster: PasteHelper | PastePinnwand
512
513 if self.config.hist_file.exists():
514 try:
515 self.rl_history.load(
516 self.config.hist_file,
517 getpreferredencoding() or "ascii",
518 )
519 except OSError:
520 pass
521
522 self.module_gatherer = ModuleGatherer(
523 skiplist=self.config.import_completion_skiplist
524 )
525 self.completers = autocomplete.get_default_completer(
526 config.autocomplete_mode, self.module_gatherer
527 )

Callers 2

__init__Method · 0.45
__init__Method · 0.45

Calls 8

HistoryClass · 0.85
MatchesIteratorClass · 0.85
NoInteractionClass · 0.85
getpreferredencodingFunction · 0.85
ModuleGathererClass · 0.85
PasteHelperClass · 0.85
PastePinnwandClass · 0.85
loadMethod · 0.80

Tested by

no test coverage detected