Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#943)
Browse files Browse the repository at this point in the history
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/python-jsonschema/check-jsonschema: 0.21.0 → 0.22.0](python-jsonschema/check-jsonschema@0.21.0...0.22.0)
- [github.com/psf/black: 23.1.0 → 23.3.0](psf/black@23.1.0...23.3.0)
- [github.com/charliermarsh/ruff-pre-commit: v0.0.254 → v0.0.260](astral-sh/ruff-pre-commit@v0.0.254...v0.0.260)

* sync deps and run lint

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Steven Silvester <[email protected]>
  • Loading branch information
pre-commit-ci[bot] and blink1073 authored Apr 7, 2023
1 parent c5d9e1a commit 58017fc
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 45 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ repos:
- id: trailing-whitespace

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

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

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

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.254
rev: v0.0.260
hooks:
- id: ruff
args: ["--fix"]
31 changes: 9 additions & 22 deletions jupyter_client/__init__.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
"""Client-side implementations of the Jupyter protocol"""
from ._version import __version__ # noqa
from ._version import protocol_version # noqa
from ._version import protocol_version_info # noqa
from ._version import version_info # noqa

try:
from .asynchronous import AsyncKernelClient # noqa
from .blocking import BlockingKernelClient
from .client import KernelClient
from .connect import * # noqa
from .launcher import * # noqa
from .manager import AsyncKernelManager
from .manager import KernelManager
from .manager import run_kernel
from .multikernelmanager import AsyncMultiKernelManager
from .multikernelmanager import MultiKernelManager
from .provisioning import KernelProvisionerBase
from .provisioning import LocalProvisioner
except ModuleNotFoundError:
import warnings

