Update ruff config and typing (#7145)

This commit is contained in:
Steven Silvester 2023-11-09 19:53:11 -06:00 committed by GitHub
parent 875e4d754f
commit 29d665dbac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 25 additions and 14 deletions

View File

@ -50,7 +50,7 @@ repos:
files: "^notebook"
stages: [manual]
args: ["--install-types", "--non-interactive"]
additional_dependencies: ["traitlets>=5.13", "tornado", "jupyter_server>=2.9", "jupyterlab_server>=2.25", "jupyterlab>=4.0"]
additional_dependencies: ["traitlets>=5.13", "tornado", "jupyter_server>=2.10", "jupyterlab_server>=2.25", "jupyterlab>=4.0"]
- repo: https://github.com/pre-commit/pygrep-hooks
rev: 'v1.10.0'
@ -60,11 +60,15 @@ repos:
- id: rst-inline-touching-normal
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.4
rev: v0.1.5
hooks:
- id: ruff
types_or: [ python, jupyter ]
exclude: '^docs/source/examples/Notebook/Importing Notebooks.ipynb'
args: ['--fix', '--show-fixes']
- id: ruff-format
types_or: [ python, jupyter ]
exclude: '^docs/source/examples/Notebook/Importing Notebooks.ipynb'
- repo: https://github.com/scientific-python/cookie
rev: '2023.10.27'

View File

@ -235,7 +235,7 @@
"\\nabla \\times \\vec{\\mathbf{B}} -\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{E}}}{\\partial t} & = \\frac{4\\pi}{c}\\vec{\\mathbf{j}} \\\\\n",
"\\nabla \\cdot \\vec{\\mathbf{E}} & = 4 \\pi \\rho \\\\\n",
"\\nabla \\times \\vec{\\mathbf{E}}\\, +\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{B}}}{\\partial t} & = \\vec{\\mathbf{0}} \\\\\n",
"\\nabla \\cdot \\vec{\\mathbf{B}} & = 0 \n",
"\\nabla \\cdot \\vec{\\mathbf{B}} & = 0\n",
"\\end{eqnarray}\"\"\"\n",
")"
]
@ -277,8 +277,7 @@
"metadata": {},
"outputs": [],
"source": [
"from IPython.display import HTML\n",
"from IPython.display import display\n",
"from IPython.display import HTML, display\n",
"\n",
"s = \"\"\"<table>\n",
"<tr>\n",

View File

@ -124,7 +124,6 @@
"outputs": [],
"source": [
"import sys\n",
"from ctypes import CDLL\n",
"\n",
"# This will crash a Linux or Mac system\n",
"# equivalent calls can be made on Windows\n",
@ -225,9 +224,7 @@
}
],
"source": [
"from __future__ import print_function\n",
"\n",
"print('hi, stderr', file=sys.stderr)"
"print(\"hi, stderr\", file=sys.stderr)"
]
},
{
@ -270,7 +267,8 @@
}
],
"source": [
"import time, sys\n",
"import sys\n",
"import time\n",
"\n",
"for i in range(8):\n",
" print(i)\n",

View File

@ -301,6 +301,8 @@ class JupyterNotebookApp(NotebookConfigShimMixin, LabServerApp): # type:ignore[
def server_extension_is_enabled(self, extension: str) -> bool:
"""Check if server extension is enabled."""
if self.serverapp is None:
return False
try:
extension_enabled = (
self.serverapp.extension_manager.extensions[extension].enabled is True
@ -311,6 +313,7 @@ class JupyterNotebookApp(NotebookConfigShimMixin, LabServerApp): # type:ignore[
def initialize_handlers(self) -> None:
"""Initialize handlers."""
assert self.serverapp is not None # noqa: S101
page_config = self.serverapp.web_app.settings.setdefault("page_config_data", {})
nbclassic_enabled = self.server_extension_is_enabled("nbclassic")
page_config["nbclassic_enabled"] = nbclassic_enabled

View File

@ -138,7 +138,10 @@ nowarn = "test -W default {args}"
detached = true
dependencies = ["pre-commit"]
[tool.hatch.envs.lint.scripts]
build = "pre-commit run --all-files ruff"
build = [
"pre-commit run --all-files ruff",
"pre-commit run --all-files ruff-format"
]
[tool.hatch.envs.typing]
dependencies = [ "pre-commit"]
@ -233,7 +236,6 @@ enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
warn_unreachable = true
[tool.ruff]
target-version = "py38"
line-length = 100
[tool.ruff.lint]
@ -260,6 +262,7 @@ ignore = [
"tests/*" = ["S101", "F841", "PLR2004"]
# undefined name 'c'
"ui-tests/test/jupyter_server_config.py" = ["F821"]
"*.ipynb" = ["E402", "B018", "E501", "T201"]
[tool.interrogate]
ignore-init-module=true

View File

@ -6,7 +6,9 @@
"id": "6f7028b9-4d2c-4fa2-96ee-bfa77bbee434",
"metadata": {},
"outputs": [],
"source": ["print('1\\n' * 200)"]
"source": [
"print(\"1\\n\" * 200)"
]
},
{
"cell_type": "code",
@ -14,7 +16,9 @@
"id": "6f7028b9-4d2c-4fa2-96ee-bfa77bbee434",
"metadata": {},
"outputs": [],
"source": ["print('1\\n' * 20)"]
"source": [
"print(\"1\\n\" * 20)"
]
}
],
"metadata": {