Skip to content

Commit d35244c

Browse files
committed
Fix linter
1 parent 6c45e50 commit d35244c

File tree

1 file changed

+64
-63
lines changed

1 file changed

+64
-63
lines changed

nbclient/client.py

Lines changed: 64 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,10 @@ def _kernel_manager_class_default(self) -> KernelManager:
278278
)
279279

280280
def __init__(
281-
self,
282-
nb: NotebookNode,
283-
km: t.Optional[KernelManager] = None,
284-
**kw) -> None:
281+
self,
282+
nb: NotebookNode,
283+
km: t.Optional[KernelManager] = None,
284+
**kw) -> None:
285285
"""Initializes the execution manager.
286286
287287
Parameters
@@ -489,9 +489,9 @@ def on_signal():
489489
pass
490490

491491
async def async_execute(
492-
self,
493-
reset_kc: bool = False,
494-
**kwargs) -> NotebookNode:
492+
self,
493+
reset_kc: bool = False,
494+
**kwargs) -> NotebookNode:
495495
"""
496496
Executes each code cell.
497497
@@ -554,9 +554,9 @@ def set_widgets_metadata(self) -> None:
554554
widget['buffers'] = buffers
555555

556556
def _update_display_id(
557-
self,
558-
display_id: str,
559-
msg: t.Dict) -> None:
557+
self,
558+
display_id: str,
559+
msg: t.Dict) -> None:
560560
"""Update outputs with a given display_id"""
561561
if display_id not in self._display_id_map:
562562
self.log.debug("display id %r not in %s", display_id, self._display_id_map)
@@ -578,14 +578,15 @@ def _update_display_id(
578578
outputs[output_idx]['data'] = out['data']
579579
outputs[output_idx]['metadata'] = out['metadata']
580580

581-
async def _async_poll_for_reply(self,
582-
msg_id: str,
583-
cell: NotebookNode,
584-
timeout: t.Optional[int],
585-
task_poll_output_msg: asyncio.Future) -> t.Dict:
581+
async def _async_poll_for_reply(
582+
self,
583+
msg_id: str,
584+
cell: NotebookNode,
585+
timeout: t.Optional[int],
586+
task_poll_output_msg: asyncio.Future) -> t.Dict:
586587

587588
assert self.kc is not None
588-
new_timeout: t.Optional[float]= None
589+
new_timeout: t.Optional[float] = None
589590
if timeout is not None:
590591
deadline = monotonic() + timeout
591592
new_timeout = float(timeout)
@@ -615,10 +616,10 @@ async def _async_poll_for_reply(self,
615616
await self._async_handle_timeout(timeout, cell)
616617

617618
async def _async_poll_output_msg(
618-
self,
619-
parent_msg_id: str,
620-
cell: NotebookNode,
621-
cell_index: int) -> None:
619+
self,
620+
parent_msg_id: str,
621+
cell: NotebookNode,
622+
cell_index: int) -> None:
622623

623624
assert self.kc is not None
624625
while True:
@@ -642,9 +643,9 @@ def _get_timeout(self, cell: t.Optional[NotebookNode]) -> int:
642643
return timeout
643644

644645
async def _async_handle_timeout(
645-
self,
646-
timeout: int,
647-
cell: t.Optional[NotebookNode] = None) -> None:
646+
self,
647+
timeout: int,
648+
cell: t.Optional[NotebookNode] = None) -> None:
648649

649650
assert self.km is not None
650651
self.log.error("Timeout waiting for execute reply (%is)." % timeout)
@@ -663,9 +664,9 @@ async def _async_check_alive(self) -> None:
663664
raise DeadKernelError("Kernel died")
664665

665666
async def async_wait_for_reply(
666-
self,
667-
msg_id: str,
668-
cell: t.Optional[NotebookNode] = None) -> t.Optional[t.Dict]:
667+
self,
668+
msg_id: str,
669+
cell: t.Optional[NotebookNode] = None) -> t.Optional[t.Dict]:
669670

670671
assert self.kc is not None
671672
# wait for finish, with timeout
@@ -699,9 +700,9 @@ def _passed_deadline(self, deadline: int) -> bool:
699700
return False
700701

701702
def _check_raise_for_error(
702-
self,
703-
cell: NotebookNode,
704-
exec_reply: t.Optional[t.Dict]) -> None:
703+
self,
704+
cell: NotebookNode,
705+
exec_reply: t.Optional[t.Dict]) -> None:
705706

