|
4 | 4 |
|
5 | 5 | """ Positron extensions to the iPython Kernel."""
|
6 | 6 | from __future__ import annotations
|
| 7 | + |
7 | 8 | import asyncio
|
8 | 9 | import logging
|
9 | 10 | import warnings
|
10 | 11 | from collections.abc import Iterable
|
11 | 12 | from itertools import chain
|
12 |
| -from typing import Any, Callable, Container, Dict, Mapping, Optional, Set, Tuple, Type |
| 13 | +from typing import Any, Callable, Container, Coroutine, Dict, Mapping, Optional, Set, Tuple, Type |
13 | 14 |
|
| 15 | +import traitlets |
14 | 16 | from ipykernel.comm.manager import CommManager
|
15 | 17 | from ipykernel.ipkernel import IPythonKernel
|
16 | 18 | from ipykernel.kernelapp import IPKernelApp
|
17 |
| -from ipykernel.zmqshell import ZMQInteractiveShell, ZMQDisplayPublisher |
18 |
| -from IPython.core import oinspect |
| 19 | +from ipykernel.zmqshell import ZMQDisplayPublisher, ZMQInteractiveShell |
| 20 | +from IPython.core import oinspect, page |
19 | 21 | from IPython.core.interactiveshell import InteractiveShell
|
20 |
| -from IPython.core.magic import Magics, line_magic, magics_class, needs_local_scope, MagicsManager |
21 |
| -from IPython.core import page |
| 22 | +from IPython.core.magic import Magics, MagicsManager, line_magic, magics_class, needs_local_scope |
22 | 23 | from IPython.utils import PyColorize
|
23 |
| -import traitlets |
24 | 24 |
|
25 | 25 | from .dataviewer import DataViewerService
|
26 |
| -from .variables import VariablesService |
27 | 26 | from .frontend import FrontendService
|
28 | 27 | from .help import HelpService
|
29 | 28 | from .inspectors import get_inspector
|
30 | 29 | from .lsp import LSPService
|
31 | 30 | from .plots import PositronDisplayPublisherHook
|
32 | 31 | from .utils import cancel_tasks, create_task
|
| 32 | +from .variables import VariablesService |
33 | 33 |
|
34 | 34 | POSITRON_DATA_VIEWER_COMM = "positron.dataViewer"
|
35 | 35 | """The comm channel target_name for Positron's Data Viewer"""
|
@@ -69,12 +69,11 @@ class PositronIPythonInspector(oinspect.Inspector):
|
69 | 69 | def pinfo(
|
70 | 70 | self,
|
71 | 71 | obj: Any,
|
72 |
| - oname: str, |
73 |
| - formatter: Callable[[str], Dict[str, str]], |
74 |
| - info: oinspect.OInfo, |
75 |
| - *, |
76 |
| - detail_level: int, |
77 |
| - enable_html_pager: bool, |
| 72 | + oname: str = "", |
| 73 | + formatter: Optional[Callable[[str], Dict[str, str]]] = None, |
| 74 | + info: Optional[oinspect.OInfo] = None, |
| 75 | + detail_level: int = 0, |
| 76 | + enable_html_pager: bool = True, |
78 | 77 | omit_sections: Container[str] = (),
|
79 | 78 | ) -> None:
|
80 | 79 | # Intercept `%pinfo obj` / `obj?` calls, and instead use Positron's help service
|
@@ -106,7 +105,7 @@ class PositronShell(ZMQInteractiveShell):
|
106 | 105 | ).tag(config=True)
|
107 | 106 |
|
108 | 107 | @traitlets.observe("colors")
|
109 |
| - def init_inspector(self, change: Optional[traitlets.Bunch] = None) -> None: |
| 108 | + def init_inspector(self, changes: Optional[traitlets.Bunch] = None) -> None: |
110 | 109 | # Override to pass `parent=self` to the inspector
|
111 | 110 | self.inspector = self.inspector_class(
|
112 | 111 | oinspect.InspectColors,
|
@@ -160,7 +159,6 @@ class PositronIPyKernel(IPythonKernel):
|
160 | 159 |
|
161 | 160 | shell: PositronShell
|
162 | 161 | comm_manager: CommManager
|
163 |
| - execution_count: int |
164 | 162 |
|
165 | 163 | shell_class: PositronShell = traitlets.Type(PositronShell, klass=InteractiveShell) # type: ignore
|
166 | 164 |
|
@@ -230,7 +228,7 @@ def start(self) -> None:
|
230 | 228 | super().start()
|
231 | 229 | self.help_service.start()
|
232 | 230 |
|
233 |
| - async def do_shutdown(self, restart: bool) -> Dict[str, Any]: |
| 231 | + async def do_shutdown(self, restart: bool) -> Dict[str, str | bool]: # type: ignore ReportIncompatibleMethodOverride |
234 | 232 | """
|
235 | 233 | Handle kernel shutdown.
|
236 | 234 | """
|
|
0 commit comments