Skip to content

Commit

Permalink
MNT: resolve ruff version sync issues
Browse files Browse the repository at this point in the history
Remove ruff dep from pyproject.toml, since that will be installed

* by pre-commit anyway locally if used
* in CI where it is used to run lint and format checks

Now we make sure that we install the pre-commit ruff version in CI to
have one source of truth for the version.

Hopefully dependabot will support .pre-commit-config.yaml
(dependabot/dependabot-core#1524) some day.
For now we use pre-commit.ci or manual pre-commit autoupdate.
  • Loading branch information
elcorto committed Apr 24, 2024
1 parent b7ad591 commit d24ddd8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
29 changes: 14 additions & 15 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,23 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: install
- name: install deps
run: |
pip install -e ".[test,dask,dev]"
# We run this for each Python version in the matrix which is redundant,
# but since ruff is fast, that's OK. We like to make sure that we install
# the ruff version from pyproject.toml, which we achieve by
#
# pip install -e ".[dev]"
#
# Doing this in another workflow such as lint.yml would install psweep +
# all deps again just for linting.
#
# The alternative would be to say
#
# pip install ruff==<version>
#
# but then we duplicate version information, which has to be maintained.
- name: install ruff
run: |
# Install the ruff version from .pre-commit-config.yaml here. Using
# https://pre-commit.ci/ because of [1] is not fun since dependabot
# and pre-commit.ci don't update at the same time, so ruff versions
# are always out of sync.
#
# [1] https://github.com/dependabot/dependabot-core/issues/1524
ruff_version=$(grep -E -A1 'astral-sh/ruff-pre-commit' \
.pre-commit-config.yaml | sed -nre "s/^\s+rev:.+'v([0-9\.]+)'/\1/p")
[ -n "$ruff_version" ] || echo "error parsing ruff version" && exit 1
pip install "ruff==$ruff_version"
- name: lint
run: |
# Check for lint rules.
Expand Down
6 changes: 2 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@ test = [
"pytest-xdist",
]

# github dependabot takes care of the ruff version here. The one in
# .pre-commit-config.yaml is dealt with by https://pre-commit.ci/ because
# https://github.com/dependabot/dependabot-core/issues/1524 . Well ok, then!
# For installing the correct ruff version in CI, see
# .github/workflows/tests.yml .
dev = [
"pre-commit",
"ruff == 0.4.1",
]


Expand Down

0 comments on commit d24ddd8

Please sign in to comment.