Skip to content

Commit 840b425

Browse files
authored
Add spelling and docstring enforcement (#6669)
* add spelling and docstring enforcement * remove markdown format * restore local hooks * add docs change * spelling
1 parent 48fb973 commit 840b425

File tree

7 files changed

+56
-12
lines changed

7 files changed

+56
-12
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ jobs:
6969
- uses: actions/checkout@v3
7070
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
7171
- run: |
72+
sudo apt-get update
73+
sudo apt install enchant-2 # for spelling
74+
7275
# pandoc is not up to date in the ubuntu repos, so we install directly
7376
wget https://github.com/jgm/pandoc/releases/download/2.14.2/pandoc-2.14.2-1-amd64.deb && sudo dpkg -i pandoc-2.14.2-1-amd64.deb
7477
- run: hatch run docs:build
@@ -169,7 +172,7 @@ jobs:
169172
run: |
170173
hatch run typing:test
171174
hatch run lint:style
172-
pipx run 'validate-pyproject[all]' pyproject.toml
175+
pipx run interrogate -v .
173176
pipx run doc8 --max-line-length=200 docs/source *.md
174177
npm install -g yarn
175178
yarn

.pre-commit-config.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ repos:
55
- repo: https://github.com/pre-commit/pre-commit-hooks
66
rev: v4.4.0
77
hooks:
8-
- id: end-of-file-fixer
98
- id: check-case-conflict
9+
- id: check-ast
10+
- id: check-docstring-first
1011
- id: check-executables-have-shebangs
11-
- id: requirements-txt-fixer
1212
- id: check-added-large-files
1313
- id: check-case-conflict
14+
- id: check-merge-conflict
15+
- id: check-json
1416
- id: check-toml
1517
- id: check-yaml
16-
- id: debug-statements
17-
- id: forbid-new-submodules
18-
- id: check-builtin-literals
18+
- id: end-of-file-fixer
1919
- id: trailing-whitespace
2020

2121
- repo: https://github.com/python-jsonschema/check-jsonschema
@@ -29,7 +29,7 @@ repos:
2929
- id: black
3030

3131
- repo: https://github.com/charliermarsh/ruff-pre-commit
32-
rev: v0.0.185
32+
rev: v0.0.189
3333
hooks:
3434
- id: ruff
3535
args: ["--fix"]

docs/source/conf.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@
7272
"myst_parser",
7373
]
7474

75+
try:
76+
import enchant # type:ignore # noqa
77+
78+
extensions += ["sphinxcontrib.spelling"]
79+
except ImportError:
80+
pass
81+
7582
myst_enable_extensions = ["html_image"]
7683
myst_update_mathjax = False
7784

notebook/__main__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""CLI entry point for notebook."""
12
import sys
23

34
from notebook.app import main

notebook/_version.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Version info for notebook."""
12
# Copyright (c) Jupyter Development Team.
23
# Distributed under the terms of the Modified BSD License.
34
import re

notebook/app.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Jupyter notebook application."""
12
import os
23
from os.path import join as pjoin
34

@@ -29,7 +30,10 @@
2930

3031

3132
class NotebookBaseHandler(ExtensionHandlerJinjaMixin, ExtensionHandlerMixin, JupyterHandler):
33+
"""The base notebook API handler."""
34+
3235
def get_page_config(self): # noqa:C901
36+
"""Get the page config."""
3337
config = LabConfig()
3438
app = self.extensionapp
3539
base_url = self.settings.get("base_url")
@@ -112,12 +116,17 @@ def get_page_config(self): # noqa:C901
112116

113117

114118
class RedirectHandler(NotebookBaseHandler):
119+
"""A redirect handler."""
120+
115121
@web.authenticated
116122
def get(self):
123+
"""Get the redirect url."""
117124
return self.redirect(self.base_url + "tree")
118125

119126

120127
class TreeHandler(NotebookBaseHandler):
128+
"""A tree page handler."""
129+
121130
@web.authenticated
122131
async def get(self, path=None):
123132
"""
@@ -156,29 +165,41 @@ async def get(self, path=None):
156165

