Skip to content

Commit

Permalink
Merge pull request #390 from consideRatio/pr/pre-commit
Browse files Browse the repository at this point in the history
pre-commit: add config and small fixes
  • Loading branch information
yuvipanda authored Apr 11, 2023
2 parents 230c069 + 8884d8b commit 3dde433
Show file tree
Hide file tree
Showing 33 changed files with 888 additions and 625 deletions.
12 changes: 12 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# flake8 is used for linting Python code setup to automatically run with
# pre-commit.
#
# ref: https://flake8.pycqa.org/en/latest/user/configuration.html
#

[flake8]
# E: style errors
# W: style warnings
# C: complexity
# D: docstring warnings (unused pydocstyle extension)
ignore = E, C, W, D
74 changes: 74 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# pre-commit is a tool to perform a predefined set of tasks manually and/or
# automatically before git commits are made.
#
# Config reference: https://pre-commit.com/#pre-commit-configyaml---top-level
#
# Common tasks
#
# - Run on all files: pre-commit run --all-files
# - Register git hooks: pre-commit install --install-hooks
#
repos:
# Autoformat: Python code, syntax patterns are modernized
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
- id: pyupgrade
args:
- --py38-plus

# Autoformat: Python code
- repo: https://github.com/PyCQA/autoflake
rev: v2.0.2
hooks:
- id: autoflake
# args ref: https://github.com/PyCQA/autoflake#advanced-usage
args:
- --in-place

# Autoformat: Python code
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort

# Autoformat: Python code
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
exclude: "contrib\/template\/.*"

# Autoformat: markdown, yaml
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0-alpha.6
hooks:
- id: prettier

# Misc...
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
# ref: https://github.com/pre-commit/pre-commit-hooks#hooks-available
hooks:
# Autoformat: Makes sure files end in a newline and only a newline.
- id: end-of-file-fixer

# Autoformat: Sorts entries in requirements.txt.
- id: requirements-txt-fixer

# Lint: Check for files with names that would conflict on a
# case-insensitive filesystem like MacOS HFS+ or Windows FAT.
- id: check-case-conflict

# Lint: Checks that non-binary executables have a proper shebang.
- id: check-executables-have-shebangs

# Lint: Python code
- repo: https://github.com/PyCQA/flake8
rev: "6.0.0"
hooks:
- id: flake8

# pre-commit.ci config reference: https://pre-commit.ci/#configuration
ci:
autoupdate_schedule: monthly
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ jlpm run watch
jupyter lab
```

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

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

```bash
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ Jupyter Server within a container and only allow network access to the Jupyter
Server via the container.

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

### Requirements

* `jupyterlab>=2` or `notebook`
- `jupyterlab>=2` or `notebook`

### Python package

Expand Down
24 changes: 13 additions & 11 deletions contrib/code-server-traitlet/jupyter_notebook_config.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# load the config object for traitlets based configuration
c = get_config() # noqa


