Skip to content

Commit 0111798

Browse files
[pre-commit.ci] pre-commit autoupdate (#1205)Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Steven Silvester <[email protected]>
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/python-jsonschema/check-jsonschema: 0.19.2 → 0.21.0](python-jsonschema/check-jsonschema@0.19.2...0.21.0) - [github.com/psf/black: 22.12.0 → 23.1.0](psf/black@22.12.0...23.1.0) - [github.com/charliermarsh/ruff-pre-commit: v0.0.236 → v0.0.242](astral-sh/ruff-pre-commit@v0.0.236...v0.0.242) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * sync deps * lint * lint * lint * 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 e6bff03 commit 0111798

File tree

27 files changed

+35
-42
lines changed

27 files changed

+35
-42
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.19.2
23+
rev: 0.21.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: 22.12.0
33+
rev: 23.1.0
3434
hooks:
3535
- id: black
3636

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

examples/identity/system_password/jupyter_server_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ def process_login_form(self, handler):
2828
return User(username=username, name=user_info.pw_gecos or username)
2929

3030

31-
c = get_config() # type: ignore # noqa
31+
c = get_config() # type: ignore
3232

3333
c.ServerApp.identity_provider_class = SystemPasswordIdentityProvider

jupyter_server/_tz.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def dst(self, d):
2323
return ZERO
2424

2525

26-
UTC = tzUTC()
26+
UTC = tzUTC() # type:ignore
2727

2828

2929
def utc_aware(unaware):

jupyter_server/base/handlers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ def write_error(self, status_code, **kwargs):
682682
try:
683683
message = exception.log_message % exception.args
684684
except Exception:
685-
pass
685+
pass # noqa
686686

687687
# construct the custom reason, if defined
688688
reason = getattr(exception, "reason", "")

jupyter_server/extension/application.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def _default_serverapp(self):
216216
return ServerApp.instance()
217217
except Exception:
218218
# error retrieving instance, e.g. MultipleInstanceError
219-
pass
219+
pass # noqa
220220

221221
# serverapp accessed before it was defined,
222222
# declare an empty one
@@ -588,7 +588,7 @@ def launch_instance(cls, argv=None, **kwargs):
588588
extension's landing page.
589589
"""
590590
# Handle arguments.
591-
if argv is None:
591+
if argv is None: # noqa
592592
args = sys.argv[1:] # slice out extension config.
593593
else:
594594
args = argv

jupyter_server/extension/handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def static_url(self, path, include_host=None, **kwargs):
115115
if include_host is None:
116116
include_host = getattr(self, "include_host", False)
117117

118-
if include_host:
118+
if include_host: # noqa
119119
base = self.request.protocol + "://" + self.request.host # type:ignore[attr-defined]
120120
else:
121121
base = ""

jupyter_server/gateway/managers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ async def kernel_culled(self, kernel_id: str) -> bool: # typing: ignore
338338
# notification model, this will need to be revisited.
339339
km = self.kernel_manager.get_kernel(kernel_id)
340340
except Exception: # Let exceptions here reflect culled kernel
341-
pass
341+
pass # noqa
342342
return km is None
343343

344344

jupyter_server/nbconvert/handlers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def get_exporter(format, **kwargs):
6868
"""get an exporter, raising appropriate errors"""
6969
# if this fails, will raise 500
7070
try:
71-
from nbconvert.exporters.base import get_exporter # type:ignore
71+
from nbconvert.exporters.base import get_exporter
7272
except ImportError as e:
7373
raise web.HTTPError(500, "Could not import nbconvert: %s" % e) from e
7474

jupyter_server/prometheus/metrics.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
)
1717

1818
except ImportError:
19-
2019
from prometheus_client import Gauge, Histogram
2120

2221
HTTP_REQUEST_DURATION_SECONDS = Histogram(

jupyter_server/serverapp.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,7 +1796,6 @@ def _deprecated_rate_limit_window(self, change):
17961796

17971797
@default("terminals_enabled")
17981798
def _default_terminals_enabled(self):
1799-
18001799
return True
18011800

18021801
authenticate_prometheus = Bool(
@@ -2729,7 +2728,7 @@ def _prepare_browser_open(self):
27292728
if self.identity_provider.token:
27302729
uri = url_concat(uri, {"token": self.identity_provider.token})
27312730

2732-
if self.file_to_run:
2731+
if self.file_to_run: # noqa
27332732
# Create a separate, temporary open-browser-file
27342733
# pointing at a specific file.
27352734
open_file = self.browser_open_file_to_run

jupyter_server/services/contents/manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def _validate_preferred_dir(self, proposal):
9393
if value != self.parent.preferred_dir:
9494
self.parent.preferred_dir = os.path.join(self.root_dir, *value.split("/"))
9595
except (AttributeError, TraitError):
96-
pass
96+
pass # noqa
9797
return value
9898

9999
allow_hidden = Bool(False, config=True, help="Allow access to hidden files")

jupyter_server/services/kernels/connection/base.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""Kernel connection helpers."""
22
import json
33
import struct
4-
import sys
54

