Skip to content

Commit 37fdfd8

Browse files
committed
Set up Ruff, bots, and workflows
1 parent 6a12124 commit 37fdfd8

File tree

6 files changed

+121
-70
lines changed

6 files changed

+121
-70
lines changed

.github/dependabot.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
labels:
8+
- "Internal"

.github/workflows/bot.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: bot
2+
concurrency:
3+
group: ${{ github.workflow }}-${{ github.event.number }}-${{ github.event.ref }}
4+
cancel-in-progress: true
5+
on: # yamllint disable-line rule:truthy
6+
pull_request
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
jobs:
13+
auto-merge:
14+
runs-on: ubuntu-latest
15+
if: (github.event.pull_request.user.login == 'dependabot[bot]' || github.event.pull_request.user.login == 'pre-commit-ci[bot]') && github.repository == 'physiopy/physiopy-repository-template'
16+
steps:
17+
- name: Enable auto-merge for bot PRs
18+
run: gh pr merge --auto --squash "$PR_URL"
19+
env:
20+
PR_URL: ${{ github.event.pull_request.html_url }}
21+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.pre-commit-config.yaml

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,39 @@
1+
ci:
2+
autoupdate_schedule: quarterly
3+
14
# See https://pre-commit.com for more information
25
# See https://pre-commit.com/hooks.html for more hooks
36
repos:
47
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v4.4.0
8+
rev: v6.0.0
69
hooks:
7-
- id: trailing-whitespace
8-
- id: end-of-file-fixer
9-
- id: check-yaml
10-
- id: check-added-large-files
11-
- id: check-case-conflict
12-
- id: check-merge-conflict
13-
- repo: https://github.com/psf/black
14-
rev: 22.10.0
15-
hooks:
16-
- id: black
17-
- repo: https://github.com/pycqa/isort
18-
rev: 5.10.1
19-
hooks:
20-
- id: isort
21-
- repo: https://github.com/pycqa/flake8
22-
rev: 6.0.0
23-
hooks:
24-
- id: flake8
25-
- repo: https://github.com/pycqa/pydocstyle
26-
rev: 6.1.1
27-
hooks:
28-
- id: pydocstyle
10+
- id: trailing-whitespace
11+
- id: end-of-file-fixer
12+
- id: check-yaml
13+
- id: check-added-large-files
14+
- id: check-case-conflict
15+
- id: check-merge-conflict
16+
2917
- repo: https://github.com/pre-commit/pygrep-hooks
30-
rev: v1.9.0
18+
rev: v1.10.0
3119
hooks:
3220
- id: rst-backticks
3321
- id: rst-directive-colons
3422
- id: rst-inline-touching-normal
23+
24+
- repo: https://github.com/codespell-project/codespell
25+
rev: v2.4.1
26+
hooks:
27+
- id: codespell
28+
args: ["-L", "trough,troughs"]
29+
30+
- repo: https://github.com/astral-sh/ruff-pre-commit
31+
rev: v0.12.2
32+
hooks:
33+
- id: ruff
34+
name: ruff linter
35+
args: [--fix]
36+
files: <reponame>
37+
- id: ruff-format
38+
name: ruff formatter
39+
files: <reponame>

README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,26 @@ This repository is meant to be a template for python3 projects.
1313
- Auto release based on Github versioning with Physiopy's labels.
1414
- `.gitattributes` for python
1515
- `.gitignore` for python and containers
16-
- Pre-commit (black, isort, flake8, pydocstyle, and RST documentation)
16+
- Pre-commit (Ruff, codespell, and RST documentation)
1717
- Read the Docs (based on sphinx)
18+
- Duecredit
1819
- Zenodo
1920
- Codecov (for master branch, 90%+)
2021
- Python setup with `extra_require` options
2122
- Versioneer
2223
- Issue templates (bugs, feature requests, generic)
2324
- PR template
24-
- Workflows (Auto release and PyPI upload)
25+
- Workflows & Bots (Dependabot, Labeler, bot automerge, auto author assignment, Auto release, and PyPI upload)
2526

