Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 committed Oct 22, 2023
1 parent 9e69d36 commit c43ee19
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
6 changes: 4 additions & 2 deletions ipykernel/connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ def _find_connection_file(connection_file):
return jupyter_client.find_connection_file(connection_file)


def get_connection_info(connection_file: str | None = None, unpack: bool = False) -> str:
def get_connection_info(
connection_file: str | None = None, unpack: bool = False
) -> str | dict[str, Any]:
"""Return the connection information for the current Kernel.
Parameters
Expand Down Expand Up @@ -81,7 +83,7 @@ def get_connection_info(connection_file: str | None = None, unpack: bool = False
info = json.loads(info_str)
# ensure key is bytes:
info["key"] = info.get("key", "").encode()
return info
return info # type:ignore[no-any-return]

return info_str

Expand Down
1 change: 1 addition & 0 deletions ipykernel/kernelapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ def write_connection_file(self):
# original file had port number 0, we update with the actual port
# used.
existing_connection_info = get_connection_info(cf, unpack=True)
assert isinstance(existing_connection_info, dict)
connection_info = dict(existing_connection_info, **connection_info)
if connection_info == existing_connection_info:
self.log.debug("Connection file %s with current information already exists", cf)
Expand Down
6 changes: 3 additions & 3 deletions ipykernel/kernelspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def install(
prefix: str | None = None,
profile: str | None = None,
env: dict[str, str] | None = None,
):
) -> str:
"""Install the IPython kernelspec for Jupyter
Parameters
Expand Down Expand Up @@ -147,7 +147,7 @@ def install(
# kernel_name is specified and display_name is not
# default display_name to kernel_name
display_name = kernel_name
overrides = {}
overrides: dict[str, Any] = {}
if display_name:
overrides["display_name"] = display_name
if profile:
Expand All @@ -165,7 +165,7 @@ def install(
)
# cleanup afterward
shutil.rmtree(path)
return dest
return dest # type:ignore[no-any-return]


# Entrypoint
Expand Down
1 change: 1 addition & 0 deletions ipykernel/zmqshell.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ def connect_info(self, arg_s):
if jupyter_runtime_dir() == os.path.dirname(connection_file):
connection_file = os.path.basename(connection_file)

assert isinstance(info, str)
print(info + "\n")
print(
f"Paste the above JSON into a file, and connect with:\n"
Expand Down

0 comments on commit c43ee19

Please sign in to comment.