Skip to content

Commit 22475a3

Browse files
authored
Adopt ruff and typing (#6658)
* adopt ruff and typing * reinstate local hooks * fix classifier * fix lint * limit ruff target * fix doc8 test * add integrity check * lint * lint * only use mdformat for changelog * prettier
1 parent 0b99dcc commit 22475a3

18 files changed

+207
-139
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
name: Is this a bug in Notebook? Open an issue.
3-
about: If you're not sure, feel free to post your question on Jupyter's Discourse
3+
about:
4+
If you're not sure, feel free to post your question on Jupyter's Discourse
45
channel.
56

67
labels: bug

.github/dependabot.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
version: 2
22
updates:
3-
# Set update schedule for GitHub Actions
43
- package-ecosystem: "github-actions"
54
directory: "/"
65
schedule:
7-
# Check for updates to GitHub Actions every weekday
6+
interval: "weekly"
7+
- package-ecosystem: "pip"
8+
directory: "/"
9+
schedule:
810
interval: "weekly"

.github/workflows/build.yml

+14-6
Original file line numberDiff line numberDiff line change
@@ -157,22 +157,30 @@ jobs:
157157
with:
158158
ignore_links: "https://playwright.dev/docs/test-cli/ https://blog.jupyter.org/the-big-split-9d7b88a031a7 https://blog.jupyter.org/jupyter-ascending-1bf5b362d97e"
159159

160-
pre_commit:
160+
test_lint:
161+
name: Test Lint
161162
runs-on: ubuntu-latest
162-
timeout-minutes: 10
163163
steps:
164164
- uses: actions/checkout@v3
165165
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
166-
- run: pip install -e .
167-
- uses: jupyterlab/maintainer-tools/.github/actions/pre-commit@v1
168-
166+
- name: Run Linters
167+
run: |
168+
hatch run typing:test
169+
hatch run lint:style
170+
pipx run 'validate-pyproject[all]' pyproject.toml
171+
pipx run doc8 --max-line-length=200 docs/source *.md
172+
npm install -g yarn
173+
yarn
174+
yarn eslint:check
175+
yarn prettier:check
176+
yarn integrity
169177
170178
tests_check: # This job does nothing and is only used for the branch protection
171179
if: always()
172180
needs:
173181
- test
174182
- install
175-
- pre_commit
183+
- test_lint
176184
- test_docs
177185
- test_minimum_versions
178186
- test_prereleases

.pre-commit-config.yaml

+13-42
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
ci:
2+
autoupdate_schedule: monthly
3+
14
repos:
25
- repo: https://github.com/pre-commit/pre-commit-hooks
36
rev: v4.4.0
47
hooks:
5-
- id: forbid-new-submodules
68
- id: end-of-file-fixer
79
- id: check-case-conflict
810
- id: check-executables-have-shebangs
@@ -12,56 +14,25 @@ repos:
1214
- id: check-toml
1315
- id: check-yaml
1416
- id: debug-statements
17+
- id: forbid-new-submodules
1518
- id: check-builtin-literals
1619
- id: trailing-whitespace
17-
exclude: .bumpversion.cfg
20+
21+
- repo: https://github.com/python-jsonschema/check-jsonschema
22+
rev: 0.19.2
23+
hooks:
24+
- id: check-github-workflows
1825

1926
- repo: https://github.com/psf/black
2027
rev: 22.10.0
2128
hooks:
2229
- id: black
23-
args: ["--line-length", "100"]
24-
25-
- repo: https://github.com/PyCQA/isort
26-
rev: 5.10.1
27-
hooks:
28-
- id: isort
29-
files: \.py$
30-
args: [--profile=black]
31-
32-
- repo: https://github.com/PyCQA/doc8
33-
rev: v1.0.0
34-
hooks:
35-
- id: doc8
36-
args: [--max-line-length=200]
37-
stages: [manual]
38-
39-
- repo: https://github.com/abravalheri/validate-pyproject
40-
rev: v0.10.1
41-
hooks:
42-
- id: validate-pyproject
43-
stages: [manual]
44-
45-
- repo: https://github.com/executablebooks/mdformat
46-
rev: 0.7.16
47-
hooks:
48-
- id: mdformat
49-
additional_dependencies:
50-
[mdformat-gfm, mdformat-frontmatter, mdformat-footnote]
5130

52-
- repo: https://github.com/john-hen/Flake8-pyproject
53-
rev: 1.2.2
31+
- repo: https://github.com/charliermarsh/ruff-pre-commit
32+
rev: v0.0.165
5433
hooks:
55-
- id: Flake8-pyproject
56-
alias: flake8
57-
additional_dependencies:
58-
["flake8-bugbear==22.6.22", "flake8-implicit-str-concat==0.2.0"]
59-
stages: [manual]
60-
61-
- repo: https://github.com/python-jsonschema/check-jsonschema
62-
rev: 0.19.2
63-
hooks:
64-
- id: check-github-workflows
34+
- id: ruff
35+
args: ["--fix"]
6536

6637
- repo: local
6738
hooks:

.prettierignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
node_modules
2+
.mypy_cache
3+
.ruff_cache
24
**/node_modules
35
**/lib
46
**/package.json
57
**/static
68
**/labextension
79
build
10+
CHANGELOG.md

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
The Jupyter notebook is a web-based notebook environment for interactive
99
computing.
1010

11-
![Jupyter notebook example](docs/resources/running_code_med.png "Jupyter notebook example")
11+
![Jupyter notebook example](docs/resources/running_code_med.png 'Jupyter notebook example')
1212

1313
## Maintained versions
1414

binder/example.ipynb

+6-2
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@
199199
"outputs": [],
200200
"source": [
201201
"from ipywidgets import IntSlider\n",
202+
"\n",
202203
"slider = IntSlider()\n",
203204
"slider"
204205
]
@@ -228,12 +229,15 @@
228229
"outputs": [],
229230
"source": [
230231
"from IPython.display import Latex\n",
231-
"Latex(r\"\"\"\\begin{eqnarray}\n",
232+
"\n",
233+
"Latex(\n",
234+
" r\"\"\"\\begin{eqnarray}\n",
232235
"\\nabla \\times \\vec{\\mathbf{B}} -\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{E}}}{\\partial t} & = \\frac{4\\pi}{c}\\vec{\\mathbf{j}} \\\\\n",
233236
"\\nabla \\cdot \\vec{\\mathbf{E}} & = 4 \\pi \\rho \\\\\n",
234237
"\\nabla \\times \\vec{\\mathbf{E}}\\, +\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{B}}}{\\partial t} & = \\vec{\\mathbf{0}} \\\\\n",
235238
"\\nabla \\cdot \\vec{\\mathbf{B}} & = 0 \n",
236-
"\\end{eqnarray}\"\"\")"
239+
"\\end{eqnarray}\"\"\"\n",
240+
")"
237241
]
238242
},
239243
{

buildutils/src/release-bump.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ commander
110110

111111
// Bump the version.
112112
let pySpec = spec;
113-
if (spec == 'release') {
113+
if (spec === 'release') {
114114
if (prev.indexOf('a') !== -1) {
115115
pySpec = 'beta';
116116
} else if (prev.indexOf('b') !== -1) {
@@ -120,7 +120,7 @@ commander
120120
} else {
121121
pySpec = 'alpha';
122122
}
123-
} else if (spec == 'build') {
123+
} else if (spec === 'build') {
124124
if (prev.indexOf('a') !== -1) {
125125
pySpec = 'a';
126126
} else if (prev.indexOf('b') !== -1) {

docs/source/conf.py

+15-11
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,23 @@
1212
# All configuration values have a default; values that are commented out
1313
# serve to show the default.
1414

15+
import logging
1516
import os
1617
import shutil
1718
import sys
1819

20+
logger = logging.getLogger(__name__)
21+
logging.basicConfig()
22+
1923
# If extensions (or modules to document with autodoc) are in another directory,
2024
# add these directories to sys.path here. If the directory is relative to the
2125
# documentation root, use os.path.abspath to make it absolute, like shown here.
2226

2327
# DEBUG for RTD
24-
print("DEBUG:: sys.path")
25-
print("================")
28+
logger.info("DEBUG:: sys.path")
29+
logger.info("================")
2630
for item in sys.path:
27-
print(item)
31+
logger.info(item)
2832

2933
# add repo root to sys.path
3034
# here = root/docs/source
@@ -38,15 +42,15 @@
3842
# Copy the contributing file here
3943
shutil.copy(os.path.join(repo_root, "CONTRIBUTING.md"), os.path.join(here, "contributing.md"))
4044

41-
print("repo_root")
42-
print("=====================")
43-
print(repo_root)
45+
logger.info("repo_root")
46+
logger.info("=====================")
47+
logger.info(repo_root)
4448

4549
# DEBUG for post insert on RTD
46-
print("DEBUG:: Post insert to sys.path")
47-
print("===============================")
50+
logger.info("DEBUG:: Post insert to sys.path")
51+
logger.info("===============================")
4852
for item in sys.path:
49-
print(item)
53+
logger.info(item)
5054

5155
# -- General configuration ------------------------------------------------
5256

@@ -86,7 +90,7 @@
8690

8791
# General information about the project.
8892
project = "Jupyter Notebook"
89-
copyright = "2015, Jupyter Team, https://jupyter.org"
93+
copyright = "2015, Jupyter Team, https://jupyter.org" # noqa
9094
author = "The Jupyter Team"
9195

9296
# ghissue config
@@ -98,7 +102,7 @@
98102
#
99103
_version_py = os.path.join(here, "../../notebook/_version.py")
100104
version_ns = {}
101-
exec(compile(open(_version_py).read(), _version_py, "exec"), version_ns)
105+
exec(compile(open(_version_py).read(), _version_py, "exec"), version_ns) # noqa
102106
# The short X.Y version.
103107
version = "%i.%i" % version_ns["version_info"][:2]
104108
# The full version, including alpha/beta/rc tags.

0 commit comments

Comments
 (0)