2627
Usage
2728
-----
28-
1. Find and replace the items between `<>`, for instance `<reponame>`
29-
2. Change licence
30-
3. Set up your default pushes to `origin` (`git config remote.pushDefault origin`)
31-
4. Finish setting up everything.
29+
1. Find and replace the items between `<>`, for instance `<reponame>`, throughout all files in the repository.
30+
2. If using outside of physiopy, find all `physiopy`s indicating the owner in github paths, and change it to your handle
31+
3. Change `'physiopy/physiopy-repository-template'` in line 15 of `.github/workflows/bot.yml` into what it needs to be.
32+
3. Change licence and make sure to activate the licence of choice correctly.
33+
4. Set up your default pushes to `origin` (`git config remote.pushDefault origin`)
34+
5. Check setup.cfg
35+
6. Finish setting up everything.
3236

3337
More explanation coming soon.
3438

pyproject.toml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
[tool.coverage.report]
2+
exclude_lines = [
3+
'if __name__ == .__main__.:',
4+
'if TYPE_CHECKING:',
5+
'pragma: no cover',
6+
]
7+
precision = 2
8+
9+
[tool.coverage.run]
10+
branch = true
11+
cover_pylib = false
12+
omit = [
13+
'**/__init__.py',
14+
'**/conftest.py',
15+
'**/**/_version.py',
16+
'**/**/cli/**',
17+
'**/**/due.py',
18+
'**/tests/**',
19+
]
20+
21+
[tool.ruff]
22+
extend-exclude = ['docs', 'versioneer.py', 'setup.py', '_version.py']
23+
line-length = 88
24+
target-version = 'py310'
25+
26+
[tool.ruff.format]
27+
docstring-code-format = true
28+
line-ending = 'lf'
29+
quote-style = "single"
30+
31+
[tool.ruff.lint]
32+
ignore = ['E402', 'F401', 'F811', 'E203', 'E501']
33+
select = ['A', 'B', 'E', 'D', 'F', 'I', 'UP', 'W']
34+
35+
[tool.ruff.lint.pydocstyle]
36+
convention = 'numpy'
37+
38+
[tool.ruff.lint.per-file-ignores]
39+
'*' = [
40+
'B904', # 'Within an except clause, raise exceptions with raise ... from ...'
41+
'UP007', # 'Use `X | Y` for type annotations', requires python 3.10
42+
]
43+
'*.pyi' = ['E501']
44+
'__init__.py' = ['F401']
45+
'_version.py' = ['UP031']
46+
'conftest.py' = ['D']
47+
'due.py' = ['D']
48+
'*/tests/*' = ['D']
49+
'*/__init__.py' = ['F401', 'D']
50+
'*/*/__init__.py' = ['F401', 'D']
51+
'*/_version.py' = ['UP031', 'D']

setup.cfg

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,8 @@ doc =
4444
sphinx_rtd_theme
4545
myst-parser
4646
style =
47-
flake8>=4.0
48-
black<23.0.0
49-
isort<6.0.0
50-
pydocstyle
47+
codespell>=2.2.4
48+
ruff>=0.14.2
5149
test =
5250
%(all)s
5351
%(style)s
@@ -65,42 +63,6 @@ dev =
6563
console_scripts =
6664
<reponame>=<reponame>.workflow:_main
6765

68-
[flake8]
69-
doctest = True
70-
exclude =
71-
_version.py
72-
./<reponame>/cli/__init__.py
73-
./<reponame>/tests/*
74-
versioneer.py
75-
ignore = E126, E402, W503, F401, F811
76-
max-line-length = 88
77-
extend-ignore = E203, E501
78-
extend-select = B950
79-
per-file-ignores =
80-
workflow.py:D401
81-
82-
[isort]
83-
profile = black
84-
skip_gitignore = true
85-
extend_skip =
86-
.autorc
87-
.coverage*
88-
.readthedocs.yml
89-
.zenodo.json
90-
codecov.yml
91-
setup.py
92-
versioneer.py
93-
<reponame>/_version.py
94-
skip_glob =
95-
docs/*
96-
97-
[pydocstyle]
98-
convention = numpy
99-
match =
100-
<reponame>/*.py
101-
match_dir = <reponame>/[^tests]*
102-
103-
10466
[tool:pytest]
10567
doctest_optionflags = NORMALIZE_WHITESPACE
10668
xfail_strict = true

0 commit comments

Comments
 (0)