Skip to content

Commit 1d6bbeb

Browse files
authored
fix: simplify and prepare for next release (#301)
Signed-off-by: Henry Schreiner <[email protected]>
1 parent e03df78 commit 1d6bbeb

File tree

5 files changed

+36
-64
lines changed

5 files changed

+36
-64
lines changed

docs/_includes/interactive_repo_review.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@
2020
<App
2121
header={false}
2222
deps={[
23-
"sp-repo-review==2023.09.21",
23+
"sp-repo-review==2023.10.27",
2424
"repo-review==0.10.0",
25-
"validate-pyproject==0.14",
26-
"scikit-build-core==0.5.1",
25+
"validate-pyproject==0.15",
26+
"scikit-build-core==0.6.0",
27+
"cibuildwheel==2.16.2",
2728
]}
2829
/>,
2930
);

docs/pages/guides/style.md

Lines changed: 29 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,20 @@ Here is the snippet to add Black to your `.pre-commit-config.yml`:
108108

109109
```yaml
110110
- repo: https://github.com/psf/black-pre-commit-mirror
111-
rev: "23.10.0"
111+
rev: "23.10.1"
112112
hooks:
113113
- id: black
114114
```
115115

116116
{% details You can add a Black badge to your repo as well %}
117117

118+
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
119+
118120
```md
119121
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
120122
```
121123

