Skip to content

Commit 920f0a5

Browse files
authored
Add initial pre-commit (#256)
1 parent 44b13b6 commit 920f0a5

File tree

16 files changed

+124
-12
lines changed

16 files changed

+124
-12
lines changed

.pre-commit-config.yaml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
ci:
2+
skip: [check-jsonschema]
3+
4+
repos:
5+
- repo: https://github.com/pre-commit/pre-commit-hooks
6+
rev: v4.1.0
7+
hooks:
8+
- id: end-of-file-fixer
9+
- id: check-case-conflict
10+
- id: check-executables-have-shebangs
11+
- id: requirements-txt-fixer
12+
- id: check-added-large-files
13+
- id: check-case-conflict
14+
- id: check-toml
15+
- id: check-yaml
16+
- id: debug-statements
17+
- id: forbid-new-submodules
18+
- id: check-builtin-literals
19+
# - id: trailing-whitespace
20+
21+
# - repo: https://github.com/psf/black
22+
# rev: 22.3.0
23+
# hooks:
24+
# - id: black
25+
# args: ["--line-length", "100"]
26+
27+
# - repo: https://github.com/PyCQA/isort
28+
# rev: 5.10.1
29+
# hooks:
30+
# - id: isort
31+
# files: \.py$
32+
# args: [--profile=black]
33+
34+
# - repo: https://github.com/pre-commit/mirrors-prettier
35+
# rev: v2.6.1
36+
# hooks:
37+
# - id: prettier
38+
39+
# - repo: https://github.com/asottile/pyupgrade
40+
# rev: v2.31.1
41+
# hooks:
42+
# - id: pyupgrade
43+
# args: [--py37-plus]
44+
45+
- repo: https://github.com/PyCQA/doc8
46+
rev: 0.11.0
47+
hooks:
48+
- id: doc8
49+
args: [--max-line-length=200]
50+
51+
# - repo: https://github.com/pycqa/flake8
52+
# rev: 4.0.1
53+
# hooks:
54+
# - id: flake8
55+
# additional_dependencies:
56+
# [
57+
# "flake8-bugbear==20.1.4",
58+
# "flake8-logging-format==0.6.0",
59+
# "flake8-implicit-str-concat==0.2.0",
60+
# ]
61+
62+
- repo: https://github.com/sirosen/check-jsonschema
63+
rev: 0.14.1
64+
hooks:
65+
- id: check-jsonschema
66+
name: "Check GitHub Workflows"
67+
files: ^\.github/workflows/
68+
types: [yaml]
69+
args: ["--schemafile", "https://json.schemastore.org/github-workflow"]

CONTRIBUTING.md

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,63 @@
1-
# Development Install
1+
# Contributing
2+
3+
If you're reading this section, you're probably interested in contributing to
4+
Jupyter. Welcome and thanks for your interest in contributing!
5+
6+
Please take a look at the Contributor documentation, familiarize yourself with
7+
using the Jupyter Server, and introduce yourself on the mailing list and
8+
share what area of the project you are interested in working on.
9+
10+
For general documentation about contributing to Jupyter projects, see the
11+
[Project Jupyter Contributor Documentation](https://jupyter.readthedocs.io/en/latest/contributing/content-contributor.html).
12+
13+
## Development Install
214

315
``` shell
416
git clone https://github.com/jupyterlab/jupyterlab_server.git
517
cd jupyterlab_server
618
pip install -e .
719
```
820

9-
# Testing
21+
## Testing
1022

1123
It is probably best to create a virtual environment to create a local test setup. There are multiple tools for creating a Python virtual environment out there from which you can choose the one you like best.
1224

1325
To create a local test setup run the following commands (inside your virtual environment, if you chose to create one):
1426

15-
``` shell
27+
```shell
1628
git clone https://github.com/jupyterlab/jupyterlab_server.git
1729
cd jupyterlab_server
1830
pip install -e .[test] # install test dependencies
1931
pytest --pyargs jupyterlab_server
2032
```
33+
34+
## Code Styling
35+
`jupyterlab_server` has adopted automatic code formatting so you shouldn't
36+
need to worry too much about your code style.
37+
As long as your code is valid,
38+
the pre-commit hook should take care of how it should look.
39+
`pre-commit` and its associated hooks will automatically be installed when
40+
you run `pip install -e ".[test]"`
41+
42+
To install `pre-commit` manually, run the following::
43+
44+
```shell
45+
pip install pre-commit
46+
pre-commit install
47+
```
48+
49+
You can invoke the pre-commit hook by hand at any time with:
50+
51+
```shell
52+
pre-commit run
53+
````
54+
55+
which should run any autoformatting on your code
56+
and tell you about any errors it couldn't fix automatically.
57+
You may also install [black integration](https://github.com/psf/black#editor-integration)
58+
into your text editor to format code automatically.
59+
60+
If you have already committed files before setting up the pre-commit
61+
hook with `pre-commit install`, you can fix everything up using
62+
`pre-commit run --all-files`. You need to make the fixing commit
63+
yourself after that.

jupyterlab_server/config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def get_package_url(data):
3939
def get_federated_extensions(labextensions_path):
4040
"""Get the metadata about federated extensions
4141
"""
42-
federated_extensions = dict()
42+
federated_extensions = {}
4343
for ext_dir in labextensions_path:
4444
# extensions are either top-level directories, or two-deep in @org directories
4545
for ext_path in chain(iglob(pjoin(ext_dir, '[!@]*', 'package.json')),
@@ -106,7 +106,7 @@ def get_page_config(labextensions_path, app_settings_dir=None, logger=None):
106106
recursive_update(page_config, static_page_config)
107107

108108
# Handle federated extensions that disable other extensions
109-
disabled_by_extensions_all = dict()
109+
disabled_by_extensions_all = {}
110110
extensions = page_config['federated_extensions'] = []
111111

112112
federated_exts = get_federated_extensions(labextensions_path)
@@ -153,7 +153,7 @@ def get_page_config(labextensions_path, app_settings_dir=None, logger=None):
153153
if ext_data.get(disabled_key):
154154
disabled_by_extensions_all[ext] = ext_data[disabled_key]
155155

156-
disabled_by_extensions = dict()
156+
disabled_by_extensions = {}
157157
for name in sorted(disabled_by_extensions_all):
158158
# skip if the extension itself is disabled by other config
159159
if page_config[disabled_key].get(name) == True:

jupyterlab_server/handlers.py

100755100644
File mode changed.

jupyterlab_server/process.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,4 +286,4 @@ def _create_process(self, **kwargs):
286286

287287

288288
# Register the cleanup handler.
289-
atexit.register(Process._cleanup)
289+
atexit.register(Process._cleanup)

jupyterlab_server/process_app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def get_command(self):
2121
"""Get the command and kwargs to run with `Process`.
2222
This is intended to be overridden.
2323
"""
24-
return ['python', '--version'], dict()
24+
return ['python', '--version'], {}
2525

2626
def initialize_settings(self):
2727
"""Start the application.

jupyterlab_server/server.py

100755100644
File mode changed.

jupyterlab_server/settings_handler.py

100755100644
File mode changed.

jupyterlab_server/settings_utils.py

100755100644
File mode changed.

jupyterlab_server/test_utils.py

100755100644
File mode changed.

0 commit comments

Comments
 (0)