Skip to content

Commit 444138c

Browse files
authored
Update typings and fix tests (#1344)
1 parent 1ffd6ee commit 444138c

File tree

9 files changed

+26
-42
lines changed

9 files changed

+26
-42
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ci:
44

55
repos:
66
- repo: https://github.com/pre-commit/pre-commit-hooks
7-
rev: v4.4.0
7+
rev: v4.5.0
88
hooks:
99
- id: check-case-conflict
1010
- id: check-ast
@@ -44,11 +44,6 @@ repos:
4444
- id: blacken-docs
4545
additional_dependencies: [black==23.7.0]
4646

47-
- repo: https://github.com/psf/black-pre-commit-mirror
48-
rev: 23.9.1
49-
hooks:
50-
- id: black
51-
5247
- repo: https://github.com/codespell-project/codespell
5348
rev: "v2.2.6"
5449
hooks:
@@ -63,13 +58,14 @@ repos:
6358
- id: rst-inline-touching-normal
6459

6560
- repo: https://github.com/astral-sh/ruff-pre-commit
66-
rev: v0.0.292
61+
rev: v0.1.3
6762
hooks:
6863
- id: ruff
6964
args: ["--fix", "--show-fixes"]
65+
- id: ruff-format
7066

7167
- repo: https://github.com/scientific-python/cookie
72-
rev: "2023.09.21"
68+
rev: "2023.10.27"
7369
hooks:
7470
- id: sp-repo-review
7571
additional_dependencies: ["repo-review[cli]"]

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@
152152
# Theme options are theme-specific and customize the look and feel of a theme
153153
# further. For a list of options available for each theme, see the
154154
# documentation.
155-
# html_theme_options = {}
155+
html_theme_options = {"navigation_with_keys": False}
156156

157157
# Add any paths that contain custom themes here, relative to this directory.
158158
# html_theme_path = []

jupyter_server/base/handlers.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ async def prepare(self) -> Awaitable[None] | None: # type:ignore[override]
611611
warnings.warn( # noqa
612612
"Overriding JupyterHandler.get_current_user is deprecated in jupyter-server 2.0."
613613
" Use an IdentityProvider class.",
614-
DeprecationWarning
614+
DeprecationWarning,
615615
# stacklevel not useful here
616616
)
617617
user = User(self.get_current_user())
@@ -993,9 +993,7 @@ def initialize(
993993
if isinstance(path, str):
994994
path = [path]
995995

996-
self.root = tuple(
997-
os.path.abspath(os.path.expanduser(p)) + os.sep for p in path
998-
) # type:ignore[assignment]
996+
self.root = tuple(os.path.abspath(os.path.expanduser(p)) + os.sep for p in path) # type:ignore[assignment]
999997
self.default_filename = default_filename
1000998

1001999
def compute_etag(self) -> str | None:

jupyter_server/gateway/gateway_client.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -546,9 +546,7 @@ def __init__(self, **kwargs):
546546
"""Initialize a gateway client."""
547547
super().__init__(**kwargs)
548548
self._connection_args = {} # initialized on first use
549-
self.gateway_token_renewer = self.gateway_token_renewer_class(
550-
parent=self, log=self.log
551-
) # type:ignore[operator]
549+
self.gateway_token_renewer = self.gateway_token_renewer_class(parent=self, log=self.log) # type:ignore[operator]
552550

553551
# store of cookies with store time
554552
self._cookies: ty.Dict[str, ty.Tuple[Morsel, datetime]] = {}

jupyter_server/serverapp.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,8 +1255,7 @@ def _default_allow_remote(self) -> bool:
12551255
# scoped to the loopback interface. For now, we'll assume that
12561256
# any scoped link-local address is effectively local.
12571257
if not (
1258-
parsed.is_loopback
1259-
or (("%" in addr) and parsed.is_link_local) # type:ignore[operator]
1258+
parsed.is_loopback or (("%" in addr) and parsed.is_link_local) # type:ignore[operator]
12601259
):
12611260
return True
12621261
return False
@@ -1885,7 +1884,8 @@ def init_configurables(self) -> None:
18851884
self.gateway_config = GatewayClient.instance(parent=self)
18861885

18871886
if not issubclass(
1888-
self.kernel_manager_class, AsyncMappingKernelManager # type:ignore[arg-type]
1887+
self.kernel_manager_class, # type:ignore[arg-type]
1888+
AsyncMappingKernelManager,
18891889
):
18901890
warnings.warn(
18911891
"The synchronous MappingKernelManager class is deprecated and will not be supported in Jupyter Server 3.0",
@@ -1894,7 +1894,8 @@ def init_configurables(self) -> None:
18941894
)
18951895

18961896
if not issubclass(
1897-
self.contents_manager_class, AsyncContentsManager # type:ignore[arg-type]
1897+
self.contents_manager_class, # type:ignore[arg-type]
1898+
AsyncContentsManager,
18981899
):
18991900
warnings.warn(
19001901
"The synchronous ContentsManager classes are deprecated and will not be supported in Jupyter Server 3.0",
@@ -1967,9 +1968,7 @@ def init_configurables(self) -> None:
19671968
f"Ignoring deprecated config ServerApp.login_handler_class={self.login_handler_class}."
19681969
" Superseded by ServerApp.identity_provider_class={self.identity_provider_class}."
19691970
)
1970-
self.identity_provider = self.identity_provider_class(
1971-
**identity_provider_kwargs
1972-
) # type:ignore[operator]
1971+
self.identity_provider = self.identity_provider_class(**identity_provider_kwargs) # type:ignore[operator]
19731972

19741973
if self.identity_provider_class is LegacyIdentityProvider:
19751974
# legacy config stored the password in tornado_settings

jupyter_server/services/kernels/connection/channels.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -627,11 +627,7 @@ def _finish_kernel_info(self, info):
627627
if protocol_version != client_protocol_version:
628628
self.session.adapt_version = int(protocol_version.split(".")[0])
629629
self.log.info(
630-
"Adapting from protocol version {protocol_version} (kernel {kernel_id}) to {client_protocol_version} (client).".format(
631-
protocol_version=protocol_version,
632-
kernel_id=self.kernel_id,
633-
client_protocol_version=client_protocol_version,
634-
)
630+
f"Adapting from protocol version {protocol_version} (kernel {self.kernel_id}) to {client_protocol_version} (client)."
635631
)
636632
if not self._kernel_info_future.done():
637633
self._kernel_info_future.set_result(info)

jupyter_server/utils.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,7 @@ def is_namespace_package(namespace: str) -> bool | None:
321321
# NOTE: using submodule_search_locations because the loader can be None
322322
try:
323323
spec = importlib.util.find_spec(namespace)
324-
except (
325-
ValueError
326-
): # spec is not set - see https://docs.python.org/3/library/importlib.html#importlib.util.find_spec
324+
except ValueError: # spec is not set - see https://docs.python.org/3/library/importlib.html#importlib.util.find_spec
327325
return None
328326

329327
if not spec:

pyproject.toml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ nowarn = "test -W default {args}"
104104

105105
[tool.hatch.envs.typing]
106106
features = ["test"]
107-
dependencies = [ "mypy~=1.6", "traitlets>=5.11.2", "jupyter_core>=5.3.2"]
107+
dependencies = [ "mypy~=1.6", "traitlets>=5.11.2", "jupyter_core>=5.3.2", "jupyter_client>=8.5"]
108108
[tool.hatch.envs.typing.scripts]
109109
test = "mypy --install-types --non-interactive {args:.}"
110110

@@ -119,19 +119,18 @@ integration = "test --integration_tests=true {args}"
119119
[tool.hatch.envs.lint]
120120
detached = true
121121
dependencies = [
122-
"black[jupyter]==23.3.0",
123122
"mdformat>0.7",
124-
"ruff==0.0.287",
123+
"ruff==0.1.3",
125124
]
126125
[tool.hatch.envs.lint.scripts]
127126
style = [
128127
"ruff {args:.}",
129-
"black --check --diff {args:.}",
128+
"ruff format {args:.}",
130129
"mdformat --check {args:docs/source *.md}"
131130
]
132131
fmt = [
133-
"black {args:.}",
134132
"ruff --fix {args:.}",
133+
"ruff format {args:.}",
135134
"mdformat {args:docs/source *.md}"
136135
]
137136

@@ -153,13 +152,11 @@ skip-if-exists = ["jupyter_server/static/style/bootstrap.min.css"]
153152
install-pre-commit-hook = true
154153
optional-editable-build = true
155154

156-
[tool.black]
157-
line-length = 100
158-
target-version = ["py38"]
159-
160155
[tool.ruff]
161156
target-version = "py38"
162157
line-length = 100
158+
159+
[tool.ruff.lint]
163160
select = [
164161
"A",
165162
"B",
@@ -171,7 +168,6 @@ select = [
171168
"FBT",
172169
"I",
173170
"ICN",
174-
"ISC",
175171
"N",
176172
"PLC",
177173
"PLE",
@@ -234,7 +230,7 @@ unfixable = [
234230
"RUF100",
235231
]
236232

237-
[tool.ruff.per-file-ignores]
233+
[tool.ruff.lint.per-file-ignores]
238234
# B011 Do not call assert False since python -O removes these calls
239235
# F841 local variable 'foo' is assigned to but never used
240236
# C408 Unnecessary `dict` call

tests/services/sessions/test_manager.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ class DummyKernel:
2424
def __init__(self, kernel_name="python"):
2525
self.kernel_name = kernel_name
2626

27+
def update_env(self, *args, **kwargs):
28+
pass
29+
2730

2831
dummy_date = utcnow()
2932
dummy_date_s = isoformat(dummy_date)

0 commit comments

Comments
 (0)