From 44012293b5c809353156a8fe73a73a027edcb1b8 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:01:35 +0200 Subject: [PATCH] MAINT: autoupdate pre-commit hooks (#7) * MAINT: address linter issues * MAINT: implement updates from pre-commit hooks --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: GitHub Co-authored-by: Remco de Boer <29308176+redeboer@users.noreply.github.com> --- .cspell.json | 1 + .github/workflows/cd.yml | 16 +++++++- .github/workflows/ci.yml | 3 +- .github/workflows/pr-linting.yml | 23 +----------- .github/workflows/release-drafter.yml | 2 +- .pre-commit-config.yaml | 54 +++++++++++++-------------- .vscode/extensions.json | 8 ++-- .vscode/settings.json | 16 ++++++-- README.md | 1 - environment.yml | 2 +- pyproject.toml | 49 +++++++++--------------- src/sphinx_pybtex_etal_style/style.py | 16 ++++---- 12 files changed, 88 insertions(+), 103 deletions(-) diff --git a/.cspell.json b/.cspell.json index 7bf8005..1a4c899 100644 --- a/.cspell.json +++ b/.cspell.json @@ -50,6 +50,7 @@ "conda", "mypy", "pybtex", + "PyPA", "PYTHONHASHSEED", "SymPy" ] 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 b1b457a..b0163c6 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 bbc36fd..81a7c8e 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: @@ -34,13 +41,25 @@ repos: - id: mixed-line-ending - 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: black + - id: prettier + + - 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 - repo: https://github.com/ComPWA/policy - rev: 0.2.0 + rev: 0.3.4 hooks: - id: check-dev-files args: @@ -51,7 +70,7 @@ repos: - --repo-title=sphinx-pybtex-etal-style - repo: https://github.com/streetsidesoftware/cspell-cli - rev: v8.3.0 + rev: v8.6.1 hooks: - id: cspell @@ -75,30 +94,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 4c877ec..440f084 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,13 +45,21 @@ "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.typeCheckingMode": "strict", "python.testing.unittestEnabled": 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/README.md b/README.md index 93f1020..f469a7b 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,6 @@ [![pre-commit.ci status](https://results.pre-commit.ci/badge/github/ComPWA/sphinx-pybtex-etal-style/main.svg)](https://results.pre-commit.ci/latest/github/ComPWA/sphinx-pybtex-etal-style/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 Sphinx extension defines a new bibliography style for the [`sphinxcontrib-bibtex`](https://sphinxcontrib-bibtex.rtfd.io) extension. Install through [PyPI](https://pypi.org) with `pip`: diff --git a/environment.yml b/environment.yml index 662cf4c..b9f5e11 100644 --- a/environment.yml +++ b/environment.yml @@ -2,7 +2,7 @@ name: sphinx-pybtex-etal-style channels: - defaults dependencies: - - python==3.8.* + - python==3.9.* - pip - pip: - -e .[dev] diff --git a/pyproject.toml b/pyproject.toml index 25d3082..90057a3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,6 @@ requires-python = ">=3.7" [project.optional-dependencies] dev = ["sphinx-pybtex-etal-style[sty]"] -format = ["black"] lint = [ "ruff", "sphinx-pybtex-etal-style[mypy]", @@ -50,6 +49,7 @@ mypy = [ ] sty = [ "pre-commit >=1.4.0", + "ruff", "sphinx-pybtex-etal-style[format]", "sphinx-pybtex-etal-style[lint]", ] @@ -79,31 +79,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"] @@ -149,6 +124,16 @@ reportUnusedVariable = true typeCheckingMode = "strict" [tool.ruff] +preview = true +show-fixes = true +src = ["src"] +target-version = "py37" + +[tool.ruff.format] +docstring-code-format = true +line-ending = "lf" + +[tool.ruff.lint] extend-select = [ "A", "B", @@ -193,15 +178,17 @@ ignore = [ "D407", "D416", "E501", + "ISC001", + "PLW1514", "SIM108", "UP036", ] -show-fixes = true -src = ["src"] -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", @@ -212,7 +199,7 @@ task-tags = ["cspell"] "S101", ] -[tool.ruff.pydocstyle] +[tool.ruff.lint.pydocstyle] convention = "google" [tool.tomlsort] diff --git a/src/sphinx_pybtex_etal_style/style.py b/src/sphinx_pybtex_etal_style/style.py index c93b484..14fe465 100644 --- a/src/sphinx_pybtex_etal_style/style.py +++ b/src/sphinx_pybtex_etal_style/style.py @@ -11,7 +11,7 @@ from pybtex.style.template import ( FieldIsMissing, Node, - _format_list, # pyright: ignore[reportPrivateUsage] + _format_list, # pyright: ignore[reportPrivateUsage] # noqa: PLC2701 field, href, join, @@ -74,20 +74,20 @@ class UnsrtEtAl(UnsrtStyle): def __init__(self) -> None: super().__init__(abbreviate_names=True) - def format_names(self, role: Entry, as_sentence: bool = True) -> Node: + def format_names(self, role: Entry, as_sentence: bool = True) -> Node: # noqa: PLR6301 formatted_names = names(role, sep=", ", sep2=" and ", last_sep=", and ") if as_sentence: return sentence[formatted_names] return formatted_names def format_eprint(self, e: Entry) -> Node: - if "doi" in e.fields: - return "" + if "doi" in e.fields: # pyright:ignore[reportOperatorIssue] + return "" # pyright:ignore[reportReturnType] return super().format_eprint(e) - def format_url(self, e: Entry) -> Node: - if "doi" in e.fields or "eprint" in e.fields: - return "" + def format_url(self, e: Entry) -> Node: # noqa: PLR6301 + if "doi" in e.fields or "eprint" in e.fields: # pyright:ignore[reportOperatorIssue] + return "" # pyright:ignore[reportReturnType] return words[ href[ field("url", raw=True), @@ -108,7 +108,7 @@ def format_isbn(self, e: Entry) -> Node: else: msg = ( f"Unknown unsrt_etal_isbn_resolver: {self.isbn_resolver}. Valid options" - f" are {', '.join(ISBNResolvers.__args__)}." + f" are {', '.join(ISBNResolvers.__args__)}." # pyright:ignore[reportAttributeAccessIssue] ) raise NotImplementedError(msg) return href[url, join["ISBN:", field("isbn", raw=True)]]