Skip to content

Commit 8884d8b

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 847bf7f commit 8884d8b

File tree

30 files changed

+748
-614
lines changed

30 files changed

+748
-614
lines changed

CONTRIBUTING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@ jlpm run watch
9090
jupyter lab
9191
```
9292

93-
With the watch command running, every saved change will immediately be built locally
94-
and available in your running JupyterLab. Refresh JupyterLab to load the change in
93+
With the watch command running, every saved change will immediately be built locally
94+
and available in your running JupyterLab. Refresh JupyterLab to load the change in
9595
your browser (you may need to wait several seconds for the extension to be rebuilt).
9696

97-
By default, the `jlpm run build` command generates the source maps for this
98-
extension to make it easier to debug using the browser dev tools. To also generate
97+
By default, the `jlpm run build` command generates the source maps for this
98+
extension to make it easier to debug using the browser dev tools. To also generate
9999
source maps for the JupyterLab core extensions, you can run the following command:
100100

101101
```bash

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ Jupyter Server within a container and only allow network access to the Jupyter
4848
Server via the container.
4949

5050
> For more insights, see [Ryan Lovett's comment about
51-
it](https://github.com/jupyterhub/jupyter-server-proxy/pull/359#issuecomment-1350118197).
51+
> it](https://github.com/jupyterhub/jupyter-server-proxy/pull/359#issuecomment-1350118197).
5252
5353
## Install
5454

5555
### Requirements
5656

57-
* `jupyterlab>=2` or `notebook`
57+
- `jupyterlab>=2` or `notebook`
5858

5959
### Python package
6060

contrib/code-server-traitlet/jupyter_notebook_config.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@
33

44

55
c.ServerProxy.servers = {
6-
'code-server': {
7-
'command': [
8-
'code-server',
9-
'--auth=none',
10-
'--disable-telemetry',
11-
'--bind-addr=localhost:{port}'
12-
],
13-
'timeout': 20,
14-
'launcher_entry': {
15-
'title': 'VS Code'
6+
"code-server": {
7+
"command": [
8+
"code-server",
9+
"--auth=none",
10+
"--disable-telemetry",
11+
"--bind-addr=localhost:{port}",
12+
],
13+
"timeout": 20,
14+
"launcher_entry": {"title": "VS Code"},
1615
}
17-
}
1816
}

contrib/template/cookiecutter.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"project_name": "",
3-
"author_name": "Project Jupyter Contributors",
4-
"author_email": "[email protected]"
2+
"project_name": "",
3+
"author_name": "Project Jupyter Contributors",
4+
"author_email": "[email protected]"
55
}

contrib/template/{{cookiecutter.project_name}}/jupyter_{{cookiecutter.project_name}}_proxy/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"""
77
import os
88

9+
910
def setup_{{cookiecutter.project_name}}():
1011
return {
1112
'command': [],

contrib/theia/jupyter_theia_proxy/__init__.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,22 @@
77
import os
88
import shutil
99

10+
1011
def setup_theia():
1112
# Make sure theia is in $PATH
1213
def _theia_command(port):
13-
full_path = shutil.which('theia')
14+
full_path = shutil.which("theia")
1415
if not full_path:
15-
raise FileNotFoundError('Can not find theia executable in $PATH')
16-
return ['theia', 'start', '.', '--hostname=127.0.0.1', '--port=' + str(port)]
16+
raise FileNotFoundError("Can not find theia executable in $PATH")
17+
return ["theia", "start", ".", "--hostname=127.0.0.1", "--port=" + str(port)]
1718

1819
return {
19-
'command': _theia_command,
20-
'environment': {
21-
'USE_LOCAL_GIT': 'true'
20+
"command": _theia_command,
21+
"environment": {"USE_LOCAL_GIT": "true"},
22+
"launcher_entry": {
23+
"title": "Theia IDE",
24+
"icon_path": os.path.join(
25+
os.path.dirname(os.path.abspath(__file__)), "icons", "theia.svg"
26+
),
2227
},
23-
'launcher_entry': {
24-
'title': 'Theia IDE',
25-
'icon_path': os.path.join(os.path.dirname(os.path.abspath(__file__)), 'icons', 'theia.svg')
26-
}
27-
}
28+
}

contrib/theia/setup.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,20 @@
22

33
setuptools.setup(
44
name="jupyter-theia-proxy",
5-
version='1.0dev',
5+
version="1.0dev",
66
url="https://github.com/jupyterhub/jupyter-server-proxy/tree/HEAD/contrib/theia",
77
author="Project Jupyter Contributors",
88
description="[email protected]",
99
packages=setuptools.find_packages(),
10-
keywords=['Jupyter'],
11-
classifiers=['Framework :: Jupyter'],
12-
install_requires=[
13-
'jupyter-server-proxy'
14-
],
10+
keywords=["Jupyter"],
11+
classifiers=["Framework :: Jupyter"],
12+
install_requires=["jupyter-server-proxy"],
1513
entry_points={
16-
'jupyter_serverproxy_servers': [
17-
'theia = jupyter_theia_proxy:setup_theia',
14+
"jupyter_serverproxy_servers": [
15+
"theia = jupyter_theia_proxy:setup_theia",
1816
]
1917
},
2018
package_data={
21-
'jupyter_theia_proxy': ['icons/*'],
19+
"jupyter_theia_proxy": ["icons/*"],
2220
},
2321
)

docs/source/arbitrary-ports-hosts.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,4 @@ accessing it from a classic notebook extension.
9090
// Construct URL of our proxied service
9191
let service_url = base_url + 'proxy/' + port;
9292
93-
// Do stuff with your service_url
93+
// Do stuff with your service_url

docs/source/changelog.md

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
[@bollwyvl](https://github.com/search?q=repo%3Ajupyterhub%2Fjupyter-server-proxy+involves%3Abollwyvl+updated%3A2021-11-29..2022-01-19&type=Issues) | [@consideRatio](https://github.com/search?q=repo%3Ajupyterhub%2Fjupyter-server-proxy+involves%3AconsideRatio+updated%3A2021-11-29..2022-01-19&type=Issues) | [@yuvipanda](https://github.com/search?q=repo%3Ajupyterhub%2Fjupyter-server-proxy+involves%3Ayuvipanda+updated%3A2021-11-29..2022-01-19&type=Issues)
2525

26-
2726
### 3.2.0 - 2021-11-29
2827

2928
#### New features added
@@ -110,7 +109,7 @@
110109

111110
#### Bugs fixed
112111

113-
* Include jupyterlab-server-proxy in the sdist [#260](https://github.com/jupyterhub/jupyter-server-proxy/pull/260) ([@xhochy](https://github.com/xhochy))
112+
- Include jupyterlab-server-proxy in the sdist [#260](https://github.com/jupyterhub/jupyter-server-proxy/pull/260) ([@xhochy](https://github.com/xhochy))
114113

115114
#### Contributors to this release
116115

@@ -120,7 +119,7 @@
120119

121120
#### Bugs fixed
122121

123-
* Fix PyPI url [#259](https://github.com/jupyterhub/jupyter-server-proxy/pull/259) ([@janjagusch](https://github.com/janjagusch))
122+
- Fix PyPI url [#259](https://github.com/jupyterhub/jupyter-server-proxy/pull/259) ([@janjagusch](https://github.com/janjagusch))
124123

125124
#### Contributors to this release
126125

@@ -138,19 +137,19 @@ version jumps from 2.1.2 to 3.0.0.
138137

139138
#### Enhancements made
140139

141-
* Package jupyter lab extension [#245](https://github.com/jupyterhub/jupyter-server-proxy/pull/245) ([@janjagusch](https://github.com/janjagusch))
140+
- Package jupyter lab extension [#245](https://github.com/jupyterhub/jupyter-server-proxy/pull/245) ([@janjagusch](https://github.com/janjagusch))
142141

143142
#### Maintenance and upkeep improvements
144143

145-
* Breaking: Replace host_whitelist with host_allowlist [#256](https://github.com/jupyterhub/jupyter-server-proxy/pull/256) ([@manics](https://github.com/manics))
146-
* Switch from notebook to jupyter-server [#254](https://github.com/jupyterhub/jupyter-server-proxy/pull/254) ([@manics](https://github.com/manics))
144+
- Breaking: Replace host_whitelist with host_allowlist [#256](https://github.com/jupyterhub/jupyter-server-proxy/pull/256) ([@manics](https://github.com/manics))
145+
- Switch from notebook to jupyter-server [#254](https://github.com/jupyterhub/jupyter-server-proxy/pull/254) ([@manics](https://github.com/manics))
147146

148147
#### Continuous integration improvements
149148

150-
* Move build.yaml into test.yaml [#255](https://github.com/jupyterhub/jupyter-server-proxy/pull/255) ([@manics](https://github.com/manics))
151-
* Fix build.yaml workflow [#249](https://github.com/jupyterhub/jupyter-server-proxy/pull/249) ([@manics](https://github.com/manics))
152-
* Add publish PyPI and NPM workflow [#247](https://github.com/jupyterhub/jupyter-server-proxy/pull/247) ([@manics](https://github.com/manics))
153-
* tests: remove bad test, add new clarifying current behavior [#240](https://github.com/jupyterhub/jupyter-server-proxy/pull/240) ([@consideRatio](https://github.com/consideRatio))
149+
- Move build.yaml into test.yaml [#255](https://github.com/jupyterhub/jupyter-server-proxy/pull/255) ([@manics](https://github.com/manics))
150+
- Fix build.yaml workflow [#249](https://github.com/jupyterhub/jupyter-server-proxy/pull/249) ([@manics](https://github.com/manics))
151+
- Add publish PyPI and NPM workflow [#247](https://github.com/jupyterhub/jupyter-server-proxy/pull/247) ([@manics](https://github.com/manics))
152+
- tests: remove bad test, add new clarifying current behavior [#240](https://github.com/jupyterhub/jupyter-server-proxy/pull/240) ([@consideRatio](https://github.com/consideRatio))
154153

155154
#### Contributors to this release
156155

@@ -170,14 +169,14 @@ extension isn't yet bundled with the python package.
170169

171170
#### Enhancements made
172171

173-
* Add Jupyter Server extension data file (JupyterLab 3 support) [#235](https://github.com/jupyterhub/jupyter-server-proxy/pull/235) ([@jtpio](https://github.com/jtpio))
174-
* Update dependencies to include jupyterlab 3.x.x (JupyterLab 3 support) [#229](https://github.com/jupyterhub/jupyter-server-proxy/pull/229) ([@dipanjank](https://github.com/dipanjank))
172+
- Add Jupyter Server extension data file (JupyterLab 3 support) [#235](https://github.com/jupyterhub/jupyter-server-proxy/pull/235) ([@jtpio](https://github.com/jtpio))
173+
- Update dependencies to include jupyterlab 3.x.x (JupyterLab 3 support) [#229](https://github.com/jupyterhub/jupyter-server-proxy/pull/229) ([@dipanjank](https://github.com/dipanjank))
175174

176175
#### Documentation improvements
177176

178-
* Bump to 1.6.0 (setup.py) and add CHANGELOG.md [#238](https://github.com/jupyterhub/jupyter-server-proxy/pull/238) ([@consideRatio](https://github.com/consideRatio))
179-
* Replace server-process list with linkable headings [#236](https://github.com/jupyterhub/jupyter-server-proxy/pull/236) ([@manics](https://github.com/manics))
180-
* Rename the mamba-navigator example to gator in the documentation [#234](https://github.com/jupyterhub/jupyter-server-proxy/pull/234) ([@jtpio](https://github.com/jtpio))
177+
- Bump to 1.6.0 (setup.py) and add CHANGELOG.md [#238](https://github.com/jupyterhub/jupyter-server-proxy/pull/238) ([@consideRatio](https://github.com/consideRatio))
178+
- Replace server-process list with linkable headings [#236](https://github.com/jupyterhub/jupyter-server-proxy/pull/236) ([@manics](https://github.com/manics))
179+
- Rename the mamba-navigator example to gator in the documentation [#234](https://github.com/jupyterhub/jupyter-server-proxy/pull/234) ([@jtpio](https://github.com/jtpio))
181180

182181
#### Contributors to this release
183182

docs/source/conf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#
55
import datetime
66

7-
87
# -- Project information -----------------------------------------------------
98
# ref: https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
109
#

docs/source/convenience/new.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ named after your project with a python package. From there, you should:
1919
process, any environment variables, and title of the launcher icon
2020

2121
#. (Optionally) Add a square svg icon for your launcher in the ``icons``
22-
subfolder, with the same name as your project.
22+
subfolder, with the same name as your project.

jupyter_server_proxy/__init__.py

Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,43 @@
1-
from .handlers import setup_handlers
2-
from .config import ServerProxy as ServerProxyConfig, make_handlers, get_entrypoint_server_processes, make_server_process
31
from jupyter_server.utils import url_path_join as ujoin
4-
from .api import ServersInfoHandler, IconHandler
2+
3+
from .api import IconHandler, ServersInfoHandler
4+
from .config import ServerProxy as ServerProxyConfig
5+
from .config import get_entrypoint_server_processes, make_handlers, make_server_process
6+
from .handlers import setup_handlers
7+
58

69
# Jupyter Extension points
710
def _jupyter_server_extension_points():
8-
return [{
9-
'module': 'jupyter_server_proxy',
10-
}]
11+
return [
12+
{
13+
"module": "jupyter_server_proxy",
14+
}
15+
]
16+
1117

1218
def _jupyter_nbextension_paths():
13-
return [{
14-
"section": "tree",
15-
"dest": "jupyter_server_proxy",
16-
'src': 'static',
17-
"require": "jupyter_server_proxy/tree"
18-
}]
19+
return [
20+
{
21+
"section": "tree",
22+
"dest": "jupyter_server_proxy",
23+
"src": "static",
24+
"require": "jupyter_server_proxy/tree",
25+
}
26+
]
27+
1928

2029
def _jupyter_labextension_paths():
21-
return [{
22-
"src": "labextension",
23-
"dest": "@jupyterhub/jupyter-server-proxy",
24-
}]
30+
return [
31+
{
32+
"src": "labextension",
33+
"dest": "@jupyterhub/jupyter-server-proxy",
34+
}
35+
]
2536

2637

2738
def _load_jupyter_server_extension(nbapp):
2839
# Set up handlers picked up via config
29-
base_url = nbapp.web_app.settings['base_url']
40+
base_url = nbapp.web_app.settings["base_url"]
3041
serverproxy_config = ServerProxyConfig(parent=nbapp)
3142

3243
server_processes = [
@@ -35,7 +46,7 @@ def _load_jupyter_server_extension(nbapp):
3546
]
3647
server_processes += get_entrypoint_server_processes(serverproxy_config)
3748
server_handlers = make_handlers(base_url, server_processes)
38-
nbapp.web_app.add_handlers('.*', server_handlers)
49+
nbapp.web_app.add_handlers(".*", server_handlers)
3950

4051
# Set up default non-server handler
4152
setup_handlers(
@@ -48,10 +59,17 @@ def _load_jupyter_server_extension(nbapp):
4859
if sp.launcher_entry.enabled and sp.launcher_entry.icon_path:
4960
icons[sp.name] = sp.launcher_entry.icon_path
5061

51-
nbapp.web_app.add_handlers('.*', [
52-
(ujoin(base_url, 'server-proxy/servers-info'), ServersInfoHandler, {'server_processes': server_processes}),
53-
(ujoin(base_url, 'server-proxy/icon/(.*)'), IconHandler, {'icons': icons}),
54-
])
62+
nbapp.web_app.add_handlers(
63+
".*",
64+
[
65+
(
66+
ujoin(base_url, "server-proxy/servers-info"),
67+
ServersInfoHandler,
68+
{"server_processes": server_processes},
69+
),
70+
(ujoin(base_url, "server-proxy/icon/(.*)"), IconHandler, {"icons": icons}),
71+
],
72+
)
5573

5674

5775
# For backward compatibility

jupyter_server_proxy/api.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
from tornado import web
21
import mimetypes
2+
33
from jupyter_server.base.handlers import JupyterHandler
44
from jupyter_server.utils import url_path_join as ujoin
5-
from collections import namedtuple
5+
from tornado import web
6+
67

78
class ServersInfoHandler(JupyterHandler):
89
def initialize(self, server_processes):
@@ -16,28 +17,29 @@ async def get(self):
1617
for sp in self.server_processes:
1718
# Manually recurse to convert namedtuples into JSONable structures
1819
item = {
19-
'name': sp.name,
20-
'launcher_entry': {
21-
'enabled': sp.launcher_entry.enabled,
22-
'title': sp.launcher_entry.title,
23-
'path_info': sp.launcher_entry.path_info
20+
"name": sp.name,
21+
"launcher_entry": {
22+
"enabled": sp.launcher_entry.enabled,
23+
"title": sp.launcher_entry.title,
24+
"path_info": sp.launcher_entry.path_info,
2425
},
25-
'new_browser_tab' : sp.new_browser_tab
26+
"new_browser_tab": sp.new_browser_tab,
2627
}
2728
if sp.launcher_entry.icon_path:
28-
icon_url = ujoin(self.base_url, 'server-proxy', 'icon', sp.name)
29-
item['launcher_entry']['icon_url'] = icon_url
29+
icon_url = ujoin(self.base_url, "server-proxy", "icon", sp.name)
30+
item["launcher_entry"]["icon_url"] = icon_url
3031

3132
data.append(item)
3233

33-
self.write({'server_processes': data})
34+
self.write({"server_processes": data})
3435

3536

3637
# FIXME: Should be a StaticFileHandler subclass
3738
class IconHandler(JupyterHandler):
3839
"""
3940
Serve launcher icons
4041
"""
42+
4143
def initialize(self, icons):
4244
"""
4345
icons is a dict of titles to paths
@@ -67,4 +69,4 @@ async def get(self, name):
6769

6870
with open(self.icons[name]) as f:
6971
self.write(f.read())
70-
self.set_header('Content-Type', content_type)
72+
self.set_header("Content-Type", content_type)

0 commit comments

Comments
 (0)