Skip to content

Commit 3dde433

Browse files
authored
Merge pull request #390 from consideRatio/pr/pre-commit
pre-commit: add config and small fixes
2 parents 230c069 + 8884d8b commit 3dde433

File tree

33 files changed

+888
-625
lines changed

33 files changed

+888
-625
lines changed

.flake8

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# flake8 is used for linting Python code setup to automatically run with
2+
# pre-commit.
3+
#
4+
# ref: https://flake8.pycqa.org/en/latest/user/configuration.html
5+
#
6+
7+
[flake8]
8+
# E: style errors
9+
# W: style warnings
10+
# C: complexity
11+
# D: docstring warnings (unused pydocstyle extension)
12+
ignore = E, C, W, D

.pre-commit-config.yaml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# pre-commit is a tool to perform a predefined set of tasks manually and/or
2+
# automatically before git commits are made.
3+
#
4+
# Config reference: https://pre-commit.com/#pre-commit-configyaml---top-level
5+
#
6+
# Common tasks
7+
#
8+
# - Run on all files: pre-commit run --all-files
9+
# - Register git hooks: pre-commit install --install-hooks
10+
#
11+
repos:
12+
# Autoformat: Python code, syntax patterns are modernized
13+
- repo: https://github.com/asottile/pyupgrade
14+
rev: v3.3.1
15+
hooks:
16+
- id: pyupgrade
17+
args:
18+
- --py38-plus
19+
20+
# Autoformat: Python code
21+
- repo: https://github.com/PyCQA/autoflake
22+
rev: v2.0.2
23+
hooks:
24+
- id: autoflake
25+
# args ref: https://github.com/PyCQA/autoflake#advanced-usage
26+
args:
27+
- --in-place
28+
29+
# Autoformat: Python code
30+
- repo: https://github.com/pycqa/isort
31+
rev: 5.12.0
32+
hooks:
33+
- id: isort
34+
35+
# Autoformat: Python code
36+
- repo: https://github.com/psf/black
37+
rev: 23.3.0
38+
hooks:
39+
- id: black
40+
exclude: "contrib\/template\/.*"
41+
42+
# Autoformat: markdown, yaml
43+
- repo: https://github.com/pre-commit/mirrors-prettier
44+
rev: v3.0.0-alpha.6
45+
hooks:
46+
- id: prettier
47+
48+
# Misc...
49+
- repo: https://github.com/pre-commit/pre-commit-hooks
50+
rev: v4.4.0
51+
# ref: https://github.com/pre-commit/pre-commit-hooks#hooks-available
52+
hooks:
53+
# Autoformat: Makes sure files end in a newline and only a newline.
54+
- id: end-of-file-fixer
55+
56+
# Autoformat: Sorts entries in requirements.txt.
57+
- id: requirements-txt-fixer
58+
59+
# Lint: Check for files with names that would conflict on a
60+
# case-insensitive filesystem like MacOS HFS+ or Windows FAT.
61+
- id: check-case-conflict
62+
63+
# Lint: Checks that non-binary executables have a proper shebang.
64+
- id: check-executables-have-shebangs
65+
66+
# Lint: Python code
67+
- repo: https://github.com/PyCQA/flake8
68+
rev: "6.0.0"
69+
hooks:
70+
- id: flake8
71+
72+
# pre-commit.ci config reference: https://pre-commit.ci/#configuration
73+
ci:
74+
autoupdate_schedule: monthly

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

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1+
# load the config object for traitlets based configuration
2+
c = get_config() # noqa
3+
4+
15
c.ServerProxy.servers = {
2-
'code-server': {
3-
'command': [
4-
'code-server',
5-
'--auth=none',
6-
'--disable-telemetry',
7-
'--bind-addr=localhost:{port}'
8-
],
9-
'timeout': 20,
10-
'launcher_entry': {
11-
'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"},
1215
}
13-
}
1416
}

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.

0 commit comments

Comments
 (0)