706707
cell_allows_errors = self.allow_errors or "raises-exception" in cell.metadata.get(
707708
"tags", []
@@ -712,11 +713,11 @@ def _check_raise_for_error(
712713
raise CellExecutionError.from_cell_and_msg(cell, exec_reply['content'])
713714

714715
async def async_execute_cell(
715-
self,
716-
cell: NotebookNode,
717-
cell_index: int,
718-
execution_count: t.Optional[int] = None,
719-
store_history: bool = True) -> NotebookNode:
716+
self,
717+
cell: NotebookNode,
718+
cell_index: int,
719+
execution_count: t.Optional[int] = None,
720+
store_history: bool = True) -> NotebookNode:
720721
"""
721722
Executes a single code cell.
722723
@@ -798,10 +799,10 @@ async def async_execute_cell(
798799
execute_cell = run_sync(async_execute_cell)
799800

800801
def process_message(
801-
self,
802-
msg: t.Dict,
803-
cell: NotebookNode,
804-
cell_index: int) -> t.Optional[t.List]:
802+
self,
803+
msg: t.Dict,
804+
cell: NotebookNode,
805+
cell_index: int) -> t.Optional[t.List]:
805806
"""
806807
Processes a kernel message, updates cell state, and returns the
807808
resulting output object that was appended to cell.outputs.
@@ -864,11 +865,11 @@ def process_message(
864865
return None
865866

866867
def output(
867-
self,
868-
outs: t.List,
869-
msg: t.Dict,
870-
display_id: str,
871-
cell_index: int) -> t.Optional[t.List]:
868+
self,
869+
outs: t.List,
870+
msg: t.Dict,
871+
display_id: str,
872+
cell_index: int) -> t.Optional[t.List]:
872873

873874
msg_type = msg['msg_type']
874875

@@ -904,10 +905,10 @@ def output(
904905
return out
905906

906907
def clear_output(
907-
self,
908-
outs: t.List,
909-
msg: t.Dict,
910-
cell_index: int) -> None:
908+
self,
909+
outs: t.List,
910+
msg: t.Dict,
911+
cell_index: int) -> None:
911912

912913
content = msg['content']
913914

@@ -928,18 +929,18 @@ def clear_output(
928929
self.clear_display_id_mapping(cell_index)
929930

930931
def clear_display_id_mapping(
931-
self,
932-
cell_index: int) -> None:
932+
self,
933+
cell_index: int) -> None:
933934

934935
for display_id, cell_map in self._display_id_map.items():
935936
if cell_index in cell_map:
936937
cell_map[cell_index] = []
937938

938939
def handle_comm_msg(
939-
self,
940-
outs: t.List,
941-
msg: t.Dict,
942-
cell_index: int) -> None:
940+
self,
941+
outs: t.List,
942+
msg: t.Dict,
943+
cell_index: int) -> None:
943944

944945
content = msg['content']
945946
data = content['data']
@@ -989,9 +990,9 @@ def _get_buffer_data(self, msg: t.Dict) -> t.List[t.Dict[str, str]]:
989990
return encoded_buffers
990991

991992
def register_output_hook(
992-
self,
993-
msg_id: str,
994-
hook: t.Callable) -> None:
993+
self,
994+
msg_id: str,
995+
hook: t.Callable) -> None:
995996
"""Registers an override object that handles output/clear_output instead.
996997
997998
Multiple hooks can be registered, where the last one will be used (stack based)
@@ -1001,9 +1002,9 @@ def register_output_hook(
10011002
self.output_hook_stack[msg_id].append(hook)
10021003

10031004
def remove_output_hook(
1004-
self,
1005-
msg_id: str,
1006-
hook: t.Callable) -> None:
1005+
self,
1006+
msg_id: str,
1007+
hook: t.Callable) -> None:
10071008
"""Unregisters an override object that handles output/clear_output instead"""
10081009
# mimics
10091010
# https://jupyterlab.github.io/jupyterlab/services/interfaces/kernel.ikernelconnection.html#removemessagehook
@@ -1023,10 +1024,10 @@ def on_comm_open_jupyter_widget(self, msg: t.Dict):
10231024

10241025

10251026
def execute(
1026-
nb: NotebookNode,
1027-
cwd: t.Optional[str] = None,
1028-
km: t.Optional[KernelManager] = None,
1029-
**kwargs) -> NotebookClient:
1027+
nb: NotebookNode,
1028+
cwd: t.Optional[str] = None,
1029+
km: t.Optional[KernelManager] = None,
1030+
**kwargs) -> NotebookClient:
10301031
"""Execute a notebook's code, updating outputs within the notebook object.
10311032
10321033
This is a convenient wrapper around NotebookClient. It returns the

0 commit comments

Comments
 (0)