Skip to content

Commit df3c15e

Browse files
Add ruff and refurb to hooks and fix CI banner. (#29)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Tobias Raabe <[email protected]>
1 parent 12644c8 commit df3c15e

File tree

8 files changed

+110
-107
lines changed

8 files changed

+110
-107
lines changed

.pre-commit-config.yaml

+11-42
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ exclude: |
55
66
repos:
77
- repo: https://github.com/pre-commit/pre-commit-hooks
8-
rev: v4.3.0
8+
rev: v4.4.0
99
hooks:
1010
- id: check-added-large-files
1111
args: ['--maxkb=25']
@@ -34,11 +34,6 @@ repos:
3434
- id: python-no-log-warn
3535
- id: python-use-type-annotations
3636
- id: text-unicode-replacement-char
37-
- repo: https://github.com/asottile/pyupgrade
38-
rev: v3.2.2
39-
hooks:
40-
- id: pyupgrade
41-
args: [--py37-plus]
4237
- repo: https://github.com/asottile/reorder_python_imports
4338
rev: v3.9.0
4439
hooks:
@@ -52,44 +47,26 @@ repos:
5247
{{cookiecutter.project_slug}}/setup.cfg
5348
)$
5449
- repo: https://github.com/psf/black
55-
rev: 22.10.0
50+
rev: 22.12.0
5651
hooks:
5752
- id: black
5853
- repo: https://github.com/PyCQA/docformatter
59-
rev: v1.5.0
54+
rev: v1.5.1
6055
hooks:
6156
- id: docformatter
6257
args: [--in-place, --wrap-summaries, "88", --wrap-descriptions, "88", --blank]
63-
- repo: https://github.com/PyCQA/flake8
64-
rev: 5.0.4
58+
- repo: https://github.com/charliermarsh/ruff-pre-commit
59+
rev: v0.0.205
6560
hooks:
66-
- id: flake8
67-
additional_dependencies: [
68-
flake8-alfred,
69-
flake8-bugbear,
70-
flake8-builtins,
71-
flake8-comprehensions,
72-
flake8-docstrings,
73-
flake8-eradicate,
74-
flake8-print,
75-
flake8-pytest-style,
76-
flake8-todo,
77-
flake8-typing-imports,
78-
flake8-unused-arguments,
79-
pep8-naming,
80-
pydocstyle,
81-
Pygments,
82-
]
61+
- id: ruff
62+
args: [hooks, tests]
63+
pass_filenames: false
8364
- repo: https://github.com/dosisod/refurb
84-
rev: v1.5.0
65+
rev: v1.9.1
8566
hooks:
8667
- id: refurb
8768
args: [--ignore, FURB126]
8869
exclude: ({{cookiecutter.project_slug}})
89-
- repo: https://github.com/guilatrova/tryceratops
90-
rev: v1.1.0
91-
hooks:
92-
- id: tryceratops
9370
- repo: https://github.com/econchick/interrogate
9471
rev: 1.5.0
9572
hooks:
@@ -104,10 +81,6 @@ repos:
10481
"{{cookiecutter.project_slug}}/tests/test_import.py"
10582
]
10683
pass_filenames: false
107-
- repo: https://github.com/codespell-project/codespell
108-
rev: v2.1.0
109-
hooks:
110-
- id: codespell
11184
- repo: https://github.com/executablebooks/mdformat
11285
rev: 0.7.16
11386
hooks:
@@ -141,13 +114,9 @@ repos:
141114
rev: v2.2.2
142115
hooks:
143116
- id: codespell
144-
- repo: https://github.com/guilatrova/tryceratops
145-
rev: v1.1.0
146-
hooks:
147-
- id: tryceratops
148-
exclude: "{{cookiecutter.project_slug}}/pyproject.toml"
117+
additional_dependencies: [tomli]
149118
- repo: https://github.com/pre-commit/mirrors-mypy
150-
rev: 'v0.990'
119+
rev: 'v0.991'
151120
hooks:
152121
- id: mypy
153122
args: [

cookiecutter.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"project_description": "A project for ...",
77
"github_username": "{{ cookiecutter.author.lower().replace(' ', '') }}",
88
"github_email": "{{ cookiecutter.email }}",
9-
"python_version": "3.8",
9+
"python_version": "3.10",
1010
"add_tox": ["yes", "no"],
1111
"add_github_actions": ["yes", "no"],
1212
"add_mypy": ["yes", "no"],

docs/source/changes.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
This is a record of all past cookiecutter-pytask-project releases and what went into
44
them in reverse chronological order.
55

6+
## 1.4.0 - 2023-xx-xx
7+
8+
- {pull}`29` adds ruff and refurb to pre-commits and fixes CI banner.
9+
610
## 1.3.0 - 2022-11-20
711

812
- {pull}`22` removes sphinx-click and renames docs environment to

pyproject.toml

+39-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
[build-system]
22
requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.0"]
3+
build-backend = "setuptools.build_meta"
34

45

56
[tool.setuptools_scm]
67
write_to = "version.py"
78

89

9-
[tool.tryceratops]
10-
ignore = ["TC003"]
11-
12-
1310
[tool.mypy]
1411
files = ["hooks", "tests"]
1512
exclude = "{{cookiecutter.project_slug}}"
@@ -26,3 +23,41 @@ warn_unused_ignores = true
2623
module = "tests.*"
2724
disallow_untyped_defs = false
2825
ignore_errors = true
26+
27+
28+
[tool.ruff]
29+
target-version = "py37"
30+
select = ["ALL"]
31+
fix = true
32+
extend-ignore = [
33+
# Numpy docstyle
34+
"D107",
35+
"D203",
36+
"D212",
37+
"D213",
38+
"D402",
39+
"D413",
40+
"D415",
41+
"D416",
42+
"D417",
43+
# Others.
44+
"D404", # Do not start module docstring with "This".
45+
"RET504", # unnecessary variable assignment before return.
46+
"S101", # raise errors for asserts.
47+
"B905", # strict parameter for zip that was implemented in py310.
48+
"I", # ignore isort
49+
"ANN101", # type annotating self
50+
"ANN102", # type annotating cls
51+
"FBT", # flake8-boolean-trap
52+
"EM", # flake8-errmsg
53+
"ANN401", # flake8-annotate typing.Any
54+
"PD", # pandas-vet
55+
]
56+
57+
58+
[tool.ruff.per-file-ignores]
59+
"tests/*" = ["D", "ANN"]
60+
61+
62+
[tool.ruff.pydocstyle]
63+
convention = "numpy"

tox.ini

-12
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,6 @@ commands =
3232
sphinx-build -T -b html -d {envtmpdir}/doctrees . {envtmpdir}/html
3333
- sphinx-build -T -b linkcheck -d {envtmpdir}/doctrees . {envtmpdir}/linkcheck
3434

35-
[flake8]
36-
docstring-convention = numpy
37-
ignore =
38-
D ; ignore missing docstrings.
39-
E203 ; ignore whitespace around : which is enforced by Black.
40-
W503 ; ignore linebreak before binary operator which is enforced by Black.
41-
PT006 ; ignore that parametrizing tests with tuple argument names is preferred.
42-
max-line-length = 88
43-
pytest-mark-no-parentheses = true
44-
warn-symbols =
45-
pytest.mark.wip = Remove 'wip' mark for tests.
46-
4735
[pytest]
4836
addopts = --doctest-modules
4937
testpaths =

{{cookiecutter.project_slug}}/.pre-commit-config.yaml

+17-36
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.3.0
3+
rev: v4.4.0
44
hooks:
55
- id: check-added-large-files
66
args: ['--maxkb=25']
@@ -25,7 +25,7 @@ repos:
2525
- id: python-use-type-annotations
2626
- id: text-unicode-replacement-char
2727
- repo: https://github.com/asottile/pyupgrade
28-
rev: v3.2.2
28+
rev: v3.3.1
2929
hooks:
3030
- id: pyupgrade
3131
args: [--py37-plus]
@@ -39,54 +39,31 @@ repos:
3939
hooks:
4040
- id: setup-cfg-fmt
4141
- repo: https://github.com/psf/black
42-
rev: 22.10.0
42+
rev: 22.12.0
4343
hooks:
4444
- id: black
4545
- repo: https://github.com/PyCQA/docformatter
46-
rev: v1.5.0
46+
rev: v1.5.1
4747
hooks:
4848
- id: docformatter
4949
args: [--in-place, --wrap-summaries, "88", --wrap-descriptions, "88", --blank]
50-
- repo: https://github.com/PyCQA/flake8
51-
rev: 5.0.4
50+
{% if cookiecutter.python_version in ["3.10", "3.11", "3.12"] %}- repo: https://github.com/charliermarsh/ruff-pre-commit
51+
rev: v0.0.205
5252
hooks:
53-
- id: flake8
54-
additional_dependencies: [
55-
flake8-alfred,
56-
flake8-bugbear,
57-
flake8-builtins,
58-
flake8-comprehensions,
59-
flake8-docstrings,
60-
flake8-eradicate,
61-
flake8-print,
62-
flake8-pytest-style,
63-
flake8-todo,
64-
flake8-typing-imports,
65-
flake8-unused-arguments,
66-
pep8-naming,
67-
pydocstyle,
68-
Pygments,
69-
]
70-
{% if cookiecutter.python_version in ["3.10", "3.11", "3.12"] %}- repo: https://github.com/dosisod/refurb
71-
rev: v1.5.0
53+
- id: ruff
54+
- repo: https://github.com/dosisod/refurb
55+
rev: v1.9.1
7256
hooks:
7357
- id: refurb
7458
args: [--ignore, FURB126]
75-
{% endif %}- repo: https://github.com/guilatrova/tryceratops
76-
rev: v1.1.0
77-
hooks:
78-
- id: tryceratops
59+
{% endif %}
7960
- repo: https://github.com/econchick/interrogate
8061
rev: 1.5.0
8162
hooks:
8263
- id: interrogate
8364
args: [-v, --fail-under=40]
84-
- repo: https://github.com/codespell-project/codespell
85-
rev: v2.1.0
86-
hooks:
87-
- id: codespell
8865
- repo: https://github.com/executablebooks/mdformat
89-
rev: 0.7.14
66+
rev: 0.7.16
9067
hooks:
9168
- id: mdformat
9269
additional_dependencies: [
@@ -111,15 +88,19 @@ repos:
11188
# path/to/file.py
11289
# )$
11390
{% if cookiecutter.add_mypy == "yes" %}- repo: https://github.com/pre-commit/mirrors-mypy
114-
rev: 'v0.990'
91+
rev: 'v0.991'
11592
hooks:
11693
- id: mypy
11794
args: [
11895
--no-strict-optional,
11996
--ignore-missing-imports,
12097
]
12198
pass_filenames: false
122-
{% endif %}- repo: meta
99+
{% endif %}- repo: https://github.com/codespell-project/codespell
100+
rev: v2.2.2
101+
hooks:
102+
- id: codespell
103+
- repo: meta
123104
hooks:
124105
- id: check-hooks-apply
125106
- id: check-useless-excludes

{{cookiecutter.project_slug}}/pyproject.toml

+38
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,41 @@ ignore_errors = true
2626

2727
[tool.pytask.ini_options]
2828
paths = "./src/{{ cookiecutter.project_slug }}"
29+
30+
31+
[tool.ruff]
32+
target-version = "py{{ cookiecutter.python_version | replace('.', '') }}"
33+
select = ["ALL"]
34+
fix = true
35+
extend-ignore = [
36+
# Numpy docstyle
37+
"D107",
38+
"D203",
39+
"D212",
40+
"D213",
41+
"D402",
42+
"D413",
43+
"D415",
44+
"D416",
45+
"D417",
46+
# Others.
47+
"D404", # Do not start module docstring with "This".
48+
"RET504", # unnecessary variable assignment before return.
49+
"S101", # raise errors for asserts.
50+
"B905", # strict parameter for zip that was implemented in py310.
51+
"I", # ignore isort
52+
"ANN101", # type annotating self
53+
"ANN102", # type annotating cls
54+
"FBT", # flake8-boolean-trap
55+
"EM", # flake8-errmsg
56+
"ANN401", # flake8-annotate typing.Any
57+
"PD", # pandas-vet
58+
]
59+
60+
61+
[tool.ruff.per-file-ignores]
62+
"tests/*" = ["D", "ANN"]
63+
64+
65+
[tool.ruff.pydocstyle]
66+
convention = "numpy"

{{cookiecutter.project_slug}}/tox.ini

-12
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,6 @@ conda_deps =
2121
commands =
2222
pytest {posargs}
2323

24-
[flake8]
25-
docstring-convention = numpy
26-
ignore =
27-
D ; ignore missing docstrings.
28-
E203 ; ignore whitespace around : which is enforced by Black.
29-
W503 ; ignore linebreak before binary operator which is enforced by Black.
30-
PT006 ; ignore that parametrizing tests with tuple argument names is preferred.
31-
max-line-length = 88
32-
pytest-mark-no-parentheses = true
33-
warn-symbols =
34-
pytest.mark.wip = Remove 'wip' mark for tests.
35-
3624
[pytest]
3725
addopts = --doctest-modules
3826
filterwarnings =

0 commit comments

Comments
 (0)