Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jupyter/jupyter_client
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v8.0.2
Choose a base ref
...
head repository: jupyter/jupyter_client
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: dc0eaba1f609079672ec739fcd977dc44431da92
Choose a head ref
  • 5 commits
  • 20 files changed
  • 7 contributors

Commits on Feb 7, 2023

  1. [pre-commit.ci] pre-commit autoupdate (#928)

    Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
    Co-authored-by: David Brochart <david.brochart@gmail.com>
    Co-authored-by: Steven Silvester <steven.silvester@ieee.org>
    3 people authored Feb 7, 2023
    Copy the full SHA
    19dbf1b View commit details

Commits on Feb 8, 2023

  1. Improving jsonutil tests (#929)

    Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
    andrehora and pre-commit-ci[bot] authored Feb 8, 2023
    Copy the full SHA
    557530b View commit details

Commits on Feb 12, 2023

  1. Copy the full SHA
    e77ad89 View commit details

Commits on Feb 16, 2023

  1. Add license (#934)

    Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
    dcsaba89 and pre-commit-ci[bot] authored Feb 16, 2023
    Copy the full SHA
    9df6ac3 View commit details
  2. fix kernelspec print output (#933)

    - typos in log -> print migration, where deferred formatting doesn't work
    - keep errors written to stderr
    minrk authored Feb 16, 2023
    Copy the full SHA
    dc0eaba View commit details
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.19.2
rev: 0.21.0
hooks:
- id: check-github-workflows

@@ -30,12 +30,12 @@ repos:
- id: mdformat

- repo: https://github.com/psf/black
rev: 22.12.0
rev: 23.1.0
hooks:
- id: black

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.236
rev: v0.0.243
hooks:
- id: ruff
args: ["--fix"]
62 changes: 0 additions & 62 deletions COPYING.md

This file was deleted.

31 changes: 31 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
BSD 3-Clause License

- Copyright (c) 2001-2015, IPython Development Team
- Copyright (c) 2015-, Jupyter Development Team

All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -79,4 +79,32 @@ yourself after that.
Some of the hooks only run on CI by default, but you can invoke them by
running with the `--hook-stage manual` argument.

## About the Jupyter Development Team

The Jupyter Development Team is the set of all contributors to the Jupyter project.
This includes all of the Jupyter subprojects.

The core team that coordinates development on GitHub can be found here:
https://github.com/jupyter/.

## Our Copyright Policy

Jupyter uses a shared copyright model. Each contributor maintains copyright
over their contributions to Jupyter. But, it is important to note that these
contributions are typically only changes to the repositories. Thus, the Jupyter
source code, in its entirety is not the copyright of any single person or
institution. Instead, it is the collective copyright of the entire Jupyter
Development Team. If individual contributors want to maintain a record of what
changes/contributions they have specific copyright on, they should indicate
their copyright in the commit message of the change, when they commit the
change to one of the Jupyter repositories.

With this in mind, the following banner should be used in any source code file
to indicate the copyright and license terms:

```
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
```

[jupyter protocol]: https://jupyter-client.readthedocs.io/en/latest/messaging.html
4 changes: 2 additions & 2 deletions jupyter_client/jsonutil.py
Original file line number Diff line number Diff line change
@@ -111,7 +111,7 @@ def json_default(obj):
return obj.isoformat().replace('+00:00', 'Z')

if isinstance(obj, bytes):
return b2a_base64(obj).decode('ascii')
return b2a_base64(obj, newline=False).decode('ascii')

if isinstance(obj, Iterable):
return list(obj)
@@ -157,7 +157,7 @@ def json_clean(obj):
if isinstance(obj, bytes):
# unanmbiguous binary data is base64-encoded
# (this probably should have happened upstream)
return b2a_base64(obj).decode('ascii')
return b2a_base64(obj, newline=False).decode('ascii')

if isinstance(obj, container_to_list) or (
hasattr(obj, '__iter__') and hasattr(obj, next_attr_name)
19 changes: 9 additions & 10 deletions jupyter_client/kernelspecapp.py
Original file line number Diff line number Diff line change
@@ -62,7 +62,7 @@ def path_key(item):

print("Available kernels:")
for kernelname, path in sorted(paths.items(), key=path_key):
print(" %s %s", kernelname.ljust(name_len), path)
print(f" {kernelname.ljust(name_len)} {path}")
else:
print(json.dumps({"kernelspecs": specs}, indent=2))
return specs
@@ -140,7 +140,7 @@ def parse_command_line(self, argv):
if self.extra_args:
self.sourcedir = self.extra_args[0]
else:
print("No source directory specified.")
print("No source directory specified.", file=sys.stderr)
self.exit(1)

def start(self):
@@ -157,14 +157,12 @@ def start(self):
)
except OSError as e:
if e.errno == errno.EACCES:
print(e)
print(e, file=sys.stderr)
if not self.user:
print(
"Perhaps you want to install with `sudo` or `--user`?",
)
print("Perhaps you want to install with `sudo` or `--user`?", file=sys.stderr)
self.exit(1)
elif e.errno == errno.EEXIST:
print("A kernel spec is already present at %s", e.filename)
print(f"A kernel spec is already present at {e.filename}", file=sys.stderr)
self.exit(1)
raise

@@ -209,7 +207,8 @@ def start(self):
if not (self.force or self.answer_yes):
print("Kernel specs to remove:")
for name in self.spec_names:
print(" %s\t%s", name.ljust(20), name.ljust(20))
path = spec_paths.get(name, name)
print(f" {name.ljust(20)}\t{path.ljust(20)}")
answer = input("Remove %i kernel specs [y/N]: " % len(self.spec_names))
if not answer.lower().startswith("y"):
return
@@ -224,7 +223,7 @@ def start(self):
self.exit(1)
else:
raise
print("Removed %s", path)
print(f"Removed {path}")


class InstallNativeKernelSpec(JupyterApp):
@@ -295,7 +294,7 @@ def start(self):
name_len = len(sorted(provisioners, key=lambda name: len(name))[-1])

for name in sorted(provisioners):
print(" %s %s", name.ljust(name_len), provisioners[name])
print(f" {name.ljust(name_len)} {provisioners[name]}")


class KernelSpecApp(Application):
2 changes: 1 addition & 1 deletion jupyter_client/localinterfaces.py
Original file line number Diff line number Diff line change
@@ -128,7 +128,7 @@ def _load_ips_ip():
addrs = []
for line in lines:
blocks = line.lower().split()
if (len(blocks) >= 2) and (blocks[0] == "inet"): # noqa
if (len(blocks) >= 2) and (blocks[0] == "inet"):
addrs.append(blocks[1].split("/")[0])
_populate_from_list(addrs)

1 change: 0 additions & 1 deletion jupyter_client/multikernelmanager.py
Original file line number Diff line number Diff line change
@@ -533,7 +533,6 @@ def new_kernel_id(self, **kwargs: t.Any) -> str:


class AsyncMultiKernelManager(MultiKernelManager):

kernel_manager_class = DottedObjectName(
"jupyter_client.ioloop.AsyncIOLoopKernelManager",
config=True,
2 changes: 1 addition & 1 deletion jupyter_client/provisioning/local_provisioner.py
Original file line number Diff line number Diff line change
@@ -127,7 +127,7 @@ def _tolerate_no_process(os_error: OSError) -> None:
# In Windows, we will get an Access Denied error if the process
# has already terminated. Ignore it.
if sys.platform == 'win32':
if os_error.winerror != 5: # noqa
if os_error.winerror != 5:
raise
# On Unix, we may get an ESRCH error (or ProcessLookupError instance) if
# the process has already terminated. Ignore it.
2 changes: 1 addition & 1 deletion jupyter_client/session.py
Original file line number Diff line number Diff line change
@@ -835,7 +835,7 @@ def send(
else:
try:
# check to see if buf supports the buffer protocol.
view = memoryview(buf) # type:ignore[assignment]
view = memoryview(buf)
except TypeError as e:
emsg = "Buffer objects must support the buffer protocol."
raise TypeError(emsg) from e
1 change: 1 addition & 0 deletions jupyter_client/ssh/forward.py
Original file line number Diff line number Diff line change
@@ -88,6 +88,7 @@ def handle(self):

def forward_tunnel(local_port, remote_host, remote_port, transport):
"""Forward an ssh tunnel."""

# this is a little convoluted, but lets me configure things for the Handler
# object. (SocketServer doesn't give Handlers any way to access the outer
# server normally.)
1 change: 1 addition & 0 deletions jupyter_client/win_interrupt.py
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ def create_interrupt_event():
this handle and use it with ``send_interrupt`` to interrupt the child
process.
"""

# Create a security attributes struct that permits inheritance of the
# handle by new processes.
# FIXME: We can clean up this mess by requiring pywin32 for IPython.
11 changes: 7 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ file = "README.md"
content-type = "text/markdown"

[project.license]
file = "COPYING.md"
file = "LICENSE"

[project.urls]
Homepage = "https://jupyter.org"
@@ -108,9 +108,9 @@ test = "mypy --install-types --non-interactive {args:.}"

[tool.hatch.envs.lint]
dependencies = [
"black[jupyter]==22.12.0",
"black[jupyter]==23.1.0",
"mdformat>0.7",
"ruff==0.0.236",
"ruff==0.0.243",
]
[tool.hatch.envs.lint.scripts]
style = [
@@ -196,7 +196,6 @@ select = [
"N",
"PLC",
"PLE",
"PLR",
"PLW",
"Q",
"RUF",
@@ -239,6 +238,10 @@ ignore = [
"N806",
# SIM105 Use `contextlib.suppress(ValueError)` instead of try-except-pass
"SIM105",
# SIM108 [*] Use ternary operator
"SIM108",
# S110 `try`-`except`-`pass` detected, consider logging the exception
"S110",
]
unfixable = [
# Don't touch print statements
2 changes: 0 additions & 2 deletions tests/test_connect.py
Original file line number Diff line number Diff line change
@@ -247,15 +247,13 @@ def test_mixin_cleanup_random_ports():

@pytest.mark.parametrize("file_exists, km_matches", param_values)
def test_reconcile_connection_info(file_exists, km_matches):

expected_info = sample_info
mismatched_info = sample_info.copy()
mismatched_info["key"] = b"def456"
mismatched_info["shell_port"] = expected_info["shell_port"] + 42
mismatched_info["control_port"] = expected_info["control_port"] + 42

with TemporaryDirectory() as connection_dir:

cf = os.path.join(connection_dir, "kernel.json")
km = KernelManager()
km.connection_file = cf
Loading