65
from jupyter_client.session import Session
76
from tornado.websocket import WebSocketHandler
@@ -36,8 +35,6 @@ def serialize_binary_message(msg):
3635
# don't modify msg or buffer list in-place
3736
msg = msg.copy()
3837
buffers = list(msg.pop("buffers"))
39-
if sys.version_info < (3, 4):
40-
buffers = [x.tobytes() for x in buffers]
4138
bmsg = json.dumps(msg, default=json_default).encode("utf8")
4239
buffers.insert(0, bmsg)
4340
nbufs = len(buffers)

jupyter_server/services/kernels/connection/channels.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def create_stream(self):
164164
self.channels[channel] = stream = meth(identity=identity)
165165
stream.channel = channel
166166

167-
def nudge(self):
167+
def nudge(self): # noqa
168168
"""Nudge the zmq connections with kernel_info_requests
169169
Returns a Future that will resolve when we have received
170170
a shell or control reply and at least one iopub message,
@@ -444,7 +444,7 @@ def disconnect(self):
444444
ZMQChannelsWebsocketConnection._open_sockets.remove(self)
445445
self._close_future.set_result(None)
446446
except Exception:
447-
pass
447+
pass # noqa
448448

449449
def handle_incoming_message(self, incoming_msg: str) -> None:
450450
"""Handle incoming messages from Websocket to ZMQ Sockets."""
@@ -657,7 +657,7 @@ def write_stderr(self, error_message, parent_header):
657657
err_msg["channel"] = "iopub"
658658
self.write_message(json.dumps(err_msg, default=json_default))
659659

660-
def _limit_rate(self, channel, msg, msg_list):
660+
def _limit_rate(self, channel, msg, msg_list): # noqa
661661
"""Limit the message rate on a channel."""
662662
if not (self.limit_rate and channel == "iopub"):
663663
return False

jupyter_server/services/kernels/handlers.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ async def post(self, kernel_id, action):
9494
await ensure_async(km.interrupt_kernel(kernel_id))
9595
self.set_status(204)
9696
if action == "restart":
97-
9897
try:
9998
await km.restart_kernel(kernel_id)
10099
except Exception as e:

jupyter_server/services/kernels/kernelmanager.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,8 @@ def list_kernels(self):
516516
model = self.kernel_model(kernel_id)
517517
kernels.append(model)
518518
except (web.HTTPError, KeyError):
519-
pass # Probably due to a (now) non-existent kernel, continue building the list
519+
# Probably due to a (now) non-existent kernel, continue building the list
520+
pass # noqa
520521
return kernels
521522

522523
# override _check_kernel_id to raise 404 instead of KeyError

jupyter_server/services/sessions/sessionmanager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def _validate_database_filepath(self, proposal):
189189
with open(value, "rb") as f:
190190
header = f.read(100)
191191

192-
if not header.startswith(b"SQLite format 3") and header != b"": # noqa
192+
if not header.startswith(b"SQLite format 3") and header != b"":
193193
msg = "The given file is not an SQLite database file."
194194
raise TraitError(msg)
195195
return value

jupyter_server/traittypes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def validate(self, obj, value):
7777
if self.subclass_from_klasses(value):
7878
return value
7979
except Exception:
80-
pass
80+
pass # noqa
8181

8282
self.error(obj, value)
8383

@@ -109,7 +109,7 @@ def _resolve_classes(self):
109109
klass = self._resolve_string(klass)
110110
self.importable_klasses.append(klass)
111111
except Exception:
112-
pass
112+
pass # noqa
113113
else:
114114
self.importable_klasses.append(klass)
115115

@@ -221,7 +221,7 @@ def _resolve_classes(self):
221221
klass = self._resolve_string(klass)
222222
self.importable_klasses.append(klass)
223223
except Exception:
224-
pass
224+
pass # noqa
225225
else:
226226
self.importable_klasses.append(klass)
227227

jupyter_server/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,9 @@ def is_namespace_package(namespace):
313313
# NOTE: using submodule_search_locations because the loader can be None
314314
try:
315315
spec = importlib.util.find_spec(namespace)
316-
except ValueError: # spec is not set - see https://docs.python.org/3/library/importlib.html#importlib.util.find_spec
316+
except (
317+
ValueError
318+
): # spec is not set - see https://docs.python.org/3/library/importlib.html#importlib.util.find_spec
317319
return None
318320

319321
if not spec:

pyproject.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ integration = "test --integration_tests=true {args}"
118118
[tool.hatch.envs.lint]
119119
detached = true
120120
dependencies = [
121-
"black[jupyter]==22.12.0",
121+
"black[jupyter]==23.1.0",
122122
"mdformat>0.7",
123-
"ruff==0.0.236",
123+
"ruff==0.0.242",
124124
]
125125
[tool.hatch.envs.lint.scripts]
126126
style = [
@@ -217,6 +217,10 @@ ignore = [
217217
"N818",
218218
# SIM105 Use `contextlib.suppress(...)`
219219
"SIM105",
220+
# PLR0913 Too many arguments to function call
221+
"PLR0913",
222+
# PLR0912 Too many branches
223+
"PLR0912",
220224
]
221225
unfixable = [
222226
# Don't touch print statements

tests/auth/test_identity.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ async def test_auth_disabled(request, jp_serverapp, jp_fetch):
187187
assert not idp.auth_enabled
188188

189189
with mock.patch.dict(jp_serverapp.web_app.settings, {"identity_provider": idp}):
190-
191190
resp = await jp_fetch("/api/me", headers={"Authorization": "", "Cookie": ""})
192191

193192
user_info = json.loads(resp.body.decode("utf8"))

tests/extension/mockextensions/app.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ def get(self):
4343

4444

4545
class MockExtensionApp(ExtensionAppJinjaMixin, ExtensionApp):
46-
4746
name = "mockextension"
4847
template_paths = List().tag(config=True)
4948
static_paths = [STATIC_PATH]

tests/services/contents/test_api.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,6 @@ async def test_copy_400_hidden(
595595
contents,
596596
contents_dir,
597597
):
598-
599598
# Create text files
600599
hidden_dir = contents_dir / ".hidden"
601600
hidden_dir.mkdir(parents=True, exist_ok=True)
@@ -795,7 +794,6 @@ async def test_rename_400_hidden(jp_fetch, jp_base_url, contents, contents_dir):
795794

796795

797796
async def test_checkpoints_follow_file(jp_fetch, contents):
798-
799797
path = "foo"
800798
name = "a.ipynb"
801799

tests/services/contents/test_fileio.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ def handle_umask():
7878

7979
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Windows")
8080
def test_atomic_writing_umask(handle_umask, tmp_path):
81-
8281
os.umask(0o022)
8382
f1 = str(tmp_path / "1")
8483
with atomic_writing(f1) as f:

tests/services/contents/test_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ async def test_403(jp_file_contents_manager_class, tmp_path):
260260

261261

262262
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Can't test hidden files on Windows")
263-
async def test_400(jp_file_contents_manager_class, tmp_path):
263+
async def test_400(jp_file_contents_manager_class, tmp_path): # noqa
264264
# Test Delete behavior
265265
# Test delete of file in hidden directory
266266
td = str(tmp_path)
@@ -503,7 +503,7 @@ async def test_modified_date(jp_contents_manager):
503503
assert renamed["last_modified"] >= saved["last_modified"]
504504

505505

506-
async def test_get(jp_contents_manager):
506+
async def test_get(jp_contents_manager): # noqa
507507
cm = jp_contents_manager
508508
# Create a notebook
509509
model = await ensure_async(cm.new_untitled(type="notebook"))

tests/test_gateway.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def generate_model(name):
7777
return model
7878

7979

80-
async def mock_gateway_request(url, **kwargs):
80+
async def mock_gateway_request(url, **kwargs): # noqa
8181
method = "GET"
8282
if kwargs["method"]:
8383
method = kwargs["method"]
@@ -197,7 +197,6 @@ def helper(*args, **kwargs):
197197

198198

199199
class CustomTestTokenRenewer(GatewayTokenRenewerBase): # type:ignore[misc]
200-
201200
TEST_EXPECTED_TOKEN_VALUE = "Use this token value: 42"
202201

203202
# The following are configured by the config test to ensure they flow
@@ -342,7 +341,7 @@ def test_gateway_request_timeout_pad_option(
342341
GatewayClient.instance().init_connection_args()
343342

344343
assert app.gateway_config.request_timeout == expected_request_timeout
345-
assert GatewayClient.instance().KERNEL_LAUNCH_TIMEOUT == expected_kernel_launch_timeout
344+
assert expected_kernel_launch_timeout == GatewayClient.instance().KERNEL_LAUNCH_TIMEOUT
346345

347346
GatewayClient.clear_instance()
348347

tests/test_traittypes.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ class DummyInt(int):
1515

1616

1717
class Thing(HasTraits):
18-
1918
a = InstanceFromClasses(
2019
default_value=2,
2120
klasses=[

tests/unix_sockets/test_serverapp_integration.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ def test_shutdown_server(jp_environ):
214214

215215
@pytest.mark.integration_test
216216
def test_jupyter_server_apps(jp_environ):
217-
218217
# Start a server in another process
219218
# Stop that server
220219
import subprocess

0 commit comments

Comments
 (0)