From 55385b2fbed0124ad9b6b05308ddaf607e00eae5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 1 Apr 2024 22:40:55 +0000 Subject: [PATCH 1/7] MAINT: autoupdate pre-commit hooks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/kynan/nbstripout: 0.6.1 → 0.7.1](https://github.com/kynan/nbstripout/compare/0.6.1...0.7.1) - [github.com/ComPWA/policy: 0.2.3 → 0.3.3](https://github.com/ComPWA/policy/compare/0.2.3...0.3.3) - [github.com/psf/black-pre-commit-mirror: 23.12.1 → 24.3.0](https://github.com/psf/black-pre-commit-mirror/compare/23.12.1...24.3.0) - [github.com/ComPWA/mirrors-pyright: v1.1.345 → v1.1.356](https://github.com/ComPWA/mirrors-pyright/compare/v1.1.345...v1.1.356) - [github.com/astral-sh/ruff-pre-commit: v0.1.13 → v0.3.5](https://github.com/astral-sh/ruff-pre-commit/compare/v0.1.13...v0.3.5) --- .pre-commit-config.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2307886..b7cd2f0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,7 @@ repos: - id: check-useless-excludes - repo: https://github.com/kynan/nbstripout - rev: 0.6.1 + rev: 0.7.1 hooks: - id: nbstripout args: @@ -38,7 +38,7 @@ repos: metadata.vscode - repo: https://github.com/ComPWA/policy - rev: 0.2.3 + rev: 0.3.3 hooks: - id: check-dev-files args: @@ -65,7 +65,7 @@ repos: - id: trailing-whitespace - repo: https://github.com/psf/black-pre-commit-mirror - rev: 23.12.1 + rev: 24.3.0 hooks: - id: black - id: black-jupyter @@ -101,12 +101,12 @@ repos: )$ - repo: https://github.com/ComPWA/mirrors-pyright - rev: v1.1.345 + rev: v1.1.356 hooks: - id: pyright - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.13 + rev: v0.3.5 hooks: - id: ruff args: [--fix] From aec7ba0b9ad6fe3731af9004674ef450109ca48d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 1 Apr 2024 22:41:11 +0000 Subject: [PATCH 2/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .github/workflows/ci.yml | 3 +- .github/workflows/pr-linting.yml | 23 ++----------- .github/workflows/release-drafter.yml | 2 +- .pre-commit-config.yaml | 23 +++++-------- .vscode/extensions.json | 8 ++--- .vscode/settings.json | 28 ++++++++++++---- pyproject.toml | 48 ++++++++++----------------- 7 files changed, 55 insertions(+), 80 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2eaff7b..2708cfa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,7 +2,8 @@ name: CI concurrency: group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true + cancel-in-progress: |- + ${{ github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }} env: PYTHONHASHSEED: "0" diff --git a/.github/workflows/pr-linting.yml b/.github/workflows/pr-linting.yml index cd3bb74..0fab841 100644 --- a/.github/workflows/pr-linting.yml +++ b/.github/workflows/pr-linting.yml @@ -10,24 +10,5 @@ on: - unlabeled jobs: - check-labels: - name: Check labels - runs-on: ubuntu-22.04 - steps: - - uses: docker://agilepathway/pull-request-label-checker:latest # cspell:ignore agilepathway - with: - any_of: >- - 🐛 Bug,✨ Feature,⚙️ Enhancement,⚠️ Interface,❗ Behavior,📝 Docs,🔨 Maintenance,🖱️ DX - none_of: Epic,💫 Good first issue - repo_token: ${{ secrets.GITHUB_TOKEN }} - - check-title: - name: Check title - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - - run: npm install @compwa/commitlint-config - - name: Create commitlint config - run: | - echo "module.exports = {extends: ['@compwa/commitlint-config']}" > commitlint.config.js - - uses: JulienKode/pull-request-name-linter-action@v0.5.0 # cspell:ignore kode + lint-pr: + uses: ComPWA/actions/.github/workflows/pr-linting.yml@v1 diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index d64f197..5234093 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -11,6 +11,6 @@ jobs: update_release_draft: runs-on: ubuntu-22.04 steps: - - uses: release-drafter/release-drafter@v5 + - uses: release-drafter/release-drafter@v6 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b7cd2f0..aa7098f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -49,6 +49,14 @@ repos: - --repo-title=benchmarks - id: colab-toc-visible + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.3.5 + hooks: + - id: ruff + args: [--fix] + types_or: [python, pyi, jupyter] + - id: ruff-format + types_or: [python, pyi, jupyter] - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.5.0 hooks: @@ -64,14 +72,6 @@ repos: - id: mixed-line-ending - id: trailing-whitespace - - repo: https://github.com/psf/black-pre-commit-mirror - rev: 24.3.0 - hooks: - - id: black - - id: black-jupyter - args: [--line-length=85] - types_or: [jupyter] - - repo: https://github.com/pre-commit/mirrors-prettier rev: v4.0.0-alpha.8 hooks: @@ -104,10 +104,3 @@ repos: rev: v1.1.356 hooks: - id: pyright - - - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.3.5 - hooks: - - id: ruff - args: [--fix] - types_or: [python, pyi, jupyter] diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 72f5509..dba1484 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -7,28 +7,28 @@ "executablebookproject.myst-highlight", "github.vscode-github-actions", "github.vscode-pull-request-github", - "ms-python.black-formatter", "ms-python.python", "ms-python.vscode-pylance", "ms-vscode.live-server", "ms-vsliveshare.vsliveshare", "oijaz.unicode-latex", "redhat.vscode-yaml", - "Soulcode.vscode-unwanted-extensions", + "soulcode.vscode-unwanted-extensions", "stkb.rewrap", "tamasfe.even-better-toml", - "tyriar.sort-lines", "yzhang.markdown-all-in-one" ], "unwantedRecommendations": [ "bungcip.better-toml", "davidanson.vscode-markdownlint", "garaioag.garaio-vscode-unwanted-recommendations", + "ms-python.black-formatter", "ms-python.flake8", "ms-python.isort", "ms-python.mypy-type-checker", "ms-python.pylint", "streetsidesoftware.code-spell-checker", - "travisillig.vscode-json-stable-stringify" + "travisillig.vscode-json-stable-stringify", + "tyriar.sort-lines" ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index 70e723a..e870c8a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,10 +1,13 @@ { "[git-commit]": { - "editor.rulers": [72], + "editor.rulers": [ + 72 + ], "rewrap.wrappingColumn": 72 }, "[json]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.wordWrap": "on" }, "[jsonc]": { "editor.defaultFormatter": "esbenp.prettier-vscode" @@ -20,25 +23,36 @@ "editor.codeActionsOnSave": { "source.organizeImports": "explicit" }, - "editor.defaultFormatter": "ms-python.black-formatter", - "editor.rulers": [88] + "editor.defaultFormatter": "charliermarsh.ruff", + "editor.rulers": [ + 88 + ] }, "[yaml]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, - "black-formatter.importStrategy": "fromEnvironment", "diffEditor.experimental.showMoves": true, "editor.formatOnSave": true, "files.associations": { ".cspell/*.txt": "plaintext" }, "files.eol": "\n", - "github-actions.workflows.pinned.workflows": [".github/workflows/ci.yml"], + "github-actions.workflows.pinned.workflows": [ + ".github/workflows/ci.yml" + ], + "gitlens.telemetry.enabled": false, "livePreview.defaultPreviewPath": "docs/_build/html", "multiDiffEditor.experimental.enabled": true, + "notebook.codeActionsOnSave": { + "notebook.source.organizeImports": "explicit" + }, + "notebook.formatOnSave.enabled": true, "notebook.gotoSymbols.showAllSymbols": true, "python.analysis.autoImportCompletions": false, + "redhat.telemetry.enabled": false, "rewrap.wrappingColumn": 88, "ruff.enable": true, - "ruff.organizeImports": true + "ruff.importStrategy": "fromEnvironment", + "ruff.organizeImports": true, + "telemetry.telemetryLevel": "off" } diff --git a/pyproject.toml b/pyproject.toml index d762174..3e1e7e4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,9 +53,6 @@ doc = [ "sphinx-copybutton", "sphinx-togglebutton", ] -format = [ - "black", -] jupyter = [ "isort", "jupyterlab >=3.0", @@ -76,6 +73,7 @@ sty = [ "benchmarks[lint]", "benchmarks[types]", "pre-commit >=1.4.0", + "ruff", ] test = [ "nbmake", @@ -91,30 +89,6 @@ file = "README.md" [tool.setuptools] include-package-data = false -[tool.black] -exclude = ''' -/( - .*\.egg-info - | .*build - | \.eggs - | \.git - | \.pytest_cache - | \.tox - | \.venv - | \.vscode - | dist -)/ -''' -include = '\.pyi?$' -preview = true -target-version = [ - "py310", - "py311", - "py37", - "py38", - "py39", -] - [tool.pyright] reportGeneralTypeIssues = false reportImportCycles = false @@ -162,6 +136,15 @@ testpaths = [ [tool.ruff] extend-include = ["*.ipynb"] +preview = true +show-fixes = true +target-version = "py37" + +[tool.ruff.format] +docstring-code-format = true +line-ending = "lf" + +[tool.ruff.lint] extend-select = [ "A", "B", @@ -205,13 +188,16 @@ ignore = [ "D407", "D416", "E501", + "ISC001", + "PLW1514", "SIM108", ] -show-fixes = true -target-version = "py37" task-tags = ["cspell"] -[tool.ruff.per-file-ignores] +[tool.ruff.lint.isort] +split-on-trailing-comma = false + +[tool.ruff.lint.per-file-ignores] "*.ipynb" = [ "B018", "C408", @@ -240,7 +226,7 @@ task-tags = ["cspell"] "scripts/*" = ["INP001"] "setup.py" = ["D100"] -[tool.ruff.pydocstyle] +[tool.ruff.lint.pydocstyle] convention = "google" [tool.tomlsort] From 8b0207dad667b4142004f759d595726ea9418cb2 Mon Sep 17 00:00:00 2001 From: GitHub Date: Mon, 1 Apr 2024 22:43:56 +0000 Subject: [PATCH 3/7] MAINT: implement updates from pre-commit hooks --- .vscode/settings.json | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index e870c8a..00bdf75 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,8 +1,6 @@ { "[git-commit]": { - "editor.rulers": [ - 72 - ], + "editor.rulers": [72], "rewrap.wrappingColumn": 72 }, "[json]": { @@ -24,9 +22,7 @@ "source.organizeImports": "explicit" }, "editor.defaultFormatter": "charliermarsh.ruff", - "editor.rulers": [ - 88 - ] + "editor.rulers": [88] }, "[yaml]": { "editor.defaultFormatter": "esbenp.prettier-vscode" @@ -37,9 +33,7 @@ ".cspell/*.txt": "plaintext" }, "files.eol": "\n", - "github-actions.workflows.pinned.workflows": [ - ".github/workflows/ci.yml" - ], + "github-actions.workflows.pinned.workflows": [".github/workflows/ci.yml"], "gitlens.telemetry.enabled": false, "livePreview.defaultPreviewPath": "docs/_build/html", "multiDiffEditor.experimental.enabled": true, From 1cb2417ed3e7db72f096b0dc332c9364b66c0323 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 1 Apr 2024 22:45:26 +0000 Subject: [PATCH 4/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- docs/visualize-jax-benchmark.ipynb | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/docs/visualize-jax-benchmark.ipynb b/docs/visualize-jax-benchmark.ipynb index cfd2d03..01b0c5f 100644 --- a/docs/visualize-jax-benchmark.ipynb +++ b/docs/visualize-jax-benchmark.ipynb @@ -99,13 +99,9 @@ "df = pd.DataFrame(\n", " {\n", " (\"sample size\", \"\"): X[::2],\n", - " (\"1 CPU\", \"parametrized\"): Y_1CPU[f\"{parametrized}, run 2\"].mean(axis=1)[\n", - " ::2\n", - " ],\n", + " (\"1 CPU\", \"parametrized\"): Y_1CPU[f\"{parametrized}, run 2\"].mean(axis=1)[::2],\n", " (\"1 CPU\", \"substituted\"): Y_1CPU[f\"{substituted}, run 2\"].mean(axis=1)[::2],\n", - " (\"8 CPUs\", \"parametrized\"): Y_8CPU[f\"{parametrized}, run 2\"].mean(axis=1)[\n", - " ::2\n", - " ],\n", + " (\"8 CPUs\", \"parametrized\"): Y_8CPU[f\"{parametrized}, run 2\"].mean(axis=1)[::2],\n", " (\"8 CPUs\", \"substituted\"): Y_8CPU[f\"{substituted}, run 2\"].mean(axis=1)[::2],\n", " },\n", ")\n", @@ -223,9 +219,7 @@ " return y_1cpu / y_8cpu\n", "\n", "\n", - "def create_multithreading_ratio_plot(\n", - " substract_base_time: bool, savefig: bool = False\n", - "):\n", + "def create_multithreading_ratio_plot(substract_base_time: bool, savefig: bool = False):\n", " plt.rc(\"font\", size=12)\n", " fig, axes = plt.subplots(figsize=(8, 4), ncols=2, tight_layout=True)\n", " ax1, ax2 = axes\n", From 335d19c4e1554fa09cb459834379994c44ce70cc Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Fri, 5 Apr 2024 21:26:13 +0200 Subject: [PATCH 5/7] MAINT: address linting issues --- scripts/execute_jax_benchmark.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/execute_jax_benchmark.py b/scripts/execute_jax_benchmark.py index a371b0b..3c61ea7 100644 --- a/scripts/execute_jax_benchmark.py +++ b/scripts/execute_jax_benchmark.py @@ -60,7 +60,7 @@ def main() -> int: - t: dict[str, dict[str, list[float]]] = defaultdict(lambda: defaultdict(list)) + t: dict[int, dict[str, list[float]]] = defaultdict(lambda: defaultdict(list)) output_file = f"{THIS_DIRECTORY}/computation_times.yaml" if os.path.exists(output_file): imported_times = load_benchmark(output_file) @@ -111,7 +111,7 @@ def create_amplitude_model() -> AmplitudeModel: ) reference_subsystem = 1 model = amplitude_builder.formulate(reference_subsystem) - model.parameter_defaults.update(imported_parameter_values) + model.parameter_defaults.update(imported_parameter_values) # pyright:ignore[reportArgumentType,reportCallIssue] return model @@ -173,12 +173,12 @@ def benchmark(func: Function, sample: DataSample) -> float: return stop - start -def load_benchmark(filename: str) -> dict[str, dict[str, list[float]]]: +def load_benchmark(filename: str) -> dict[int, dict[str, list[float]]]: with open(filename) as f: return yaml.safe_load(f) -def write_benchmark(times: dict[str, dict[str, list[float]]], filename: str) -> None: +def write_benchmark(times: dict[int, dict[str, list[float]]], filename: str) -> None: with open(filename, "w") as f: yaml.dump( times, From 377bc12af3c76b25da6fec46ac7ebe549bdc2a83 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Sat, 6 Apr 2024 11:30:17 +0200 Subject: [PATCH 6/7] MAINT: autoupdate pre-commit config --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index aa7098f..e264585 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -38,7 +38,7 @@ repos: metadata.vscode - repo: https://github.com/ComPWA/policy - rev: 0.3.3 + rev: 0.3.4 hooks: - id: check-dev-files args: @@ -101,6 +101,6 @@ repos: )$ - repo: https://github.com/ComPWA/mirrors-pyright - rev: v1.1.356 + rev: v1.1.357 hooks: - id: pyright From dc59090fbffc33ea2096967cf869f9c858f34c4a Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Sat, 6 Apr 2024 12:32:30 +0200 Subject: [PATCH 7/7] MAINT: add newline --- .pre-commit-config.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e264585..5da1767 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -57,6 +57,7 @@ repos: types_or: [python, pyi, jupyter] - id: ruff-format types_or: [python, pyi, jupyter] + - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.5.0 hooks: