Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test changing base method to async after #1295 #1339

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions ipykernel/ipkernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ async def run(execution: Execution) -> None:

return reply_content

def do_complete(self, code, cursor_pos):
async def do_complete(self, code, cursor_pos):
"""Handle code completion."""
if _use_experimental_60_completion and self.use_experimental_completions:
return self._experimental_do_complete(code, cursor_pos)
Expand Down Expand Up @@ -567,7 +567,7 @@ def _experimental_do_complete(self, code, cursor_pos):
"status": "ok",
}

def do_inspect(self, code, cursor_pos, detail_level=0, omit_sections=()):
async def do_inspect(self, code, cursor_pos, detail_level=0, omit_sections=()):
"""Handle code inspection."""
name = token_at_cursor(code, cursor_pos)

Expand Down Expand Up @@ -595,7 +595,7 @@ def do_inspect(self, code, cursor_pos, detail_level=0, omit_sections=()):

return reply_content

def do_history(
async def do_history(
self,
hist_access_type,
output,
Expand Down Expand Up @@ -631,13 +631,13 @@ def do_history(
"history": list(hist),
}

def do_shutdown(self, restart):
async def do_shutdown(self, restart):
"""Handle kernel shutdown."""
if self.shell:
self.shell.exit_now = True
return dict(status="ok", restart=restart)

def do_is_complete(self, code):
async def do_is_complete(self, code):
"""Handle an is_complete request."""
transformer_manager = getattr(self.shell, "input_transformer_manager", None)
if transformer_manager is None:
Expand Down
12 changes: 6 additions & 6 deletions ipykernel/kernelbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ async def execute_request(self, socket, ident, parent):
self._aborted_time = time.monotonic()
self.log.info("Aborting queue")

def do_execute(
async def do_execute(
self,
code,
silent,
Expand Down Expand Up @@ -829,7 +829,7 @@ async def complete_request(self, socket, ident, parent):
matches = json_clean(matches)
self.session.send(socket, "complete_reply", matches, parent, ident)

def do_complete(self, code, cursor_pos):
async def do_complete(self, code, cursor_pos):
"""Override in subclasses to find completions."""
return {
"matches": [],
Expand Down Expand Up @@ -865,7 +865,7 @@ async def inspect_request(self, socket, ident, parent):
msg = self.session.send(socket, "inspect_reply", reply_content, parent, ident)
self.log.debug("%s", msg)

def do_inspect(self, code, cursor_pos, detail_level=0, omit_sections=()):
async def do_inspect(self, code, cursor_pos, detail_level=0, omit_sections=()):
"""Override in subclasses to allow introspection."""
return {"status": "ok", "data": {}, "metadata": {}, "found": False}

Expand All @@ -889,7 +889,7 @@ async def history_request(self, socket, ident, parent):
msg = self.session.send(socket, "history_reply", reply_content, parent, ident)
self.log.debug("%s", msg)

def do_history(
async def do_history(
self,
hist_access_type,
output,
Expand Down Expand Up @@ -1020,7 +1020,7 @@ async def shutdown_request(self, socket, ident, parent):

self.stop()

def do_shutdown(self, restart):
async def do_shutdown(self, restart):
"""Override in subclasses to do things when the frontend shuts down the
kernel.
"""
Expand All @@ -1046,7 +1046,7 @@ async def is_complete_request(self, socket, ident, parent):
reply_msg = self.session.send(socket, "is_complete_reply", reply_content, parent, ident)
self.log.debug("%s", reply_msg)

def do_is_complete(self, code):
async def do_is_complete(self, code):
"""Override in subclasses to find completions."""
return {"status": "unknown"}

Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ filterwarnings= [
"ignore:unclosed database in <sqlite3.Connection:ResourceWarning",

# ignore deprecated non async during tests:
"always:For consistency across implementations, it is recommended that:PendingDeprecationWarning",
"error:For consistency across implementations, it is recommended that:PendingDeprecationWarning",


]

Expand Down
3 changes: 2 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def destroy(self):
@no_type_check
async def test_shell_message(self, *args, **kwargs):
msg_list = self._prep_msg(*args, **kwargs)
print(msg_list)
await self.process_shell_message(msg_list)
receive_stream: MemoryObjectReceiveStream[Any] = self.session._streams[self.shell_socket][
"receive"
Expand Down Expand Up @@ -168,7 +169,7 @@ def __init__(self, *args, **kwargs):
self.shell = MagicMock()
super().__init__(*args, **kwargs)

def do_execute(
async def do_execute(
self, code, silent, store_history=True, user_expressions=None, allow_stdin=False
):
if not silent:
Expand Down
Loading