2020import warnings
2121from dis import COMPILER_FLAG_NAMES
2222from pathlib import Path
23- from typing import Any , Callable , ContextManager , Iterable , NoReturn , Sequence
23+ from typing import (
24+ Any ,
25+ Callable ,
26+ ContextManager ,
27+ Coroutine ,
28+ Iterable ,
29+ Literal ,
30+ NoReturn ,
31+ Sequence ,
32+ overload ,
33+ )
2434
2535from prompt_toolkit .formatted_text import OneStyleAndTextTuple
2636from prompt_toolkit .patch_stdout import patch_stdout as patch_stdout_context
@@ -505,6 +515,34 @@ class ReplExit(Exception):
505515 """
506516
507517
518+ @overload
519+ def embed (
520+ globals : dict [str , Any ] | None = ...,
521+ locals : dict [str , Any ] | None = ...,
522+ configure : Callable [[PythonRepl ], None ] | None = ...,
523+ vi_mode : bool = ...,
524+ history_filename : str | None = ...,
525+ title : str | None = ...,
526+ startup_paths : Sequence [str | Path ] | None = ...,
527+ patch_stdout : bool = ...,
528+ return_asyncio_coroutine : Literal [False ] = ...,
529+ ) -> None : ...
530+
531+
532+ @overload
533+ def embed (
534+ globals : dict [str , Any ] | None = ...,
535+ locals : dict [str , Any ] | None = ...,
536+ configure : Callable [[PythonRepl ], None ] | None = ...,
537+ vi_mode : bool = ...,
538+ history_filename : str | None = ...,
539+ title : str | None = ...,
540+ startup_paths : Sequence [str | Path ] | None = ...,
541+ patch_stdout : bool = ...,
542+ return_asyncio_coroutine : Literal [True ] = ...,
543+ ) -> Coroutine [Any , Any , None ]: ...
544+
545+
508546def embed (
509547 globals : dict [str , Any ] | None = None ,
510548 locals : dict [str , Any ] | None = None ,
@@ -515,7 +553,7 @@ def embed(
515553 startup_paths : Sequence [str | Path ] | None = None ,
516554 patch_stdout : bool = False ,
517555 return_asyncio_coroutine : bool = False ,
518- ) -> None :
556+ ) -> None | Coroutine [ Any , Any , None ] :
519557 """
520558 Call this to embed Python shell at the current point in your program.
521559 It's similar to `IPython.embed` and `bpython.embed`. ::
@@ -577,3 +615,4 @@ async def coroutine() -> None:
577615 else :
578616 with patch_context :
579617 repl .run ()
618+ return None
0 commit comments