mirror of
https://github.com/jupyter/notebook.git
synced 2025-02-17 12:39:54 +08:00
Update ruff config and typing (#7145)
This commit is contained in:
parent
875e4d754f
commit
29d665dbac
@ -50,7 +50,7 @@ repos:
|
|||||||
files: "^notebook"
|
files: "^notebook"
|
||||||
stages: [manual]
|
stages: [manual]
|
||||||
args: ["--install-types", "--non-interactive"]
|
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
|
- repo: https://github.com/pre-commit/pygrep-hooks
|
||||||
rev: 'v1.10.0'
|
rev: 'v1.10.0'
|
||||||
@ -60,11 +60,15 @@ repos:
|
|||||||
- id: rst-inline-touching-normal
|
- id: rst-inline-touching-normal
|
||||||
|
|
||||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
rev: v0.1.4
|
rev: v0.1.5
|
||||||
hooks:
|
hooks:
|
||||||
- id: ruff
|
- id: ruff
|
||||||
|
types_or: [ python, jupyter ]
|
||||||
|
exclude: '^docs/source/examples/Notebook/Importing Notebooks.ipynb'
|
||||||
args: ['--fix', '--show-fixes']
|
args: ['--fix', '--show-fixes']
|
||||||
- id: ruff-format
|
- id: ruff-format
|
||||||
|
types_or: [ python, jupyter ]
|
||||||
|
exclude: '^docs/source/examples/Notebook/Importing Notebooks.ipynb'
|
||||||
|
|
||||||
- repo: https://github.com/scientific-python/cookie
|
- repo: https://github.com/scientific-python/cookie
|
||||||
rev: '2023.10.27'
|
rev: '2023.10.27'
|
||||||
|
@ -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 \\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 \\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 \\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",
|
"\\end{eqnarray}\"\"\"\n",
|
||||||
")"
|
")"
|
||||||
]
|
]
|
||||||
@ -277,8 +277,7 @@
|
|||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"from IPython.display import HTML\n",
|
"from IPython.display import HTML, display\n",
|
||||||
"from IPython.display import display\n",
|
|
||||||
"\n",
|
"\n",
|
||||||
"s = \"\"\"<table>\n",
|
"s = \"\"\"<table>\n",
|
||||||
"<tr>\n",
|
"<tr>\n",
|
||||||
|
@ -124,7 +124,6 @@
|
|||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"import sys\n",
|
"import sys\n",
|
||||||
"from ctypes import CDLL\n",
|
|
||||||
"\n",
|
"\n",
|
||||||
"# This will crash a Linux or Mac system\n",
|
"# This will crash a Linux or Mac system\n",
|
||||||
"# equivalent calls can be made on Windows\n",
|
"# equivalent calls can be made on Windows\n",
|
||||||
@ -225,9 +224,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"from __future__ import print_function\n",
|
"print(\"hi, stderr\", file=sys.stderr)"
|
||||||
"\n",
|
|
||||||
"print('hi, stderr', file=sys.stderr)"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -270,7 +267,8 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"import time, sys\n",
|
"import sys\n",
|
||||||
|
"import time\n",
|
||||||
"\n",
|
"\n",
|
||||||
"for i in range(8):\n",
|
"for i in range(8):\n",
|
||||||
" print(i)\n",
|
" print(i)\n",
|
||||||
|
@ -301,6 +301,8 @@ class JupyterNotebookApp(NotebookConfigShimMixin, LabServerApp): # type:ignore[
|
|||||||
|
|
||||||
def server_extension_is_enabled(self, extension: str) -> bool:
|
def server_extension_is_enabled(self, extension: str) -> bool:
|
||||||
"""Check if server extension is enabled."""
|
"""Check if server extension is enabled."""
|
||||||
|
if self.serverapp is None:
|
||||||
|
return False
|
||||||
try:
|
try:
|
||||||
extension_enabled = (
|
extension_enabled = (
|
||||||
self.serverapp.extension_manager.extensions[extension].enabled is True
|
self.serverapp.extension_manager.extensions[extension].enabled is True
|
||||||
@ -311,6 +313,7 @@ class JupyterNotebookApp(NotebookConfigShimMixin, LabServerApp): # type:ignore[
|
|||||||
|
|
||||||
def initialize_handlers(self) -> None:
|
def initialize_handlers(self) -> None:
|
||||||
"""Initialize handlers."""
|
"""Initialize handlers."""
|
||||||
|
assert self.serverapp is not None # noqa: S101
|
||||||
page_config = self.serverapp.web_app.settings.setdefault("page_config_data", {})
|
page_config = self.serverapp.web_app.settings.setdefault("page_config_data", {})
|
||||||
nbclassic_enabled = self.server_extension_is_enabled("nbclassic")
|
nbclassic_enabled = self.server_extension_is_enabled("nbclassic")
|
||||||
page_config["nbclassic_enabled"] = nbclassic_enabled
|
page_config["nbclassic_enabled"] = nbclassic_enabled
|
||||||
|
@ -138,7 +138,10 @@ nowarn = "test -W default {args}"
|
|||||||
detached = true
|
detached = true
|
||||||
dependencies = ["pre-commit"]
|
dependencies = ["pre-commit"]
|
||||||
[tool.hatch.envs.lint.scripts]
|
[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]
|
[tool.hatch.envs.typing]
|
||||||
dependencies = [ "pre-commit"]
|
dependencies = [ "pre-commit"]
|
||||||
@ -233,7 +236,6 @@ enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
|
|||||||
warn_unreachable = true
|
warn_unreachable = true
|
||||||
|
|
||||||
[tool.ruff]
|
[tool.ruff]
|
||||||
target-version = "py38"
|
|
||||||
line-length = 100
|
line-length = 100
|
||||||
|
|
||||||
[tool.ruff.lint]
|
[tool.ruff.lint]
|
||||||
@ -260,6 +262,7 @@ ignore = [
|
|||||||
"tests/*" = ["S101", "F841", "PLR2004"]
|
"tests/*" = ["S101", "F841", "PLR2004"]
|
||||||
# undefined name 'c'
|
# undefined name 'c'
|
||||||
"ui-tests/test/jupyter_server_config.py" = ["F821"]
|
"ui-tests/test/jupyter_server_config.py" = ["F821"]
|
||||||
|
"*.ipynb" = ["E402", "B018", "E501", "T201"]
|
||||||
|
|
||||||
[tool.interrogate]
|
[tool.interrogate]
|
||||||
ignore-init-module=true
|
ignore-init-module=true
|
||||||
|
@ -6,7 +6,9 @@
|
|||||||
"id": "6f7028b9-4d2c-4fa2-96ee-bfa77bbee434",
|
"id": "6f7028b9-4d2c-4fa2-96ee-bfa77bbee434",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": ["print('1\\n' * 200)"]
|
"source": [
|
||||||
|
"print(\"1\\n\" * 200)"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
@ -14,7 +16,9 @@
|
|||||||
"id": "6f7028b9-4d2c-4fa2-96ee-bfa77bbee434",
|
"id": "6f7028b9-4d2c-4fa2-96ee-bfa77bbee434",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": ["print('1\\n' * 20)"]
|
"source": [
|
||||||
|
"print(\"1\\n\" * 20)"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
Loading…
Reference in New Issue
Block a user