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": "projectjupyter@gmail.com"
2+
"project_name": "",
3+
"author_name": "Project Jupyter Contributors",
4+
"author_email": "projectjupyter@gmail.com"
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="projectjupyter@gmail.com",
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

0 commit comments

Comments
 (0)