From 8f74624933f732716a8bfb08748e5f0c9b6777ca Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Sat, 4 Nov 2023 22:37:46 -0500 Subject: [PATCH] Backport PR #7142: Clean up lint handling --- .github/workflows/build.yml | 3 ++- .pre-commit-config.yaml | 9 +++++++++ pyproject.toml | 33 ++++++++++----------------------- 3 files changed, 21 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d138fe72fe..1067b71310 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -187,13 +187,14 @@ jobs: - name: Run Linters run: | hatch run typing:test - hatch run lint:style + hatch run lint:build pipx run interrogate -v . pipx run doc8 --max-line-length=200 docs/source *.md npm install -g yarn yarn yarn eslint:check yarn prettier:check + yarn build:utils yarn integrity tests_check: # This job does nothing and is only used for the branch protection diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index da34c9e88a..abe189c2a5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -43,6 +43,15 @@ repos: docs/source/examples/images/FrontendKernel.graffle/data.plist| )$ + - repo: https://github.com/pre-commit/mirrors-mypy + rev: "v1.6.1" + hooks: + - id: mypy + 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"] + - repo: https://github.com/pre-commit/pygrep-hooks rev: 'v1.10.0' hooks: diff --git a/pyproject.toml b/pyproject.toml index 23f7df3922..fb41a0e10f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -134,30 +134,17 @@ dependencies = ["coverage[toml]", "pytest-cov"] test = "python -m pytest -vv --cov notebook --cov-branch --cov-report term-missing:skip-covered {args}" nowarn = "test -W default {args}" -[tool.hatch.envs.typing] -features = ["test"] -dependencies = ["mypy>=1.5.1"] -[tool.hatch.envs.typing.scripts] -test = "mypy --install-types --non-interactive {args}" - [tool.hatch.envs.lint] -dependencies = [ - "mdformat>0.7", - "mdformat-gfm>=0.3.5", - "ruff==0.1.3" -] detached = true +dependencies = ["pre-commit"] [tool.hatch.envs.lint.scripts] -style = [ - "ruff {args:.}", - "ruff format {args:.}", - "mdformat --check {args:CHANGELOG.md}" -] -fmt = [ - "ruff --fix {args:.}", - "ruff format {args:.}", - "mdformat {args:CHANGELOG.md}" -] +build = "pre-commit run --all-files ruff" + +[tool.hatch.envs.typing] +dependencies = [ "pre-commit"] +detached = true +[tool.hatch.envs.typing.scripts] +test = "pre-commit run --all-files --hook-stage manual mypy" [tool.hatch.build.hooks.jupyter-builder] dependencies = ["hatch-jupyter-builder>=0.5"] @@ -203,7 +190,7 @@ minversion = "6.0" xfail_strict = true log_cli_level = "info" addopts = [ - "-raXs", "--durations=10", "--color=yes", "--doctest-modules", + "-ra", "--durations=10", "--color=yes", "--doctest-modules", "--showlocals", "--strict-markers", "--strict-config" ] testpaths = [ @@ -285,4 +272,4 @@ fail-under=100 exclude = ["tests", "ui-tests", "docs", "node_modules", "setup.py"] [tool.repo-review] -ignore = ["PY007", "PP308", "GH102", "PC140", "PC180"] +ignore = ["PY007", "GH102", "PC180"]