Skip to content

Commit 01a4cc5

Browse files
authored
Merge pull request #25 from consideRatio/pr/add-pre-commit
maint: add pre-commit config
2 parents 90adae2 + 9aced4c commit 01a4cc5

File tree

8 files changed

+162
-28
lines changed

8 files changed

+162
-28
lines changed

.flake8

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
# F841: local variable assigned but never used
13+
ignore = E, C, W, D, F841

.pre-commit-config.yaml

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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.0
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.11.4
32+
hooks:
33+
- id: isort
34+
35+
# Autoformat: Python code
36+
- repo: https://github.com/psf/black
37+
rev: 22.12.0
38+
hooks:
39+
- id: black
40+
41+
# Autoformat: markdown, yaml
42+
- repo: https://github.com/pre-commit/mirrors-prettier
43+
rev: v3.0.0-alpha.4
44+
hooks:
45+
- id: prettier
46+
47+
# Misc...
48+
- repo: https://github.com/pre-commit/pre-commit-hooks
49+
rev: v4.4.0
50+
# ref: https://github.com/pre-commit/pre-commit-hooks#hooks-available
51+
hooks:
52+
# Autoformat: Makes sure files end in a newline and only a newline.
53+
- id: end-of-file-fixer
54+
55+
# Autoformat: Sorts entries in requirements.txt.
56+
- id: requirements-txt-fixer
57+
58+
# Lint: Check for files with names that would conflict on a
59+
# case-insensitive filesystem like MacOS HFS+ or Windows FAT.
60+
- id: check-case-conflict
61+
62+
# Lint: Checks that non-binary executables have a proper shebang.
63+
- id: check-executables-have-shebangs
64+
65+
# Lint: Python code
66+
- repo: https://github.com/PyCQA/flake8
67+
rev: "6.0.0"
68+
hooks:
69+
- id: flake8
70+
71+
# Content here is mostly copied from other locations, so lets not make
72+
# formatting changes in it.
73+
exclude: share
74+
75+
# pre-commit.ci config reference: https://pre-commit.ci/#configuration
76+
ci:
77+
autoupdate_schedule: monthly

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
2626
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
2727
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2828
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

MANIFEST.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
graft jupyter_remote_desktop_proxy/share
1+
graft jupyter_remote_desktop_proxy/share

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Jupyter Remote Desktop Proxy
2+
23
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/jupyterhub/jupyter-remote-desktop-proxy/HEAD?urlpath=desktop)
34

45
Run XFCE (or other desktop environments) on Jupyter.
+32-23
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import os
22
import shlex
3-
from shutil import which
43
import tempfile
5-
4+
from shutil import which
65

76
HERE = os.path.dirname(os.path.abspath(__file__))
87

8+
99
def setup_desktop():
1010
# make a secure temporary directory for sockets
1111
# This is only readable, writeable & searchable by our uid
@@ -22,33 +22,42 @@ def setup_desktop():
2222
# Use bundled tigervnc
2323
vnc_args = [
2424
os.path.join(HERE, 'share/tigervnc/bin/vncserver'),
25-
'-rfbunixpath', sockets_path,
26-
]
27-
socket_args = [
28-
'--unix-target', sockets_path
25+
'-rfbunixpath',
26+
sockets_path,
2927
]
28+
socket_args = ['--unix-target', sockets_path]
3029

31-
vnc_command = ' '.join(shlex.quote(p) for p in (vnc_args + [
32-
'-verbose',
33-
'-xstartup', os.path.join(HERE, 'share/xstartup'),
34-
'-geometry', '1680x1050',
35-
'-SecurityTypes', 'None',
36-
'-fg',
37-
':1',
38-
]))
30+
vnc_command = ' '.join(
31+
shlex.quote(p)
32+
for p in (
33+
vnc_args
34+
+ [
35+
'-verbose',
36+
'-xstartup',
37+
os.path.join(HERE, 'share/xstartup'),
38+
'-geometry',
39+
'1680x1050',
40+
'-SecurityTypes',
41+
'None',
42+
'-fg',
43+
':1',
44+
]
45+
)
46+
)
3947
return {
4048
'command': [
41-
'websockify', '-v',
42-
'--web', os.path.join(HERE, 'share/web/noVNC-1.2.0'),
43-
'--heartbeat', '30',
49+
'websockify',
50+
'-v',
51+
'--web',
52+
os.path.join(HERE, 'share/web/noVNC-1.2.0'),
53+
'--heartbeat',
54+
'30',
4455
'5901',
45-
] + socket_args + [
46-
'--',
47-
'/bin/sh', '-c',
48-
f'cd {os.getcwd()} && {vnc_command}'
49-
],
56+
]
57+
+ socket_args
58+
+ ['--', '/bin/sh', '-c', f'cd {os.getcwd()} && {vnc_command}'],
5059
'port': 5901,
5160
'timeout': 30,
5261
'mappath': {'/': '/vnc_lite.html'},
53-
'new_browser_window': True
62+
'new_browser_window': True,
5463
}

pyproject.toml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# autoflake is used for autoformatting Python code
2+
#
3+
# ref: https://github.com/PyCQA/autoflake#readme
4+
#
5+
[tool.autoflake]
6+
ignore-init-module-imports = true
7+
remove-all-unused-imports = true
8+
remove-duplicate-keys = true
9+
remove-unused-variables = true
10+
11+
12+
# isort is used for autoformatting Python code
13+
#
14+
# ref: https://pycqa.github.io/isort/
15+
#
16+
[tool.isort]
17+
profile = "black"
18+
19+
20+
# black is used for autoformatting Python code
21+
#
22+
# ref: https://black.readthedocs.io/en/stable/
23+
#
24+
[tool.black]
25+
skip-string-normalization = true
26+
# target-version should be all supported versions, see
27+
# https://github.com/psf/black/issues/751#issuecomment-473066811
28+
target_version = [
29+
"py36",
30+
"py37",
31+
"py38",
32+
"py39",
33+
"py310",
34+
"py311",
35+
]

setup.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
from setuptools import setup, find_packages
2-
1+
from setuptools import find_packages, setup
32

43
with open("README.md") as f:
54
readme = f.read()
@@ -40,5 +39,5 @@
4039
},
4140
python_requires=">=3.6",
4241
url="https://jupyter.org",
43-
zip_safe=False
42+
zip_safe=False,
4443
)

0 commit comments

Comments
 (0)