157166

158167
class ConsoleHandler(NotebookBaseHandler):
168+
"""A console page handler."""
169+
159170
@web.authenticated
160171
def get(self, path=None):
172+
"""Get the console page."""
161173
tpl = self.render_template("consoles.html", page_config=self.get_page_config())
162174
return self.write(tpl)
163175

164176

165177
class TerminalHandler(NotebookBaseHandler):
178+
"""A terminal page handler."""
179+
166180
@web.authenticated
167181
def get(self, path=None):
182+
"""Get the terminal page."""
168183
tpl = self.render_template("terminals.html", page_config=self.get_page_config())
169184
return self.write(tpl)
170185

171186

172187
class FileHandler(NotebookBaseHandler):
188+
"""A file page handler."""
189+
173190
@web.authenticated
174191
def get(self, path=None):
192+
"""Get the file page."""
175193
tpl = self.render_template("edit.html", page_config=self.get_page_config())
176194
return self.write(tpl)
177195

178196

179197
class NotebookHandler(NotebookBaseHandler):
198+
"""A notebook page handler."""
199+
180200
@web.authenticated
181201
def get(self, path=None):
202+
"""Get the notebook page."""
182203
tpl = self.render_template("notebooks.html", page_config=self.get_page_config())
183204
return self.write(tpl)
184205

@@ -187,6 +208,8 @@ def get(self, path=None):
187208

188209

189210
class JupyterNotebookApp(NotebookConfigShimMixin, LabServerApp):
211+
"""The notebook server extension app."""
212+
190213
name = "notebook"
191214
app_name = "Jupyter Notebook"
192215
description = "Jupyter Notebook - A web-based notebook environment for interactive computing"
@@ -246,6 +269,7 @@ def _default_workspaces_dir(self):
246269
return get_workspaces_dir()
247270

248271
def initialize_handlers(self):
272+
"""Initialize handlers."""
249273
self.handlers.append(
250274
(
251275
rf"/{self.file_url_prefix}/((?!.*\.ipynb($|\?)).*)",
@@ -261,9 +285,6 @@ def initialize_handlers(self):
261285
self.handlers.append(("/terminals/(.*)", TerminalHandler))
262286
super().initialize_handlers()
263287

264-
def initialize_settings(self):
265-
super().initialize_settings()
266-
267288
def initialize(self, argv=None):
268289
"""Subclass because the ExtensionApp.initialize() method does not take arguments"""
269290
super().initialize()

pyproject.toml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ docs = [
6969
"pydata-sphinx-theme",
7070
"sphinx>=1.3.6",
7171
"sphinxcontrib_github_alt",
72+
"sphinxcontrib_spelling"
7273
]
7374
dev = [
7475
"pre-commit",
@@ -138,10 +139,10 @@ test = "mypy --install-types --non-interactive {args:notebook tests}"
138139

139140
[tool.hatch.envs.lint]
140141
dependencies = [
141-
"black[jupyter]>=22.6.0",
142+
"black[jupyter]==22.10.0",
142143
"mdformat>0.7",
143144
"mdformat-gfm>=0.3.5",
144-
"ruff>=0.0.156"
145+
"ruff==0.0.189"
145146
]
146147
detached = true
147148
[tool.hatch.envs.lint.scripts]
@@ -263,3 +264,13 @@ ignore = [
263264
# S101 Use of `assert` detected
264265
# F841 Local variable `foo` is assigned to but never used
265266
"tests/*" = ["S101", "F841"]
267+
268+
[tool.interrogate]
269+
ignore-init-module=true
270+
ignore-private=true
271+
ignore-semiprivate=true
272+
ignore-property-decorators=true
273+
ignore-nested-functions=true
274+
ignore-nested-classes=true
275+
fail-under=100
276+
exclude = ["tests", "ui-tests", "docs", "node_modules", "setup.py"]

0 commit comments

Comments
 (0)