122-
```rst
124+
```
123125
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
124126
:target: https://github.com/psf/black
125127
```
@@ -142,13 +144,13 @@ look like Black, but run 30x faster. Here is the snippet to add Black to your
142144

143145
{% details You can add a Ruff badge to your repo as well %}
144146

145-
[![Code style: Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/format.json))](https://github.com/astral-sh/ruff)
147+
[![Code style: Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/format.json)](https://github.com/astral-sh/ruff)
146148

147149
```md
148-
[![Code style: Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/format.json))](https://github.com/astral-sh/ruff)
150+
[![Code style: Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/format.json)](https://github.com/astral-sh/ruff)
149151
```
150152

151-
```rst
153+
```
152154
.. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/format.json
153155
:target: https://github.com/astral-sh/ruff
154156
```
@@ -157,13 +159,13 @@ look like Black, but run 30x faster. Here is the snippet to add Black to your
157159

158160
{% endtab %} {% endtabs %}
159161

160-
In _very_ specific situations, you may want to retain special formatting. After
161-
carefully deciding that it is a special use case, you can use `# fmt: on` and
162-
`# fmt: off` around a code block to have it keep custom formatting. _Always_
163-
consider refactoring before you try this option! Most of the time, you can find
164-
a way to make the Blacked code look better by rewriting your code; factor out
165-
long unreadable portions into a variable, avoid writing matrices as 1D lists,
166-
etc.
162+
In _very_ specific situations, like when making a 2D array, you may want to
163+
retain special formatting. After carefully deciding that it is a special use
164+
case, you can use `# fmt: on` and `# fmt: off` around a code block to have it
165+
keep custom formatting. _Always_ consider refactoring before you try this
166+
option! Most of the time, you can find a way to make the Blacked code look
167+
better by rewriting your code; factor out long unreadable portions into a
168+
variable, avoid writing matrices as 1D lists, etc.
167169

168170
{% details Documentation / README snippets support %}
169171

@@ -177,7 +179,7 @@ markdown and restructured text. Note that because black is in
177179
rev: "1.16.0"
178180
hooks:
179181
- id: blacken-docs
180-
additional_dependencies: [black==23.10.0]
182+
additional_dependencies: [black==23.*]
181183
```
182184
183185
{% enddetails %}
@@ -195,7 +197,7 @@ pre-commit hook.
195197
196198
```yaml
197199
- repo: https://github.com/astral-sh/ruff-pre-commit
198-
rev: "v0.1.1"
200+
rev: "v0.1.3"
199201
hooks:
200202
- id: ruff
201203
args: ["--fix", "--show-fixes"]
@@ -209,7 +211,6 @@ inspect and undo changes in git.
209211
```toml
210212
[tool.ruff]
211213
src = ["src"]
212-
exclude = []
213214
214215
[tool.ruff.lint]
215216
extend-select = [
@@ -239,15 +240,8 @@ extend-select = [
239240
]
240241
ignore = [
241242
"PLR", # Design related pylint codes
242-
"E501", # Line too long
243-
"PT004", # Use underscore for non-returning fixture (use usefixture instead)
244243
]
245244
typing-modules = ["mypackage._compat.typing"]
246-
unfixable = [
247-
"T20", # Removes print statements
248-
"F841", # Removes unused variables
249-
]
250-
flake8-unused-arguments.ignore-variadic-names = true
251245
isort.required-imports = ["from __future__ import annotations"]
252246
253247
[tool.ruff.lint.per-file-ignores]
@@ -283,7 +277,7 @@ without this).
283277
> ```
284278
>
285279
> This selects the minimum version you want to target (primarily for `"UP"` and
286-
> `"I"`) {% rr RF002 %},
280+
> `"I"`) {% rr RF002 %}
287281

288282
Here are some good error codes to enable on most (but not all!) projects:
289283

@@ -839,7 +833,8 @@ limiting the default checks or by starting off a new project using them, you can
839833
get some very nice linting, including catching some problematic code that
840834
otherwise is hard to catch. PyLint is generally not a good candidate for
841835
pre-commit, since it needs to have your package installed - it is less static of
842-
check than Flake8. Here is a suggested pyproject.toml entry to get you started:
836+
check than Ruff or Flake8. Here is a suggested `pyproject.toml` entry to get you
837+
started:
843838

844839
```toml
845840
[tool.pylint]
@@ -871,34 +866,23 @@ You can replace `src` with the module name.
871866

872867
## Jupyter notebook support
873868

874-
### NBQA
875-
876-
You can adapt most tools to notebooks using
877-
[nbQA](https://github.com/nbQA-dev/nbQA). The most useful one is probably Ruff:
869+
### Ruff
878870

879-
```yaml
880-
- repo: https://github.com/nbQA-dev/nbQA
881-
rev: "1.7.0"
882-
hooks:
883-
- id: nbqa-ruff
884-
additional_dependencies: [ruff==0.0.275]
885-
```
886-
887-
You can pass extra flags to Ruff via the hook, like
888-
`args: ["--extend-ignore=F821,F401"]`.
889-
890-
{: .note-title }
891-
892-
> Native notebook support
893-
>
894-
> Ruff 0.257 added experimental notebook support! You currently have to enable
895-
> checking `.ipynb` files both in Ruff and pre-commit to use it.
871+
Ruff natively supports notebooks. You have to enable checking `.ipynb` files in
872+
pre-commit to use it with `types_or: [python, pyi, jupyter]`. This should be on
873+
both hooks if using both the linter and the formatter.
896874

897875
### Black
898876

899877
For Black, just make sure you use the `id: black-jupyter` hook instead of
900878
`id: black`; that will also include notebooks.
901879

880+
### NBQA
881+
882+
You can adapt other tools to notebooks using
883+
[nbQA](https://github.com/nbQA-dev/nbQA). However, check to see if the tool
884+
natively supports notebooks first, several of them do now.
885+
902886
### Stripping output
903887

904888
You also might like the following hook, which cleans Jupyter outputs:

pyproject.toml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ messages_control.disable = [
135135

136136
[tool.ruff]
137137
src = ["src"]
138-
exclude = []
139138

140139
[tool.ruff.lint]
141140
extend-select = [
@@ -160,15 +159,9 @@ extend-select = [
160159
]
161160
ignore = [
162161
"PLR", # Design related pylint codes
163-
"E501", # Line too long
164162
"PT004", # Incorrect check, usefixtures is the correct way to do this
165163
"RUF012", # Would require a lot of ClassVar's
166164
]
167-
unfixable = [
168-
"T20", # Removes print statements
169-
"F841", # Removes unused variables
170-
]
171-
flake8-unused-arguments.ignore-variadic-names = true
172165

173166
[tool.ruff.lint.flake8-tidy-imports.banned-api]
174167
"typing.Callable".msg = "Use collections.abc.Callable instead."

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ ci:
44

55
repos:
66
- repo: https://github.com/psf/black-pre-commit-mirror
7-
rev: "23.10.0"
7+
rev: "23.10.1"
88
hooks:
99
- id: black-jupyter
1010

1111
- repo: https://github.com/adamchainz/blacken-docs
1212
rev: "1.16.0"
1313
hooks:
1414
- id: blacken-docs
15-
additional_dependencies: [black==23.10.0]
15+
additional_dependencies: [black==23.*]
1616

1717
- repo: https://github.com/pre-commit/pre-commit-hooks
1818
rev: "v4.5.0"
@@ -45,7 +45,7 @@ repos:
4545
args: [--prose-wrap=always]
4646

4747
- repo: https://github.com/astral-sh/ruff-pre-commit
48-
rev: "v0.1.1"
48+
rev: "v0.1.3"
4949
hooks:
5050
- id: ruff
5151
args: ["--fix", "--show-fixes"]

{{cookiecutter.project_name}}/pyproject.toml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -369,13 +369,7 @@ extend-select = [
369369
]
370370
ignore = [
371371
"PLR", # Design related pylint codes
372-
"E501", # Line too long
373372
]
374-
unfixable = [
375-
"T20", # Removes print statements
376-
"F841", # Removes unused variables
377-
]
378-
flake8-unused-arguments.ignore-variadic-names = true
379373
isort.required-imports = ["from __future__ import annotations"]
380374
# Uncomment if using a _compat.typing backport
381375
# typing-modules = ["{{ cookiecutter.__project_slug }}._compat.typing"]

0 commit comments

Comments
 (0)