Skip to content

Commit e073fce

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 82eda48 commit e073fce

File tree

4 files changed

+11
-14
lines changed

4 files changed

+11
-14
lines changed

jupyter_server/base/handlers.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,14 +1195,10 @@ class ExtensionAppsHandler(JupyterHandler):
11951195
def get(self) -> None:
11961196
self.set_header("Content-Type", "application/json")
11971197
if self.serverapp:
1198-
self.finish(
1199-
json.dumps(
1200-
self.serverapp.extension_manager.extension_web_apps()
1201-
)
1202-
)
1198+
self.finish(json.dumps(self.serverapp.extension_manager.extension_web_apps()))
12031199
else:
12041200
# self.serverapp can be None
1205-
raise web.HTTPError(500, 'Server has not started correctly.')
1201+
raise web.HTTPError(500, "Server has not started correctly.")
12061202

12071203

12081204
# -----------------------------------------------------------------------------

jupyter_server/extension/manager.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
from __future__ import annotations
44

55
import importlib
6-
from itertools import starmap
76
import re
7+
from itertools import starmap
88

99
from tornado.gen import multi
1010
from traitlets import Any, Bool, Dict, HasTraits, Instance, List, Unicode, default, observe
@@ -14,8 +14,7 @@
1414
from .config import ExtensionConfigManager
1515
from .utils import ExtensionMetadataError, ExtensionModuleNotFound, get_loader, get_metadata
1616

17-
18-
RE_SLASH = x = re.compile(r'/+') # match any number of slashes
17+
RE_SLASH = x = re.compile(r"/+") # match any number of slashes
1918

2019

2120
class ExtensionPoint(HasTraits):
@@ -306,11 +305,12 @@ def extension_web_apps(self):
306305
extensions which provide a default_url (i.e. a web application).
307306
"""
308307
return {
309-
app.name: RE_SLASH.sub('/', f'{self.serverapp.base_url}/{app.default_url}')
308+
app.name: RE_SLASH.sub("/", f"{self.serverapp.base_url}/{app.default_url}")
310309
for extension_apps in self.serverapp.extension_manager.extension_apps.values()
311310
# filter out extensions that do not provide a default_url OR
312311
# set it to the root endpoint.
313-
for app in extension_apps if getattr(app, 'default_url', '/') != '/'
312+
for app in extension_apps
313+
if getattr(app, "default_url", "/") != "/"
314314
}
315315

316316
@property

tests/extension/mockextensions/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class MockExtensionApp(ExtensionAppJinjaMixin, ExtensionApp):
5050
static_paths = [STATIC_PATH] # type:ignore[assignment]
5151
mock_trait = Unicode("mock trait", config=True)
5252
loaded = False
53-
default_url = '/mockextension'
53+
default_url = "/mockextension"
5454

5555
serverapp_config = {"jpserver_extensions": {"tests.extension.mockextensions.mock1": True}}
5656

tests/extension/test_app.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,11 @@ async def test_extension_web_apps(jp_serverapp):
198198

199199
# there should be (at least) two extension applications
200200
assert set(jp_serverapp.extension_manager.extension_apps) == {
201-
'tests.extension.mockextensions', 'jupyter_server_terminals'
201+
"tests.extension.mockextensions",
202+
"jupyter_server_terminals",
202203
}
203204

204205
# but only one extension web application
205206
assert jp_serverapp.extension_manager.extension_web_apps == {
206-
'mockextension': '/a%40b/mockextension'
207+
"mockextension": "/a%40b/mockextension"
207208
}

0 commit comments

Comments
 (0)