warnings.warn("Could not import submodules")
from ._version import __version__, protocol_version, protocol_version_info, version_info
from .asynchronous import AsyncKernelClient
from .blocking import BlockingKernelClient
from .client import KernelClient
from .connect import * # noqa
from .launcher import * # noqa
from .manager import AsyncKernelManager, KernelManager, run_kernel
from .multikernelmanager import AsyncMultiKernelManager, MultiKernelManager
from .provisioning import KernelProvisionerBase, LocalProvisioner
4 changes: 3 additions & 1 deletion jupyter_client/connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,9 @@ def find_connection_file(
str : The absolute path of the connection file.
"""
if profile is not None:
warnings.warn("Jupyter has no profiles. profile=%s has been ignored." % profile)
warnings.warn(
"Jupyter has no profiles. profile=%s has been ignored." % profile, stacklevel=2
)
if path is None:
path = [".", jupyter_runtime_dir()]
if isinstance(path, str):
Expand Down
2 changes: 1 addition & 1 deletion jupyter_client/consoleapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,5 +371,5 @@ class IPythonConsoleApp(JupyterConsoleApp):

def __init__(self, *args, **kwargs):
"""Initialize the app."""
warnings.warn("IPythonConsoleApp is deprecated. Use JupyterConsoleApp")
warnings.warn("IPythonConsoleApp is deprecated. Use JupyterConsoleApp", stacklevel=2)
super().__init__(*args, **kwargs)
7 changes: 5 additions & 2 deletions jupyter_client/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,11 @@ def launch_kernel(
msg = msg.format(cmd, env.get("PATH", os.defpath), without_env)
get_logger().error(msg)
except Exception as ex2: # Don't let a formatting/logger issue lead to the wrong exception
warnings.warn(f"Failed to run command: '{cmd}' due to exception: {ex}")
warnings.warn(f"The following exception occurred handling the previous failure: {ex2}")
warnings.warn(f"Failed to run command: '{cmd}' due to exception: {ex}", stacklevel=2)
warnings.warn(
f"The following exception occurred handling the previous failure: {ex2}",
stacklevel=2,
)
raise ex

if sys.platform == "win32":
Expand Down
2 changes: 1 addition & 1 deletion jupyter_client/localinterfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def _load_ips(suppress_exceptions=True):
if not suppress_exceptions:
raise
# unexpected error shouldn't crash, load dumb default values instead.
warn("Unexpected error discovering local network interfaces: %s" % e)
warn("Unexpected error discovering local network interfaces: %s" % e, stacklevel=2)
_load_ips_dumb()


Expand Down
2 changes: 1 addition & 1 deletion jupyter_client/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def _kernel_name_changed(self, change: t.Dict[str, str]) -> None:

@property
def kernel_spec(self) -> t.Optional[kernelspec.KernelSpec]:
if self._kernel_spec is None and self.kernel_name != "":
if self._kernel_spec is None and self.kernel_name != "": # noqa
self._kernel_spec = self.kernel_spec_manager.get_kernel_spec(self.kernel_name)
return self._kernel_spec

Expand Down
13 changes: 7 additions & 6 deletions jupyter_client/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def default_secure(cfg: t.Any) -> None: # pragma: no cover
If Session.key/keyfile have not been set, set Session.key to
a new random UUID.
"""
warnings.warn("default_secure is deprecated", DeprecationWarning)
warnings.warn("default_secure is deprecated", DeprecationWarning, stacklevel=2)
if "Session" in cfg and ("key" in cfg.Session or "keyfile" in cfg.Session):
return
# key/keyfile not specified, generate new UUID:
Expand Down Expand Up @@ -567,7 +567,7 @@ def __init__(self, **kwargs):
self._check_packers()
self.none = self.pack({})
# ensure self._session_default() if necessary, so bsession is defined:
self.session
self.session # noqa
self.pid = os.getpid()
self._new_auth()
if not self.key:
Expand Down Expand Up @@ -861,9 +861,9 @@ def send(
stream.send_multipart(to_send, copy=copy)

if self.debug:
pprint.pprint(msg)
pprint.pprint(to_send)
pprint.pprint(buffers)
pprint.pprint(msg) # noqa
pprint.pprint(to_send) # noqa
pprint.pprint(buffers) # noqa

msg["tracker"] = tracker

Expand Down Expand Up @@ -1088,7 +1088,7 @@ def deserialize(
buffers = [memoryview(bytes(b.bytes)) for b in msg_list[5:]]
message["buffers"] = buffers
if self.debug:
pprint.pprint(message)
pprint.pprint(message) # noqa
# adapt to the current version
return adapt(message)

Expand All @@ -1098,5 +1098,6 @@ def unserialize(self, *args: t.Any, **kwargs: t.Any) -> t.Dict[str, t.Any]:
warnings.warn(
"Session.unserialize is deprecated. Use Session.deserialize.",
DeprecationWarning,
stacklevel=2,
)
return self.deserialize(*args, **kwargs)
8 changes: 4 additions & 4 deletions jupyter_client/ssh/tunnel.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def openssh_tunnel(
return tunnel.pid
else:
if failed:
warnings.warn("Password rejected, try again")
warnings.warn("Password rejected, try again", stacklevel=2)
password = None
if password is None:
password = getpass("%s's password: " % (server))
Expand Down Expand Up @@ -378,7 +378,7 @@ def _paramiko_tunnel(lport, rport, server, remoteip, keyfile=None, password=None
# else:
# raise
except Exception as e:
warnings.warn("*** Failed to connect to %s:%d: %r" % (server, port, e))
warnings.warn("*** Failed to connect to %s:%d: %r" % (server, port, e), stacklevel=2)
sys.exit(1)

# Don't let SIGINT kill the tunnel subprocess
Expand All @@ -387,10 +387,10 @@ def _paramiko_tunnel(lport, rport, server, remoteip, keyfile=None, password=None
try:
forward_tunnel(lport, remoteip, rport, client.get_transport())
except KeyboardInterrupt:
warnings.warn("SIGINT: Port forwarding stopped cleanly")
warnings.warn("SIGINT: Port forwarding stopped cleanly", stacklevel=2)
sys.exit(0)
except Exception as e:
warnings.warn("Port forwarding stopped uncleanly: %s" % e)
warnings.warn("Port forwarding stopped uncleanly: %s" % e, stacklevel=2)
sys.exit(255)


Expand Down
8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ test = "mypy --install-types --non-interactive {args:.}"

[tool.hatch.envs.lint]
dependencies = [
"black[jupyter]==23.1.0",
"black[jupyter]==23.3.0",
"mdformat>0.7",
"ruff==0.0.254",
"ruff==0.0.260",
]
[tool.hatch.envs.lint.scripts]
style = [
Expand Down Expand Up @@ -252,6 +252,8 @@ unfixable = [
"T201",
# Don't touch noqa lines
"RUF100",
# Imported but unused
"F401",
]

[tool.ruff.per-file-ignores]
Expand All @@ -267,6 +269,8 @@ unfixable = [
"tests/*" = ["B011", "F841", "C408", "E402", "T201", "B007", "N802", "EM101", "EM102", "PLR2004"]
# T201 `print` found
"*app.py" = ["T201"]
# F401 `._version.__version__` imported but unused
"jupyter_client/__init__.py" = ["F401"]

[tool.interrogate]
ignore-init-module=true
Expand Down
2 changes: 1 addition & 1 deletion tests/test_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def test_default_version():

def test_code_to_line_no_code():
line, pos = code_to_line("", 0)
assert line == ""
assert line == "" # noqa
assert pos == 0


Expand Down
2 changes: 1 addition & 1 deletion tests/test_jsonutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __float__(self):

def test_parse_date_invalid():
assert jsonutil.parse_date(None) is None
assert jsonutil.parse_date("") == ""
assert jsonutil.parse_date("") == "" # noqa
assert jsonutil.parse_date("invalid-date") == "invalid-date"


Expand Down

0 comments on commit 58017fc

Please sign in to comment.