c.ServerProxy.servers = {
'code-server': {
'command': [
'code-server',
'--auth=none',
'--disable-telemetry',
'--bind-addr=localhost:{port}'
],
'timeout': 20,
'launcher_entry': {
'title': 'VS Code'
"code-server": {
"command": [
"code-server",
"--auth=none",
"--disable-telemetry",
"--bind-addr=localhost:{port}",
],
"timeout": 20,
"launcher_entry": {"title": "VS Code"},
}
}
}
6 changes: 3 additions & 3 deletions contrib/template/cookiecutter.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"project_name": "",
"author_name": "Project Jupyter Contributors",
"author_email": "[email protected]"
"project_name": "",
"author_name": "Project Jupyter Contributors",
"author_email": "[email protected]"
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""
import os


def setup_{{cookiecutter.project_name}}():
return {
'command': [],
Expand Down
23 changes: 12 additions & 11 deletions contrib/theia/jupyter_theia_proxy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,22 @@
import os
import shutil


def setup_theia():
# Make sure theia is in $PATH
def _theia_command(port):
full_path = shutil.which('theia')
full_path = shutil.which("theia")
if not full_path:
raise FileNotFoundError('Can not find theia executable in $PATH')
return ['theia', 'start', '.', '--hostname=127.0.0.1', '--port=' + str(port)]
raise FileNotFoundError("Can not find theia executable in $PATH")
return ["theia", "start", ".", "--hostname=127.0.0.1", "--port=" + str(port)]

return {
'command': _theia_command,
'environment': {
'USE_LOCAL_GIT': 'true'
"command": _theia_command,
"environment": {"USE_LOCAL_GIT": "true"},
"launcher_entry": {
"title": "Theia IDE",
"icon_path": os.path.join(
os.path.dirname(os.path.abspath(__file__)), "icons", "theia.svg"
),
},
'launcher_entry': {
'title': 'Theia IDE',
'icon_path': os.path.join(os.path.dirname(os.path.abspath(__file__)), 'icons', 'theia.svg')
}
}
}
16 changes: 7 additions & 9 deletions contrib/theia/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,20 @@

setuptools.setup(
name="jupyter-theia-proxy",
version='1.0dev',
version="1.0dev",
url="https://github.com/jupyterhub/jupyter-server-proxy/tree/HEAD/contrib/theia",
author="Project Jupyter Contributors",
description="[email protected]",
packages=setuptools.find_packages(),
keywords=['Jupyter'],
classifiers=['Framework :: Jupyter'],
install_requires=[
'jupyter-server-proxy'
],
keywords=["Jupyter"],
classifiers=["Framework :: Jupyter"],
install_requires=["jupyter-server-proxy"],
entry_points={
'jupyter_serverproxy_servers': [
'theia = jupyter_theia_proxy:setup_theia',
"jupyter_serverproxy_servers": [
"theia = jupyter_theia_proxy:setup_theia",
]
},
package_data={
'jupyter_theia_proxy': ['icons/*'],
"jupyter_theia_proxy": ["icons/*"],
},
)
2 changes: 1 addition & 1 deletion docs/source/arbitrary-ports-hosts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,4 @@ accessing it from a classic notebook extension.
// Construct URL of our proxied service
let service_url = base_url + 'proxy/' + port;
// Do stuff with your service_url
// Do stuff with your service_url
29 changes: 14 additions & 15 deletions docs/source/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

[@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)


### 3.2.0 - 2021-11-29

#### New features added
Expand Down Expand Up @@ -110,7 +109,7 @@

#### Bugs fixed

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

#### Contributors to this release

Expand All @@ -120,7 +119,7 @@

#### Bugs fixed

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

#### Contributors to this release

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

#### Enhancements made

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

#### Maintenance and upkeep improvements

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

#### Continuous integration improvements

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

#### Contributors to this release

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

#### Enhancements made

* Add Jupyter Server extension data file (JupyterLab 3 support) [#235](https://github.com/jupyterhub/jupyter-server-proxy/pull/235) ([@jtpio](https://github.com/jtpio))
* 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))
- Add Jupyter Server extension data file (JupyterLab 3 support) [#235](https://github.com/jupyterhub/jupyter-server-proxy/pull/235) ([@jtpio](https://github.com/jtpio))
- 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))

#### Documentation improvements

* 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))
* Replace server-process list with linkable headings [#236](https://github.com/jupyterhub/jupyter-server-proxy/pull/236) ([@manics](https://github.com/manics))
* 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))
- 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))
- Replace server-process list with linkable headings [#236](https://github.com/jupyterhub/jupyter-server-proxy/pull/236) ([@manics](https://github.com/manics))
- 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))

#### Contributors to this release

Expand Down
1 change: 0 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#
import datetime


# -- Project information -----------------------------------------------------
# ref: https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
#
Expand Down
2 changes: 1 addition & 1 deletion docs/source/convenience/new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ named after your project with a python package. From there, you should:
process, any environment variables, and title of the launcher icon

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

0 comments on commit 3dde433

Please sign in to comment.