MCPcopy
hub / github.com/prompt-toolkit/ptpython / run

Method run

src/ptpython/repl.py:159–190  ·  view source on GitHub ↗

Run the REPL loop.

(self)

Source from the content-addressed store, hash-verified

157 )
158
159 def run(self) -> None:
160 """
161 Run the REPL loop.
162 """
163 if self.terminal_title:
164 set_title(self.terminal_title)
165
166 self._add_to_namespace()
167
168 try:
169 while True:
170 # Pull text from the user.
171 try:
172 text = self.read()
173 except EOFError:
174 return
175 except BaseException:
176 # Something went wrong while reading input.
177 # (E.g., a bug in the completer that propagates. Don't
178 # crash the REPL.)
179 traceback.print_exc()
180 continue
181
182 # Run it; display the result (or errors if applicable).
183 try:
184 self.run_and_show_expression(text)
185 except ReplExit:
186 return
187 finally:
188 if self.terminal_title:
189 clear_title()
190 self._remove_from_namespace()
191
192 async def run_and_show_expression_async(self, text: str) -> Any:
193 loop = asyncio.get_running_loop()

Callers 8

embedFunction · 0.95
prompt_for_codeMethod · 0.80
readMethod · 0.80
runFunction · 0.80
mainFunction · 0.80

Calls 4

_add_to_namespaceMethod · 0.95
readMethod · 0.80

Tested by

no test coverage detected