MCPcopy Index your code
hub / github.com/prompt-toolkit/ptpython / PythonInput

Class PythonInput

src/ptpython/python_input.py:186–1120  ·  view source on GitHub ↗

Prompt for reading Python input. :: python_input = PythonInput(...) python_code = python_input.app.run() :param create_app: When `False`, don't create and manage a prompt_toolkit application. The default is `True` and should only be set

Source from the content-addressed store, hash-verified

184
185
186class PythonInput:
187 """
188 Prompt for reading Python input.
189
190 ::
191
192 python_input = PythonInput(...)
193 python_code = python_input.app.run()
194
195 :param create_app: When `False`, don't create and manage a prompt_toolkit
196 application. The default is `True` and should only be set
197 to false if PythonInput is being embedded in a separate
198 prompt_toolkit application.
199 """
200
201 def __init__(
202 self,
203 get_globals: _GetNamespace | None = None,
204 get_locals: _GetNamespace | None = None,
205 history_filename: str | None = None,
206 vi_mode: bool = False,
207 color_depth: ColorDepth | None = None,
208 # Input/output.
209 input: Input | None = None,
210 output: Output | None = None,
211 # For internal use.
212 extra_key_bindings: KeyBindings | None = None,
213 create_app: bool = True,
214 _completer: Completer | None = None,
215 _validator: Validator | None = None,
216 _lexer: Lexer | None = None,
217 _extra_buffer_processors: list[Processor] | None = None,
218 _extra_layout_body: AnyContainer | None = None,
219 _extra_toolbars: list[AnyContainer] | None = None,
220 _input_buffer_height: AnyDimension | None = None,
221 ) -> None:
222 self.get_globals: _GetNamespace = get_globals or (lambda: {})
223 self.get_locals: _GetNamespace = get_locals or self.get_globals
224
225 self.completer = _completer or PythonCompleter(
226 self.get_globals,
227 self.get_locals,
228 lambda: self.enable_dictionary_completion,
229 )
230
231 self._completer = HidePrivateCompleter(
232 # If fuzzy is enabled, first do fuzzy completion, but always add
233 # the non-fuzzy completions, if somehow the fuzzy completer didn't
234 # find them. (Due to the way the cursor position is moved in the
235 # fuzzy completer, some completions will not always be found by the
236 # fuzzy completer, but will be found with the normal completer.)
237 merge_completers(
238 [
239 ConditionalCompleter(
240 FuzzyCompleter(DynamicCompleter(lambda: self.completer)),
241 Condition(lambda: self.enable_fuzzy_completion),
242 ),
243 DynamicCompleter(lambda: self.completer),

Callers 1

mainFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected