Skip to content

Commit 58017fc

Browse files
[pre-commit.ci] pre-commit autoupdate (#943)
* [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]>
1 parent c5d9e1a commit 58017fc

File tree

12 files changed

+42
-45
lines changed

12 files changed

+42
-45
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ repos:
2020
- id: trailing-whitespace
2121

2222
- repo: https://github.com/python-jsonschema/check-jsonschema
23-
rev: 0.21.0
23+
rev: 0.22.0
2424
hooks:
2525
- id: check-github-workflows
2626

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

3232
- repo: https://github.com/psf/black
33-
rev: 23.1.0
33+
rev: 23.3.0
3434
hooks:
3535
- id: black
3636

3737
- repo: https://github.com/charliermarsh/ruff-pre-commit
38-
rev: v0.0.254
38+
rev: v0.0.260
3939
hooks:
4040
- id: ruff
4141
args: ["--fix"]

jupyter_client/__init__.py

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,10 @@
11
"""Client-side implementations of the Jupyter protocol"""
2-
from ._version import __version__ # noqa
3-
from ._version import protocol_version # noqa
4-
from ._version import protocol_version_info # noqa
5-
from ._version import version_info # noqa
6-
7-
try:
8-
from .asynchronous import AsyncKernelClient # noqa
9-
from .blocking import BlockingKernelClient
10-
from .client import KernelClient
11-
from .connect import * # noqa
12-
from .launcher import * # noqa
13-
from .manager import AsyncKernelManager
14-
from .manager import KernelManager
15-
from .manager import run_kernel
16-
from .multikernelmanager import AsyncMultiKernelManager
17-
from .multikernelmanager import MultiKernelManager
18-
from .provisioning import KernelProvisionerBase
19-
from .provisioning import LocalProvisioner
20-
except ModuleNotFoundError:
21-
import warnings
22-
23-
warnings.warn("Could not import submodules")
2+
from ._version import __version__, protocol_version, protocol_version_info, version_info
3+
from .asynchronous import AsyncKernelClient
4+
from .blocking import BlockingKernelClient
5+
from .client import KernelClient
6+
from .connect import * # noqa
7+
from .launcher import * # noqa
8+
from .manager import AsyncKernelManager, KernelManager, run_kernel
9+
from .multikernelmanager import AsyncMultiKernelManager, MultiKernelManager
10+
from .provisioning import KernelProvisionerBase, LocalProvisioner

jupyter_client/connect.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,9 @@ def find_connection_file(
191191
str : The absolute path of the connection file.
192192
"""
193193
if profile is not None:
194-
warnings.warn("Jupyter has no profiles. profile=%s has been ignored." % profile)
194+
warnings.warn(
195+
"Jupyter has no profiles. profile=%s has been ignored." % profile, stacklevel=2
196+
)
195197
if path is None:
196198
path = [".", jupyter_runtime_dir()]
197199
if isinstance(path, str):

jupyter_client/consoleapp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,5 +371,5 @@ class IPythonConsoleApp(JupyterConsoleApp):
371371

372372
def __init__(self, *args, **kwargs):
373373
"""Initialize the app."""
374-
warnings.warn("IPythonConsoleApp is deprecated. Use JupyterConsoleApp")
374+
warnings.warn("IPythonConsoleApp is deprecated. Use JupyterConsoleApp", stacklevel=2)
375375
super().__init__(*args, **kwargs)

jupyter_client/launcher.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,11 @@ def launch_kernel(
162162
msg = msg.format(cmd, env.get("PATH", os.defpath), without_env)
163163
get_logger().error(msg)
164164
except Exception as ex2: # Don't let a formatting/logger issue lead to the wrong exception
165-
warnings.warn(f"Failed to run command: '{cmd}' due to exception: {ex}")
166-
warnings.warn(f"The following exception occurred handling the previous failure: {ex2}")
165+
warnings.warn(f"Failed to run command: '{cmd}' due to exception: {ex}", stacklevel=2)
166+
warnings.warn(
167+
f"The following exception occurred handling the previous failure: {ex2}",
168+
stacklevel=2,
169+
)
167170
raise ex
168171

169172
if sys.platform == "win32":

jupyter_client/localinterfaces.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ def _load_ips(suppress_exceptions=True):
261261
if not suppress_exceptions:
262262
raise
263263
# unexpected error shouldn't crash, load dumb default values instead.
264-
warn("Unexpected error discovering local network interfaces: %s" % e)
264+
warn("Unexpected error discovering local network interfaces: %s" % e, stacklevel=2)
265265
_load_ips_dumb()
266266

267267

jupyter_client/manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def _kernel_name_changed(self, change: t.Dict[str, str]) -> None:
178178

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

jupyter_client/session.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def default_secure(cfg: t.Any) -> None: # pragma: no cover
188188
If Session.key/keyfile have not been set, set Session.key to
189189
a new random UUID.
190190
"""
191-
warnings.warn("default_secure is deprecated", DeprecationWarning)
191+
warnings.warn("default_secure is deprecated", DeprecationWarning, stacklevel=2)
192192
if "Session" in cfg and ("key" in cfg.Session or "keyfile" in cfg.Session):
193193
return
194194
# key/keyfile not specified, generate new UUID:
@@ -567,7 +567,7 @@ def __init__(self, **kwargs):
567567
self._check_packers()
568568
self.none = self.pack({})
569569
# ensure self._session_default() if necessary, so bsession is defined:
570-
self.session
570+
self.session # noqa
571571
self.pid = os.getpid()
572572
self._new_auth()
573573
if not self.key:
@@ -861,9 +861,9 @@ def send(
861861
stream.send_multipart(to_send, copy=copy)
862862

863863
if self.debug:
864-
pprint.pprint(msg)
865-
pprint.pprint(to_send)
866-
pprint.pprint(buffers)
864+
pprint.pprint(msg) # noqa
865+
pprint.pprint(to_send) # noqa
866+
pprint.pprint(buffers) # noqa
867867

868868
msg["tracker"] = tracker
869869

@@ -1088,7 +1088,7 @@ def deserialize(
10881088
buffers = [memoryview(bytes(b.bytes)) for b in msg_list[5:]]
10891089
message["buffers"] = buffers
10901090
if self.debug:
1091-
pprint.pprint(message)
1091+
pprint.pprint(message) # noqa
10921092
# adapt to the current version
10931093
return adapt(message)
10941094

@@ -1098,5 +1098,6 @@ def unserialize(self, *args: t.Any, **kwargs: t.Any) -> t.Dict[str, t.Any]:
10981098
warnings.warn(
10991099
"Session.unserialize is deprecated. Use Session.deserialize.",
11001100
DeprecationWarning,
1101+
stacklevel=2,
11011102
)
11021103
return self.deserialize(*args, **kwargs)

jupyter_client/ssh/tunnel.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def openssh_tunnel(
269269
return tunnel.pid
270270
else:
271271
if failed:
272-
warnings.warn("Password rejected, try again")
272+
warnings.warn("Password rejected, try again", stacklevel=2)
273273
password = None
274274
if password is None:
275275
password = getpass("%s's password: " % (server))
@@ -378,7 +378,7 @@ def _paramiko_tunnel(lport, rport, server, remoteip, keyfile=None, password=None
378378
# else:
379379
# raise
380380
except Exception as e:
381-
warnings.warn("*** Failed to connect to %s:%d: %r" % (server, port, e))
381+
warnings.warn("*** Failed to connect to %s:%d: %r" % (server, port, e), stacklevel=2)
382382
sys.exit(1)
383383

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

396396

pyproject.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ test = "mypy --install-types --non-interactive {args:.}"
110110

111111
[tool.hatch.envs.lint]
112112
dependencies = [
113-
"black[jupyter]==23.1.0",
113+
"black[jupyter]==23.3.0",
114114
"mdformat>0.7",
115-
"ruff==0.0.254",
115+
"ruff==0.0.260",
116116
]
117117
[tool.hatch.envs.lint.scripts]
118118
style = [
@@ -252,6 +252,8 @@ unfixable = [
252252
"T201",
253253
# Don't touch noqa lines
254254
"RUF100",
255+
# Imported but unused
256+
"F401",
255257
]
256258

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

271275
[tool.interrogate]
272276
ignore-init-module=true

0 commit comments

Comments
 (0)