From 96f2f2b42b0d73b7f3f6f3dbdd2044a41a926505 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 6 Apr 2024 12:12:29 +0200 Subject: [PATCH] MAINT: autoupdate pre-commit hooks (#38) * DX: apply new ComPWA dev configuration * MAINT: address linting issues --------- 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> --- .cspell.json | 3 +- .github/workflows/cd.yml | 16 ++++++- .github/workflows/ci.yml | 3 +- .github/workflows/pr-linting.yml | 23 +--------- .github/workflows/release-drafter.yml | 2 +- .gitpod.yml | 4 +- .pre-commit-config.yaml | 56 ++++++++++-------------- .vscode/extensions.json | 8 ++-- .vscode/settings.json | 16 +++++-- README.md | 1 - pyproject.toml | 61 +++++++++++---------------- src/sphinx_hep_pdgref/role.py | 2 +- tests/conftest.py | 2 +- tests/test_entry.py | 2 +- 14 files changed, 88 insertions(+), 111 deletions(-) diff --git a/.cspell.json b/.cspell.json index 31c0db9..3d4b999 100644 --- a/.cspell.json +++ b/.cspell.json @@ -32,7 +32,7 @@ "tox.ini" ], "language": "en-US", - "words": ["ComPWA", "conda", "doctests", "pdgref", "pytest"], + "words": ["ComPWA", "conda", "doctests", "pdgref", "PyPA", "pytest"], "ignoreWords": [ "MAINT", "PYTHONHASHSEED", @@ -49,6 +49,7 @@ "pypi", "pyquery", "pyright", + "redeclaration", "rtfd", "sdist", "setuptools", diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 925b84d..54ae3bc 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -10,10 +10,22 @@ jobs: milestone: if: startsWith(github.ref, 'refs/tags') uses: ComPWA/actions/.github/workflows/close-milestone.yml@v1 + package-name: + uses: ComPWA/actions/.github/workflows/get-pypi-name.yml@v1 pypi: + environment: + name: PyPI + url: https://pypi.org/p/${{ needs.package-name.outputs.name }} if: startsWith(github.ref, 'refs/tags') - secrets: inherit - uses: ComPWA/actions/.github/workflows/publish-to-pypi.yml@v1 + name: Publish to PyPI + needs: + - package-name + permissions: + id-token: write + runs-on: ubuntu-22.04 + steps: + - uses: ComPWA/actions/build-pypi-distribution@v1 + - uses: pypa/gh-action-pypi-publish@release/v1 push: if: startsWith(github.ref, 'refs/tags') && !github.event.release.prerelease secrets: inherit diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c89d68e..4c6f0cb 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/.gitpod.yml b/.gitpod.yml index 049b5d2..f0a38d3 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -20,15 +20,13 @@ vscode: - editorconfig.editorconfig - esbenp.prettier-vscode - github.vscode-github-actions - - ms-python.black-formatter - ms-python.mypy-type-checker - ms-python.python - ms-python.vscode-pylance - redhat.vscode-yaml - ryanluker.vscode-coverage-gutters - - Soulcode.vscode-unwanted-extensions + - soulcode.vscode-unwanted-extensions - stkb.rewrap - streetsidesoftware.code-spell-checker - tamasfe.even-better-toml - - tyriar.sort-lines - yzhang.markdown-all-in-one diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e9faa31..54ee8de 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,6 +13,13 @@ repos: - id: check-hooks-apply - id: check-useless-excludes + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.3.5 + hooks: + - id: ruff + args: [--fix] + - id: ruff-format + - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.5.0 hooks: @@ -41,18 +48,25 @@ repos: )$ - id: trailing-whitespace - - repo: https://github.com/psf/black-pre-commit-mirror - rev: 23.12.1 + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v4.0.0-alpha.8 + hooks: + - id: prettier + + - repo: https://github.com/ComPWA/mirrors-taplo + rev: v0.8.1 hooks: - - id: black + - id: taplo - - repo: https://github.com/asottile/blacken-docs - rev: 1.16.0 + - repo: https://github.com/pappasam/toml-sort + rev: v0.23.1 hooks: - - id: blacken-docs + - id: toml-sort + args: + - --in-place - repo: https://github.com/ComPWA/policy - rev: 0.2.2 + rev: 0.3.4 hooks: - id: check-dev-files args: @@ -62,7 +76,7 @@ repos: - --repo-title=sphinx-hep-pdgref - repo: https://github.com/streetsidesoftware/cspell-cli - rev: v8.3.0 + rev: v8.6.1 hooks: - id: cspell @@ -86,31 +100,7 @@ repos: types: - python - - repo: https://github.com/pre-commit/mirrors-prettier - rev: v4.0.0-alpha.8 - hooks: - - id: prettier - - repo: https://github.com/ComPWA/mirrors-pyright - rev: v1.1.345 + rev: v1.1.357 hooks: - id: pyright - - - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.13 - hooks: - - id: ruff - args: - - --fix - - - repo: https://github.com/ComPWA/mirrors-taplo - rev: v0.8.1 - hooks: - - id: taplo - - - repo: https://github.com/pappasam/toml-sort - rev: v0.23.1 - hooks: - - id: toml-sort - args: - - --in-place diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 5ad5a57..9290f21 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -6,26 +6,26 @@ "editorconfig.editorconfig", "esbenp.prettier-vscode", "github.vscode-github-actions", - "ms-python.black-formatter", "ms-python.mypy-type-checker", "ms-python.python", "ms-python.vscode-pylance", "redhat.vscode-yaml", "ryanluker.vscode-coverage-gutters", - "Soulcode.vscode-unwanted-extensions", + "soulcode.vscode-unwanted-extensions", "stkb.rewrap", "streetsidesoftware.code-spell-checker", "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.pylint", - "travisillig.vscode-json-stable-stringify" + "travisillig.vscode-json-stable-stringify", + "tyriar.sort-lines" ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index ed70985..5e01d56 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -7,7 +7,8 @@ "rewrap.wrappingColumn": 72 }, "[json]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.wordWrap": "on" }, "[jsonc]": { "editor.defaultFormatter": "esbenp.prettier-vscode" @@ -22,13 +23,12 @@ "editor.codeActionsOnSave": { "source.organizeImports": "explicit" }, - "editor.defaultFormatter": "ms-python.black-formatter", + "editor.defaultFormatter": "charliermarsh.ruff", "editor.rulers": [88] }, "[yaml]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, - "black-formatter.importStrategy": "fromEnvironment", "coverage-gutters.coverageFileNames": ["coverage.xml"], "coverage-gutters.coverageReportFileName": "**/htmlcov/index.html", "coverage-gutters.showGutterCoverage": false, @@ -45,22 +45,30 @@ "git.rebaseWhenSync": true, "github-actions.workflows.pinned.refresh.enabled": true, "github-actions.workflows.pinned.workflows": [".github/workflows/ci.yml"], + "gitlens.telemetry.enabled": false, "multiDiffEditor.experimental.enabled": true, "mypy-type-checker.args": ["--config-file=${workspaceFolder}/pyproject.toml"], "mypy-type-checker.importStrategy": "fromEnvironment", + "notebook.codeActionsOnSave": { + "notebook.source.organizeImports": "explicit" + }, + "notebook.formatOnSave.enabled": true, "python.analysis.autoImportCompletions": false, "python.analysis.inlayHints.pytestParameters": true, "python.analysis.typeCheckingMode": "strict", "python.testing.pytestArgs": ["--color=no", "--no-cov"], "python.testing.pytestEnabled": true, "python.testing.unittestEnabled": false, + "redhat.telemetry.enabled": false, "rewrap.wrappingColumn": 88, "ruff.enable": true, + "ruff.importStrategy": "fromEnvironment", "ruff.organizeImports": true, "search.exclude": { "**/tests/**/__init__.py": true, "*/.pydocstyle": true, "src/*/*/__init__.py": true, "src/*/__init__.py": true - } + }, + "telemetry.telemetryLevel": "off" } diff --git a/README.md b/README.md index 39e61f6..a975357 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,6 @@ [![pre-commit.ci status](https://results.pre-commit.ci/badge/github/ComPWA/sphinx-hep-pdgref/main.svg)](https://results.pre-commit.ci/latest/github/ComPWA/sphinx-hep-pdgref/main) [![Spelling checked](https://img.shields.io/badge/cspell-checked-brightgreen.svg)](https://github.com/streetsidesoftware/cspell/tree/master/packages/cspell) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) -[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) This package is a diff --git a/pyproject.toml b/pyproject.toml index a0ee377..0c8a283 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,9 +48,6 @@ dev = [ "sphinx-hep-pdgref[test]", "tox >=1.9", # for skip_install, use_develop ] -format = [ - "black", -] lint = [ "ruff", "sphinx-hep-pdgref[mypy]", @@ -62,9 +59,10 @@ mypy = [ ] sty = [ "pre-commit >=1.4.0", + "ruff", "sphinx-hep-pdgref[format]", "sphinx-hep-pdgref[lint]", - "sphinx-hep-pdgref[test]", # for pytest type hints + "sphinx-hep-pdgref[test]", ] test = [ "pyquery", # for checking HTML output @@ -99,31 +97,6 @@ where = ["src"] [tool.setuptools_scm] write_to = "src/version.py" -[tool.black] -exclude = ''' -/( - .*\.egg-info - | .*build - | \.eggs - | \.git - | \.pytest_cache - | \.tox - | \.venv - | \.vscode - | dist -)/ -''' -include = '\.pyi?$' -preview = true -target-version = [ - "py310", - "py311", - "py312", - "py37", - "py38", - "py39", -] - [tool.coverage.run] branch = true source = ["src"] @@ -197,6 +170,19 @@ testpaths = [ ] [tool.ruff] +preview = true +show-fixes = true +src = [ + "src", + "tests", +] +target-version = "py37" + +[tool.ruff.format] +docstring-code-format = true +line-ending = "lf" + +[tool.ruff.lint] extend-select = [ "A", "B", @@ -240,30 +226,31 @@ ignore = [ "D407", "D416", "E501", + "ISC001", + "PLW1514", "SIM108", "UP036", ] -show-fixes = true -src = [ - "src", - "tests", -] -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] "setup.py" = ["D100"] "tests/*" = [ "D", "INP001", "PGH001", + "PLC2701", "PLR0913", "PLR2004", + "PLR6301", "S101", "T20", ] -[tool.ruff.pydocstyle] +[tool.ruff.lint.pydocstyle] convention = "google" [tool.tomlsort] diff --git a/src/sphinx_hep_pdgref/role.py b/src/sphinx_hep_pdgref/role.py index bb507d1..92e4e3c 100644 --- a/src/sphinx_hep_pdgref/role.py +++ b/src/sphinx_hep_pdgref/role.py @@ -16,7 +16,7 @@ def pdgref(pattern: URLPattern) -> RoleFunction: - def role( # noqa: PLR0913 + def role( # noqa: PLR0913, PLR0917 name: str, rawtext: str, text: str, diff --git a/tests/conftest.py b/tests/conftest.py index c504c48..dfcad45 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -17,7 +17,7 @@ from sphinx.testing.path import path @pytest.fixture(scope="session") - def rootdir() -> path: + def rootdir() -> path: # pyright:ignore[reportRedeclaration] return path(__file__).parent.abspath() / "roots" else: diff --git a/tests/test_entry.py b/tests/test_entry.py index d7b5977..dff7e4e 100644 --- a/tests/test_entry.py +++ b/tests/test_entry.py @@ -48,7 +48,7 @@ def test_from_str( entry = PDGEntry.from_str(text) assert entry == expected assert entry.first_page == first_page - from_eval = eval(str(entry)) # noqa: S307 + from_eval = eval(str(entry)) assert entry == from_eval