Skip to content

Commit

Permalink
maint: use ruff for style/linting
Browse files Browse the repository at this point in the history
  • Loading branch information
mgxd committed Aug 29, 2024
1 parent 97060e9 commit 436c903
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 68 deletions.
124 changes: 62 additions & 62 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ name: Build & test
on:
push:
branches:
- main
- main
tags:
- "*"
- "*"
pull_request:
branches:
- main
- main
schedule:
- cron: '0 0 * * 1'
- cron: '0 0 * * 1'

defaults:
run:
Expand All @@ -31,71 +31,71 @@ jobs:
commit_message: ${{ steps.get_commit_message.outputs.commit_message }}
version: ${{ steps.show_version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Print head git commit message
id: get_commit_message
run: |
if [[ -z "$COMMIT_MSG" ]]; then
COMMIT_MSG=$(git show -s --format=%s $REF)
fi
echo commit_message=$COMMIT_MSG | tee -a $GITHUB_OUTPUT
env:
COMMIT_MSG: ${{ github.event.head_commit.message }}
REF: ${{ github.event.pull_request.head.sha }}
- name: Detect version
id: show_version
run: |
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
VERSION=${GITHUB_REF##*/}
else
pipx run hatch version # Once to avoid output of initial setup
VERSION=$( pipx run hatch version )
fi
echo version=$VERSION | tee -a $GITHUB_OUTPUT
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Print head git commit message
id: get_commit_message
run: |
if [[ -z "$COMMIT_MSG" ]]; then
COMMIT_MSG=$(git show -s --format=%s $REF)
fi
echo commit_message=$COMMIT_MSG | tee -a $GITHUB_OUTPUT
env:
COMMIT_MSG: ${{ github.event.head_commit.message }}
REF: ${{ github.event.pull_request.head.sha }}
- name: Detect version
id: show_version
run: |
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
VERSION=${GITHUB_REF##*/}
else
pipx run hatch version # Once to avoid output of initial setup
VERSION=$( pipx run hatch version )
fi
echo version=$VERSION | tee -a $GITHUB_OUTPUT
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3
- name: Display Python information
run: python -c "import sys; print(sys.version)"
- name: Build sdist and wheel
run: pipx run build
- name: Check release tools
run: pipx run twine check dist/*
- name: Save build output
uses: actions/upload-artifact@v3
with:
name: dist
path: dist/
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3
- name: Display Python information
run: python -c "import sys; print(sys.version)"
- name: Build sdist and wheel
run: pipx run build
- name: Check release tools
run: pipx run twine check dist/*
- name: Save build output
uses: actions/upload-artifact@v3
with:
name: dist
path: dist/

test:
needs: [job_metadata, build]
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
install: [repo]
include:
- python-version: "3.11"
install: sdist
- python-version: "3.11"
install: wheel
- python-version: "3.11"
install: editable
- python-version: "3.12"
install: sdist
- python-version: "3.12"
install: wheel
- python-version: "3.12"
install: editable
env:
INSTALL_TYPE: ${{ matrix.install }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
if: matrix.install == 'repo' || matrix.install == 'editable'
with:
fetch-depth: 0
Expand Down Expand Up @@ -138,11 +138,11 @@ jobs:
needs: test
if: github.repository == 'nipreps/synthstrip' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/download-artifact@v3
with:
name: dist
path: dist/
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
- uses: actions/download-artifact@v3
with:
name: dist
path: dist/
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
52 changes: 46 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
requires-python = ">=3.8"
dependencies = [
Expand All @@ -36,8 +37,7 @@ Homepage = "https://github.com/nipreps/synthstrip"

[project.optional-dependencies]
dev = [
"black",
"isort",
"ruff",
"hatch",
]
nipype = [
Expand All @@ -63,9 +63,49 @@ version-file = "nipreps/synthstrip/_version.py"
"nipreps/synthstrip" = "nipreps/synthstrip"

[tool.black]
exclude = '.*'

[tool.ruff]
line-length = 99
target-version = ['py310']
skip-string-normalization = true

[tool.isort]
profile = 'black'
[tool.ruff.lint]
extend-select = [
"F",
"E",
"W",
"I",
"UP",
"YTT",
"S",
"BLE",
"B",
"A",
# "CPY",
"C4",
"DTZ",
"T10",
# "EM",
"EXE",
"FA",
"ISC",
"ICN",
"PT",
"Q",
]
ignore = [
"S311", # We are not using random for cryptographic purposes
"ISC001",
"S603",
]

[tool.ruff.lint.flake8-quotes]
inline-quotes = "single"

[tool.ruff.format]
quote-style = "single"

[tool.coverage.run]
branch = true
omit = [
"*/_version.py"
]

0 comments on commit 436c903

Please sign in to comment.