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

Method __init__

bpython/curtsiesfrontend/repl.py:330–476  ·  view source on GitHub ↗

locals_ is a mapping of locals to pass into the interpreter config is a bpython config.Struct with config attributes banner is a string to display briefly in the status bar interp is an interpreter instance to use original terminal state, useful for shelling

(
        self,
        config: Config,
        window: CursorAwareWindow,
        locals_: dict[str, Any] | None = None,
        banner: str | None = None,
        interp: Interp | None = None,
        orig_tcattrs: list[Any] | None = None,
    )

Source from the content-addressed store, hash-verified

328 """
329
330 def __init__(
331 self,
332 config: Config,
333 window: CursorAwareWindow,
334 locals_: dict[str, Any] | None = None,
335 banner: str | None = None,
336 interp: Interp | None = None,
337 orig_tcattrs: list[Any] | None = None,
338 ):
339 """
340 locals_ is a mapping of locals to pass into the interpreter
341 config is a bpython config.Struct with config attributes
342 banner is a string to display briefly in the status bar
343 interp is an interpreter instance to use
344 original terminal state, useful for shelling out with normal terminal
345 """
346
347 logger.debug("starting init")
348 self.window = window
349
350 # If creating a new interpreter on undo would be unsafe because initial
351 # state was passed in
352 self.weak_rewind = bool(locals_ or interp)
353
354 if interp is None:
355 interp = Interp(locals=locals_)
356 interp.write = self.send_to_stdouterr # type: ignore
357 if config.cli_suggestion_width <= 0 or config.cli_suggestion_width > 1:
358 config.cli_suggestion_width = 1
359
360 self.reevaluating = False
361 self.fake_refresh_requested = False
362
363 self.status_bar = StatusBar(
364 config,
365 "",
366 request_refresh=self.request_refresh,
367 schedule_refresh=self.schedule_refresh,
368 )
369 self.edit_keys = edit_keys.mapping_with_config(config, key_dispatch)
370 logger.debug("starting parent init")
371 # interp is a subclass of repl.Interpreter, so it definitely,
372 # implements the methods of Interpreter!
373 super().__init__(interp, config)
374
375 self.formatter = BPythonFormatter(config.color_scheme)
376
377 # overwriting what bpython.Repl put there
378 # interact is called to interact with the status bar,
379 # so we're just using the same object
380 self.interact = self.status_bar
381
382 # logical line currently being edited, without ps1 (usually '>>> ')
383 self._current_line = ""
384
385 # current line of output - stdout and stdin go here
386 self.current_stdouterr_line: str | FmtStr = ""
387

Callers

nothing calls this directly

Calls 10

InterpClass · 0.85
StatusBarClass · 0.85
CodeRunnerClass · 0.85
FakeOutputClass · 0.85
FakeStdinClass · 0.85
mapping_with_configMethod · 0.80
activateMethod · 0.80
BPythonFormatterClass · 0.70
messageMethod · 0.45

Tested by

no test coverage detected