From 5401b485b5b7b8e2acf061fb85b6fa97d37d5dac Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 12 Jan 2024 19:02:34 +0100 Subject: [PATCH] MAINT: autoupdate pre-commit hooks (#20) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Remco de Boer <29308176+redeboer@users.noreply.github.com> Co-authored-by: GitHub --- .pre-commit-config.yaml | 57 +++++++++++------------------- .vscode/extensions.json | 4 ++- .vscode/settings.json | 4 ++- environment.yml | 2 ++ pyproject.toml | 48 +++++++++++++++---------- scripts/execute_jax_benchmark.py | 1 + scripts/visualize_jax_benchmark.py | 1 + tox.ini | 29 +++++++++++++++ 8 files changed, 90 insertions(+), 56 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 476bcdd..ffd7382 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,6 +2,7 @@ ci: autoupdate_commit_msg: "MAINT: autoupdate pre-commit hooks" autoupdate_schedule: quarterly skip: + - prettier - pyright - taplo @@ -11,6 +12,18 @@ repos: - id: check-hooks-apply - id: check-useless-excludes + - repo: https://github.com/ComPWA/policy + rev: 0.2.0 + hooks: + - id: check-dev-files + args: + - --no-gitpod + - --no-prettierrc + - --no-pypi + - --repo-name=ComPWA benchmarks + - --repo-title=benchmarks + - id: colab-toc-visible + - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.5.0 hooks: @@ -26,29 +39,8 @@ repos: - id: mixed-line-ending - id: trailing-whitespace - - repo: https://github.com/ComPWA/repo-maintenance - rev: 0.1.0 - hooks: - - id: check-dev-files - args: - - --no-gitpod - - --no-prettierrc - - --no-pypi - - --repo-name=ComPWA benchmarks - - --repo-title=benchmarks - - id: colab-toc-visible - - repo: https://github.com/nbQA-dev/nbQA - rev: 1.7.0 - hooks: - - id: nbqa-pyupgrade - args: - - --py37-plus - - id: nbqa-ruff - args: - - --fix - - - repo: https://github.com/psf/black - rev: 23.9.1 + - repo: https://github.com/psf/black-pre-commit-mirror + rev: 23.12.1 hooks: - id: black - id: black-jupyter @@ -56,7 +48,7 @@ repos: types_or: [jupyter] - repo: https://github.com/editorconfig-checker/editorconfig-checker.python - rev: 2.7.2 + rev: 2.7.3 hooks: - id: editorconfig-checker name: editorconfig @@ -92,28 +84,21 @@ repos: metadata.vscode - repo: https://github.com/pre-commit/mirrors-prettier - rev: v3.0.3 + rev: v4.0.0-alpha.8 hooks: - id: prettier - repo: https://github.com/ComPWA/mirrors-pyright - rev: v1.1.330 + rev: v1.1.345 hooks: - id: pyright - - repo: https://github.com/asottile/pyupgrade - rev: v3.15.0 - hooks: - - id: pyupgrade - args: - - --py37-plus - - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.292 + rev: v0.1.13 hooks: - id: ruff - args: - - --fix + args: [--fix] + types_or: [python, pyi, jupyter] - repo: https://github.com/ComPWA/mirrors-taplo rev: v0.8.1 diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 973368a..72f5509 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -5,7 +5,6 @@ "editorconfig.editorconfig", "esbenp.prettier-vscode", "executablebookproject.myst-highlight", - "garaioag.garaio-vscode-unwanted-recommendations", "github.vscode-github-actions", "github.vscode-pull-request-github", "ms-python.black-formatter", @@ -15,6 +14,7 @@ "ms-vsliveshare.vsliveshare", "oijaz.unicode-latex", "redhat.vscode-yaml", + "Soulcode.vscode-unwanted-extensions", "stkb.rewrap", "tamasfe.even-better-toml", "tyriar.sort-lines", @@ -23,10 +23,12 @@ "unwantedRecommendations": [ "bungcip.better-toml", "davidanson.vscode-markdownlint", + "garaioag.garaio-vscode-unwanted-recommendations", "ms-python.flake8", "ms-python.isort", "ms-python.mypy-type-checker", "ms-python.pylint", + "streetsidesoftware.code-spell-checker", "travisillig.vscode-json-stable-stringify" ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index 11f34ff..70e723a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -18,7 +18,7 @@ }, "[python]": { "editor.codeActionsOnSave": { - "source.organizeImports": true + "source.organizeImports": "explicit" }, "editor.defaultFormatter": "ms-python.black-formatter", "editor.rulers": [88] @@ -27,6 +27,7 @@ "editor.defaultFormatter": "esbenp.prettier-vscode" }, "black-formatter.importStrategy": "fromEnvironment", + "diffEditor.experimental.showMoves": true, "editor.formatOnSave": true, "files.associations": { ".cspell/*.txt": "plaintext" @@ -34,6 +35,7 @@ "files.eol": "\n", "github-actions.workflows.pinned.workflows": [".github/workflows/ci.yml"], "livePreview.defaultPreviewPath": "docs/_build/html", + "multiDiffEditor.experimental.enabled": true, "notebook.gotoSymbols.showAllSymbols": true, "python.analysis.autoImportCompletions": false, "rewrap.wrappingColumn": 88, diff --git a/environment.yml b/environment.yml index 624c473..322916d 100644 --- a/environment.yml +++ b/environment.yml @@ -6,3 +6,5 @@ dependencies: - pip - pip: - -e .[dev] +variables: + PRETTIER_LEGACY_CLI: "1" diff --git a/pyproject.toml b/pyproject.toml index 4ced08a..3968766 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,6 +38,7 @@ dev = [ "benchmarks[doc]", "benchmarks[jupyter]", "benchmarks[sty]", + "benchmarks[test]", "sphinx-autobuild", "tox >=1.9", # for skip_install, use_develop ] @@ -55,8 +56,15 @@ format = [ "black", ] jupyter = [ + "isort", "jupyterlab >=3.0", + "jupyterlab", "jupyterlab-code-formatter", + "jupyterlab-git", + "jupyterlab-lsp", + "jupyterlab-myst", + "python-lsp-ruff", + "python-lsp-server[rope]", 'jupyterlab-myst; python_version >="3.7.0"', ] lint = [ @@ -67,6 +75,9 @@ sty = [ "benchmarks[lint]", "pre-commit >=1.4.0", ] +test = [ + "nbmake", +] [project.readme] content-type = "text/markdown" @@ -99,24 +110,6 @@ target-version = [ "py39", ] -[tool.nbqa.addopts] -ruff = [ - "--extend-ignore=B018", - "--extend-ignore=C408", - "--extend-ignore=C90", - "--extend-ignore=D", - "--extend-ignore=N806", - "--extend-ignore=N816", - "--extend-ignore=PLR09", - "--extend-ignore=PLR2004", - "--extend-ignore=PLW0602", - "--extend-ignore=PLW0603", - "--line-length=85", -] - -[tool.nbqa.exclude] -flake8 = "^docs/appendix/benchmark.ipynb" - [tool.pyright] reportGeneralTypeIssues = false reportImportCycles = false @@ -163,6 +156,7 @@ testpaths = [ ] [tool.ruff] +extend-include = ["*.ipynb"] extend-select = [ "A", "B", @@ -213,6 +207,23 @@ target-version = "py37" task-tags = ["cspell"] [tool.ruff.per-file-ignores] +"*.ipynb" = [ + "B018", + "C408", + "C90", + "D", + "E402", + "E703", + "N806", + "N816", + "PLR09", + "PLR2004", + "PLW0602", + "PLW0603", + "S101", + "T20", + "TCH00", +] "docs/*" = [ "E402", "INP001", @@ -220,6 +231,7 @@ task-tags = ["cspell"] "S113", "T201", ] +"docs/conf.py" = ["D100"] "scripts/*" = ["INP001"] "setup.py" = ["D100"] diff --git a/scripts/execute_jax_benchmark.py b/scripts/execute_jax_benchmark.py index 897026e..a371b0b 100644 --- a/scripts/execute_jax_benchmark.py +++ b/scripts/execute_jax_benchmark.py @@ -1,4 +1,5 @@ """Execute JAX over a combination of physical cores.""" + from __future__ import annotations import logging diff --git a/scripts/visualize_jax_benchmark.py b/scripts/visualize_jax_benchmark.py index 4fa7f32..549bcd8 100644 --- a/scripts/visualize_jax_benchmark.py +++ b/scripts/visualize_jax_benchmark.py @@ -1,4 +1,5 @@ """Visualize benchmark results from :file:`execute_jax_benchmark.py`.""" + from __future__ import annotations import logging diff --git a/tox.ini b/tox.ini index bfda2c6..315892b 100644 --- a/tox.ini +++ b/tox.ini @@ -57,6 +57,25 @@ setenv = FORCE_COLOR = yes PYTHONHASHSEED = 0 +[testenv:docnblive] +allowlist_externals = + sphinx-autobuild +commands = + sphinx-autobuild \ + --open-browser \ + --re-ignore .*/.ipynb_checkpoints/.* \ + --re-ignore .*/__pycache__/.* \ + --re-ignore .*\.tmp \ + --watch docs \ + docs/ docs/_build/html +description = + Set up a server to directly preview changes to the HTML pages +passenv = * +setenv = + EXECUTE_NB = yes + FORCE_COLOR = yes + PYTHONHASHSEED = 0 + [testenv:docnb-force] allowlist_externals = sphinx-build @@ -84,6 +103,16 @@ passenv = * setenv = FORCE_COLOR = yes +[testenv:nb] +allowlist_externals = + pytest +commands = + pytest --nbmake {posargs:docs} +description = + Run all notebooks with pytest +passenv = * +setenv = + PYTHONHASHSEED = 0 [testenv:sty] description =