Skip to content

Commit

Permalink
FIX: define dev dependencies as dependency groups (#11)
Browse files Browse the repository at this point in the history
* DX: recommend pull request VS Code extension
* DX: run `pyright` in `.venv`
* FIX: remove `pre-commit-uv` from environment
* MAINT: address Ruff issues
* MAINT: update lock files
  • Loading branch information
redeboer authored Oct 29, 2024
1 parent 78cbbb0 commit 9922906
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 25 deletions.
1 change: 1 addition & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"mypy",
"pybtex",
"PyPA",
"pyproject",
"PYTHONHASHSEED",
"SymPy"
]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ jobs:
if: inputs.specific-pip-packages == ''
secrets:
token: ${{ secrets.PAT }}
uses: ComPWA/actions/.github/workflows/pre-commit.yml@v2
uses: ComPWA/actions/.github/workflows/pre-commit.yml@v2.1
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ repos:
- id: check-useless-excludes

- repo: https://github.com/ComPWA/policy
rev: 0.5.0
rev: 0.5.5
hooks:
- id: check-dev-files
args:
- --repo-name=sphinx-pybtex-etal-style

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.0
rev: v0.7.1
hooks:
- id: ruff
args: [--fix]
Expand Down Expand Up @@ -64,7 +64,7 @@ repos:
- --in-place

- repo: https://github.com/streetsidesoftware/cspell-cli
rev: v8.15.1
rev: v8.15.2
hooks:
- id: cspell

Expand All @@ -89,6 +89,6 @@ repos:
- python

- repo: https://github.com/ComPWA/pyright-pre-commit
rev: v1.1.385
rev: v1.1.386
hooks:
- id: pyright
1 change: 1 addition & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"editorconfig.editorconfig",
"esbenp.prettier-vscode",
"github.vscode-github-actions",
"github.vscode-pull-request-github",
"mhutchie.git-graph",
"ms-python.mypy-type-checker",
"ms-python.python",
Expand Down
22 changes: 20 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,30 @@ cd sphinx-pybtex-etal-style
Now it's simply a matter of creating and activating the [virtual environment](https://docs.astral.sh/uv/pip/environments) with [`uv sync`](https://docs.astral.sh/uv/reference/cli/#uv-sync). The dependencies for the project are 'pinned' in each commit through the [`uv.lock` file](https://docs.astral.sh/uv/concepts/projects/#project-lockfile).

```shell
uv sync
uv sync --all-extras
source .venv/bin/activate
```

Formatting and linting checks are automatically performed when committing changes. This is done with [pre-commit](https://pre-commit.com). To install the hooks in your local repository, run [`pre-commit install`](https://pre-commit.com/#3-install-the-git-hook-scripts) **once**:
Formatting and linting checks are automatically performed when committing changes. This is done with [pre-commit](https://pre-commit.com). To install the hooks in your local repository, run install `pre-commit` with `uv`:

```shell
uv tool install pre-commit --with pre-commit-uv --force-reinstall
```

and [`pre-commit install`](https://pre-commit.com/#3-install-the-git-hook-scripts) **once**:

```shell
pre-commit install --install-hooks
```

In addition, it may be handy to install `tox`:

```shell
uv tool install tox --with tox-uv
```

If the repository provides a Tox configuration under [`pyproject.toml`](./pyproject.toml), you can see which jobs it defines with:

```shell
tox list
```
30 changes: 13 additions & 17 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,6 @@ maintainers = [{email = "[email protected]"}]
name = "sphinx-pybtex-etal-style"
requires-python = ">=3.9"

[project.optional-dependencies]
dev = ["sphinx-pybtex-etal-style[sty]"]
lint = [
"ruff",
"sphinx-pybtex-etal-style[mypy]",
]
mypy = [
"Sphinx",
"mypy",
]
sty = [
"pre-commit-uv",
"ruff",
"sphinx-pybtex-etal-style[format]",
"sphinx-pybtex-etal-style[lint]",
]

[project.readme]
content-type = "text/markdown"
file = "README.md"
Expand All @@ -62,6 +45,17 @@ Documentation = "https://github.com/ComPWA/sphinx-pybtex-etal-style/blob/main/RE
Source = "https://github.com/ComPWA/sphinx-pybtex-etal-style"
Tracker = "https://github.com/ComPWA/sphinx-pybtex-etal-style/issues"

[dependency-groups]
dev = [
"ruff",
{include-group = "style"},
]
style = [
"mypy",
{include-group = "types"},
]
types = ["sphinx"]

[tool.setuptools]
include-package-data = true
license-files = ["LICENSE"]
Expand Down Expand Up @@ -123,6 +117,8 @@ reportUnusedFunction = true
reportUnusedImport = true
reportUnusedVariable = true
typeCheckingMode = "strict"
venv = ".venv"
venvPath = "."

[tool.ruff]
extend-include = ["*.ipynb"]
Expand Down
2 changes: 1 addition & 1 deletion src/sphinx_pybtex_etal_style/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def format_isbn(self, e: Entry) -> Node: # noqa: ARG002
else:
msg = (
f"Unknown unsrt_etal_isbn_resolver: {self.isbn_resolver}. Valid options"
f" are {', '.join(ISBNResolvers.__args__)}." # pyright:ignore[reportAttributeAccessIssue]
f" are {', '.join(ISBNResolvers.__args__)}."
)
raise NotImplementedError(msg)
return href[url, join["ISBN:", field("isbn", raw=True)]]
Expand Down

0 comments on commit 9922906

Please sign in to comment.