Add spelling and docstring enforcement (#6669)

* add spelling and docstring enforcement

* remove markdown format

* restore local hooks

* add docs change

* spelling
This commit is contained in:
Steven Silvester 2022-12-23 14:55:19 -06:00 committed by GitHub
parent 48fb973071
commit 840b4256da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 56 additions and 12 deletions

View File

@ -69,6 +69,9 @@ jobs:
- uses: actions/checkout@v3
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- run: |
sudo apt-get update
sudo apt install enchant-2 # for spelling
# pandoc is not up to date in the ubuntu repos, so we install directly
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
- run: hatch run docs:build
@ -169,7 +172,7 @@ jobs:
run: |
hatch run typing:test
hatch run lint:style
pipx run 'validate-pyproject[all]' pyproject.toml
pipx run interrogate -v .
pipx run doc8 --max-line-length=200 docs/source *.md
npm install -g yarn
yarn

View File

@ -5,17 +5,17 @@ repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: end-of-file-fixer
- id: check-case-conflict
- id: check-ast
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: requirements-txt-fixer
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- id: check-json
- id: check-toml
- id: check-yaml
- id: debug-statements
- id: forbid-new-submodules
- id: check-builtin-literals
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/python-jsonschema/check-jsonschema
@ -29,7 +29,7 @@ repos:
- id: black
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.185
rev: v0.0.189
hooks:
- id: ruff
args: ["--fix"]

View File

@ -72,6 +72,13 @@ extensions = [
"myst_parser",
]
try:
import enchant # type:ignore # noqa
extensions += ["sphinxcontrib.spelling"]
except ImportError:
pass
myst_enable_extensions = ["html_image"]
myst_update_mathjax = False

View File

@ -1,3 +1,4 @@
"""CLI entry point for notebook."""
import sys
from notebook.app import main

View File

@ -1,3 +1,4 @@
"""Version info for notebook."""
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import re

View File

@ -1,3 +1,4 @@
"""Jupyter notebook application."""
import os
from os.path import join as pjoin
@ -29,7 +30,10 @@ version = __version__
class NotebookBaseHandler(ExtensionHandlerJinjaMixin, ExtensionHandlerMixin, JupyterHandler):
"""The base notebook API handler."""
def get_page_config(self): # noqa:C901
"""Get the page config."""
config = LabConfig()
app = self.extensionapp
base_url = self.settings.get("base_url")
@ -112,12 +116,17 @@ class NotebookBaseHandler(ExtensionHandlerJinjaMixin, ExtensionHandlerMixin, Jup
class RedirectHandler(NotebookBaseHandler):
"""A redirect handler."""
@web.authenticated
def get(self):
"""Get the redirect url."""
return self.redirect(self.base_url + "tree")
class TreeHandler(NotebookBaseHandler):
"""A tree page handler."""
@web.authenticated
async def get(self, path=None):
"""
@ -156,29 +165,41 @@ class TreeHandler(NotebookBaseHandler):
class ConsoleHandler(NotebookBaseHandler):
"""A console page handler."""
@web.authenticated
def get(self, path=None):
"""Get the console page."""
tpl = self.render_template("consoles.html", page_config=self.get_page_config())
return self.write(tpl)
class TerminalHandler(NotebookBaseHandler):
"""A terminal page handler."""
@web.authenticated
def get(self, path=None):
"""Get the terminal page."""
tpl = self.render_template("terminals.html", page_config=self.get_page_config())
return self.write(tpl)
class FileHandler(NotebookBaseHandler):
"""A file page handler."""
@web.authenticated
def get(self, path=None):
"""Get the file page."""
tpl = self.render_template("edit.html", page_config=self.get_page_config())
return self.write(tpl)
class NotebookHandler(NotebookBaseHandler):
"""A notebook page handler."""
@web.authenticated
def get(self, path=None):
"""Get the notebook page."""
tpl = self.render_template("notebooks.html", page_config=self.get_page_config())
return self.write(tpl)
@ -187,6 +208,8 @@ aliases = dict(base_aliases)
class JupyterNotebookApp(NotebookConfigShimMixin, LabServerApp):
"""The notebook server extension app."""
name = "notebook"
app_name = "Jupyter Notebook"
description = "Jupyter Notebook - A web-based notebook environment for interactive computing"
@ -246,6 +269,7 @@ class JupyterNotebookApp(NotebookConfigShimMixin, LabServerApp):
return get_workspaces_dir()
def initialize_handlers(self):
"""Initialize handlers."""
self.handlers.append(
(
rf"/{self.file_url_prefix}/((?!.*\.ipynb($|\?)).*)",
@ -261,9 +285,6 @@ class JupyterNotebookApp(NotebookConfigShimMixin, LabServerApp):
self.handlers.append(("/terminals/(.*)", TerminalHandler))
super().initialize_handlers()
def initialize_settings(self):
super().initialize_settings()
def initialize(self, argv=None):
"""Subclass because the ExtensionApp.initialize() method does not take arguments"""
super().initialize()

View File

@ -69,6 +69,7 @@ docs = [
"pydata-sphinx-theme",
"sphinx>=1.3.6",
"sphinxcontrib_github_alt",
"sphinxcontrib_spelling"
]
dev = [
"pre-commit",
@ -138,10 +139,10 @@ test = "mypy --install-types --non-interactive {args:notebook tests}"
[tool.hatch.envs.lint]
dependencies = [
"black[jupyter]>=22.6.0",
"black[jupyter]==22.10.0",
"mdformat>0.7",
"mdformat-gfm>=0.3.5",
"ruff>=0.0.156"
"ruff==0.0.189"
]
detached = true
[tool.hatch.envs.lint.scripts]
@ -263,3 +264,13 @@ ignore = [
# S101 Use of `assert` detected
# F841 Local variable `foo` is assigned to but never used
"tests/*" = ["S101", "F841"]
[tool.interrogate]
ignore-init-module=true
ignore-private=true
ignore-semiprivate=true
ignore-property-decorators=true
ignore-nested-functions=true
ignore-nested-classes=true
fail-under=100
exclude = ["tests", "ui-tests", "docs", "node_modules", "setup.py"]