Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAINT: autoupdate pre-commit hooks #7

Merged
merged 5 commits into from
Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"conda",
"mypy",
"pybtex",
"PyPA",
"PYTHONHASHSEED",
"SymPy"
]
Expand Down
16 changes: 14 additions & 2 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
23 changes: 2 additions & 21 deletions .github/workflows/pr-linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected] # cspell:ignore kode
lint-pr:
uses: ComPWA/actions/.github/workflows/pr-linting.yml@v1
2 changes: 1 addition & 1 deletion .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
54 changes: 25 additions & 29 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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

Expand All @@ -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
8 changes: 4 additions & 4 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
16 changes: 12 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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,
Expand All @@ -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"
}
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`:
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: sphinx-pybtex-etal-style
channels:
- defaults
dependencies:
- python==3.8.*
- python==3.9.*
- pip
- pip:
- -e .[dev]
Expand Down
49 changes: 18 additions & 31 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]",
Expand All @@ -50,6 +49,7 @@ mypy = [
]
sty = [
"pre-commit >=1.4.0",
"ruff",
"sphinx-pybtex-etal-style[format]",
"sphinx-pybtex-etal-style[lint]",
]
Expand Down Expand Up @@ -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"]
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -212,7 +199,7 @@ task-tags = ["cspell"]
"S101",
]

[tool.ruff.pydocstyle]
[tool.ruff.lint.pydocstyle]
convention = "google"

[tool.tomlsort]
Expand Down
16 changes: 8 additions & 8 deletions src/sphinx_pybtex_etal_style/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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),
Expand All @@ -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)]]
Expand Down
Loading