Skip to content

Commit c79b6e3

Browse files
authored
Adapt to level config to match other Jupyter repos (#237)
1 parent 3451732 commit c79b6e3

18 files changed

+408
-180
lines changed

.github/dependabot.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: 2
2+
updates:
3+
# GitHub Actions
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
# Python
9+
- package-ecosystem: "pip"
10+
directory: "/"
11+
schedule:
12+
interval: "weekly"

.github/workflows/tests.yml

+24-27
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
name: tests
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
schedule:
8+
- cron: "0 8 * * *"
49

510
jobs:
6-
711
pre-commit:
812
runs-on: ubuntu-latest
913
steps:
10-
- uses: actions/checkout@v4
11-
- uses: actions/setup-python@v3
12-
with:
13-
python-version: 3.8
14-
- uses: pre-commit/[email protected]
14+
- uses: actions/checkout@v4
15+
- uses: actions/setup-python@v3
16+
with:
17+
python-version: "3.10"
18+
- uses: pre-commit/[email protected]
1519

1620
tests:
17-
1821
strategy:
1922
matrix:
2023
python-version: ["3.8", "3.9", "3.10", "3.11", " 3.12"]
@@ -28,21 +31,18 @@ jobs:
2831
runs-on: ${{ matrix.os }}
2932

3033
steps:
31-
- uses: actions/checkout@v4
32-
- name: Set up Python ${{ matrix.python-version }}
33-
uses: actions/setup-python@v3
34-
with:
35-
python-version: ${{ matrix.python-version }}
34+
- uses: actions/checkout@v4
35+
- name: Set up Python ${{ matrix.python-version }}
36+
uses: actions/setup-python@v3
37+
with:
38+
python-version: ${{ matrix.python-version }}
3639

37-
- name: Install dependencies
38-
run: |
39-
python -m pip install --upgrade pip
40-
pip install -r requirements.txt
41-
python -m bash_kernel.install # For testing a non-standard kernel
42-
pip install .
40+
- name: Install dependencies
41+
run: |
42+
python -m pip install --upgrade pip hatch
4343
44-
- name: Run tests
45-
run: pytest
44+
- name: Run tests
45+
run: hatch run test:test -x
4646

4747
docs:
4848
runs-on: ubuntu-latest
@@ -51,16 +51,13 @@ jobs:
5151
- uses: actions/setup-python@v3
5252
- name: Install dependencies
5353
run: |
54-
python -m pip install --upgrade pip
55-
pip install -r requirements.txt
56-
pip install .
54+
python -m pip install --upgrade pip hatch
55+
5756
- name: Build docs
5857
run: |
59-
cd doc
60-
make html-strict
58+
hatch run doc:build
6159
6260
publish:
63-
6461
name: Publish to PyPi
6562
needs: [tests]
6663
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.tox/
1+
.venv
22
*.py[cod]
33

44
# Packages

.pre-commit-config.yaml

+69-17
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,76 @@
1+
ci:
2+
autoupdate_schedule: monthly
3+
autoupdate_commit_msg: "chore: update pre-commit hooks"
4+
15
repos:
2-
- repo: "https://github.com/pre-commit/pre-commit-hooks"
3-
rev: v4.3.0
6+
- repo: https://github.com/pre-commit/pre-commit-hooks
7+
rev: v4.5.0
48
hooks:
5-
- id: trailing-whitespace
9+
- id: check-case-conflict
10+
- id: check-ast
11+
- id: check-docstring-first
12+
- id: check-executables-have-shebangs
13+
- id: check-added-large-files
14+
- id: check-case-conflict
15+
- id: check-merge-conflict
16+
- id: check-json
17+
- id: check-toml
18+
- id: check-yaml
19+
- id: debug-statements
620
- id: end-of-file-fixer
7-
- repo: "https://github.com/pycqa/flake8/"
8-
rev: 3.9.2
21+
- id: trailing-whitespace
22+
23+
- repo: https://github.com/python-jsonschema/check-jsonschema
24+
rev: 0.27.1
25+
hooks:
26+
- id: check-github-workflows
27+
28+
- repo: https://github.com/executablebooks/mdformat
29+
rev: 0.7.17
30+
hooks:
31+
- id: mdformat
32+
33+
- repo: https://github.com/pre-commit/mirrors-prettier
34+
rev: "v3.0.3"
35+
hooks:
36+
- id: prettier
37+
types_or: [yaml, html, json]
38+
39+
- repo: https://github.com/adamchainz/blacken-docs
40+
rev: "1.16.0"
41+
hooks:
42+
- id: blacken-docs
43+
additional_dependencies: [black==23.7.0]
44+
exclude: |
45+
(?x)^(
46+
doc/source/index.rst|
47+
tests/test_execute.py
48+
)$(|)
49+
50+
- repo: https://github.com/codespell-project/codespell
51+
rev: "v2.2.6"
952
hooks:
10-
- id: flake8
11-
- repo: "https://github.com/ambv/black"
12-
rev: 22.3.0
53+
- id: codespell
54+
args: ["-L", "sur,nd"]
55+
56+
- repo: https://github.com/pre-commit/pygrep-hooks
57+
rev: "v1.10.0"
1358
hooks:
14-
- id: black
15-
language_version: python3
16-
- repo: "https://github.com/PyCQA/isort"
17-
rev: 5.12.0
59+
- id: rst-backticks
60+
- id: rst-directive-colons
61+
- id: rst-inline-touching-normal
62+
63+
- repo: https://github.com/astral-sh/ruff-pre-commit
64+
rev: v0.1.5
1865
hooks:
19-
- id: isort
20-
- repo: https://github.com/asottile/pyupgrade
21-
rev: v2.34.0
66+
- id: ruff
67+
types_or: [python, jupyter]
68+
args: ["--fix", "--show-fixes"]
69+
- id: ruff-format
70+
types_or: [python, jupyter]
71+
72+
- repo: https://github.com/scientific-python/cookie
73+
rev: "2023.10.27"
2274
hooks:
23-
- id: pyupgrade
24-
args: ["--py36-plus"]
75+
- id: sp-repo-review
76+
additional_dependencies: ["repo-review[cli]"]

.readthedocs.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,8 @@ sphinx:
77
configuration: doc/source/conf.py
88
python:
99
install:
10-
- requirements: requirements.txt
10+
# install itself with pip install .
11+
- method: pip
12+
path: .
13+
extra_requirements:
14+
- doc

CONTRIBUTING.md

+138
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# General Jupyter contributor guidelines
2+
3+
If you're reading this section, you're probably interested in
4+
contributing to Jupyter. Welcome and thanks for your interest in
5+
contributing!
6+
7+
Please take a look at the Contributor documentation, familiarize
8+
yourself with using the Jupyter Server, and introduce yourself on the
9+
mailing list and share what area of the project you are interested in
10+
working on.
11+
12+
For general documentation about contributing to Jupyter projects, see
13+
the [Project Jupyter Contributor
14+
Documentation](https://jupyter.readthedocs.io/en/latest/contributing/content-contributor.html).
15+
16+
# Setting Up a Development Environment
17+
18+
## Installing the Jupyter Server
19+
20+
The development version of the server requires
21+
[node](https://nodejs.org/en/download/) and
22+
[pip](https://pip.pypa.io/en/stable/installing/).
23+
24+
Once you have installed the dependencies mentioned above, use the
25+
following steps:
26+
27+
```
28+
pip install --upgrade pip
29+
git clone https://github.com/jupyter/jupyter-sphinx
30+
cd jupyter-server
31+
pip install -e ".[test]"
32+
```
33+
34+
## Code Styling and Quality Checks
35+
36+
`jupyter-sphinx` has adopted automatic code formatting so you shouldn't
37+
need to worry too much about your code style. As long as your code is
38+
valid, the pre-commit hook should take care of how it should look.
39+
`pre-commit` and its associated hooks will automatically be installed
40+
when you run `pip install -e ".[test]"`
41+
42+
To install `pre-commit` hook manually, run the following:
43+
44+
```
45+
pre-commit install
46+
```
47+
48+
You can invoke the pre-commit hook by hand at any time with:
49+
50+
```
51+
pre-commit run
52+
```
53+
54+
which should run any autoformatting on your code and tell you about any
55+
errors it couldn't fix automatically. You may also install [black
56+
integration](https://github.com/psf/black#editor-integration) into your
57+
text editor to format code automatically.
58+
59+
If you have already committed files before setting up the pre-commit
60+
hook with `pre-commit install`, you can fix everything up using
61+
`pre-commit run --all-files`. You need to make the fixing commit
62+
yourself after that.
63+
64+
Some of the hooks only run on CI by default, but you can invoke them by
65+
running with the `--hook-stage manual` argument.
66+
67+
There are three hatch scripts that can be run locally as well:
68+
`hatch run lint:build` will enforce styling.
69+
70+
# Running Tests
71+
72+
Install dependencies:
73+
74+
```
75+
pip install -e .[test]
76+
```
77+
78+
To run the Python tests, use:
79+
80+
```
81+
pytest
82+
```
83+
84+
You can also run the tests using `hatch` without installing test
85+
dependencies in your local environment:
86+
87+
```
88+
pip install hatch
89+
hatch run test:test
90+
```
91+
92+
The command takes any argument that you can give to `pytest`, e.g.:
93+
94+
```
95+
hatch run test:test -k name_of_method_to_test
96+
```
97+
98+
You can also drop into a shell in the test environment by running:
99+
100+
```
101+
hatch -e test shell
102+
```
103+
104+
# Building the Docs
105+
106+
Install the docs requirements using `pip`:
107+
108+
```
109+
pip install .[doc]
110+
```
111+
112+
Once you have installed the required packages, you can build the docs
113+
with:
114+
115+
```
116+
cd docs
117+
make html
118+
```
119+
120+
You can also run the tests using `hatch` without installing test
121+
dependencies in your local environment.
122+
123+
```bash
124+
pip install hatch
125+
hatch run docs:build
126+
```
127+
128+
You can also drop into a shell in the docs environment by running:
129+
130+
```
131+
hatch -e docs shell
132+
```
133+
134+
After that, the generated HTML files will be available at
135+
`build/html/index.html`. You may view the docs in your browser.
136+
137+
You should also have a look at the [Project Jupyter Documentation
138+
Guide](https://jupyter.readthedocs.io/en/latest/contributing/content-contributor.html).

MANIFEST.in

-2
This file was deleted.

README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Jupyter Sphinx Extensions
22

3-
``jupyter-sphinx`` enables running code embedded in Sphinx documentation and
3+
`jupyter-sphinx` enables running code embedded in Sphinx documentation and
44
embedding output of that code into the resulting document. It has support
55
for rich output such as images and even Jupyter interactive widgets.
66

@@ -23,7 +23,6 @@ conda install jupyter_sphinx -c conda-forge
2323
You can check out the documentation on https://jupyter-sphinx.readthedocs.io for up to date
2424
usage information and examples.
2525

26-
2726
## License
2827

2928
We use a shared copyright model that enables all contributors to maintain the

0 commit comments

Comments
 (0)