summaryrefslogtreecommitdiffstats
path: root/examples/python-embed-with-custom-prompt.py
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2023-12-17 10:46:44 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2023-12-17 10:46:44 +0000
commit70b47719c91522ab53abc763eb6da3b62c1a00c9 (patch)
treedb7906833e1af835fb2addf0c220f00904969cd7 /examples/python-embed-with-custom-prompt.py
parentReleasing debian version 3.0.23-3. (diff)
downloadptpython-70b47719c91522ab53abc763eb6da3b62c1a00c9.tar.xz
ptpython-70b47719c91522ab53abc763eb6da3b62c1a00c9.zip
Merging upstream version 3.0.25.
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to '')
-rwxr-xr-xexamples/python-embed-with-custom-prompt.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/examples/python-embed-with-custom-prompt.py b/examples/python-embed-with-custom-prompt.py
index 968aedc..d54da1d 100755
--- a/examples/python-embed-with-custom-prompt.py
+++ b/examples/python-embed-with-custom-prompt.py
@@ -2,26 +2,26 @@
"""
Example of embedding a Python REPL, and setting a custom prompt.
"""
-from prompt_toolkit.formatted_text import HTML
+from prompt_toolkit.formatted_text import HTML, AnyFormattedText
from ptpython.prompt_style import PromptStyle
from ptpython.repl import embed
-def configure(repl):
+def configure(repl) -> None:
# Probably, the best is to add a new PromptStyle to `all_prompt_styles` and
# activate it. This way, the other styles are still selectable from the
# menu.
class CustomPrompt(PromptStyle):
- def in_prompt(self):
+ def in_prompt(self) -> AnyFormattedText:
return HTML("<ansigreen>Input[%s]</ansigreen>: ") % (
repl.current_statement_index,
)
- def in2_prompt(self, width):
+ def in2_prompt(self, width: int) -> AnyFormattedText:
return "...: ".rjust(width)
- def out_prompt(self):
+ def out_prompt(self) -> AnyFormattedText:
return HTML("<ansired>Result[%s]</ansired>: ") % (
repl.current_statement_index,
)
@@ -30,7 +30,7 @@ def configure(repl):
repl.prompt_style = "custom"
-def main():
+def main() -> None:
embed(globals(), locals(), configure=configure)