Skip to content

Commit 7cb6fd4

Browse files
authored
πŸ§‘β€πŸ’» dprint formatter for markdown, json, toml and yaml (#688)
2 parents 0667281 + 067d0ad commit 7cb6fd4

File tree

9 files changed

+214
-201
lines changed

9 files changed

+214
-201
lines changed

β€Ž.dprint.jsonc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"json": {
3+
"lineWidth": 100,
4+
"array.preferSingleLine": true,
5+
"jsonTrailingCommaFiles": [".vscode/extensions.json", ".vscode/settings.json"],
6+
},
7+
"markdown": {
8+
"lineWidth": 200,
9+
"emphasisKind": "asterisks",
10+
},
11+
"toml": {
12+
"lineWidth": 100,
13+
},
14+
"yaml": {
15+
"printWidth": 100,
16+
"formatComments": true,
17+
// "indentBlockSequenceInMap": false,
18+
"braceSpacing": false,
19+
},
20+
"excludes": ["**/*-lock.json", "**/*.lock", "**/node_modules/", "dist/"],
21+
"plugins": [
22+
"https://plugins.dprint.dev/g-plane/pretty_yaml-v0.5.1.wasm",
23+
"https://plugins.dprint.dev/json-0.20.0.wasm",
24+
"https://plugins.dprint.dev/markdown-0.19.0.wasm",
25+
"https://plugins.dprint.dev/toml-0.7.0.wasm",
26+
],
27+
}

β€Ž.github/workflows/ci.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,11 @@ jobs:
2929
with:
3030
plugins: sp-repo-review
3131

32-
- name: markdownlint
33-
uses: DavidAnson/markdownlint-cli2-action@v20
34-
with:
35-
config: ".markdownlint.yaml"
36-
globs: "**/*.md"
32+
- name: dprint
33+
uses: dprint/[email protected]
3734

3835
- name: typos
39-
uses: crate-ci/typos@master
36+
uses: crate-ci/typos@v1.33.1
4037

4138
- uses: astral-sh/setup-uv@v6
4239
with:

β€Ž.markdownlint.yaml

Lines changed: 0 additions & 29 deletions
This file was deleted.

β€Ž.vscode/extensions.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@
22
"recommendations": [
33
"charliermarsh.ruff",
44
"detachhead.basedpyright",
5+
"dprint.dprint",
56
"ms-python.mypy-type-checker",
67
"ms-python.python",
78
"seatonjiang.gitmoji-vscode",
8-
"tamasfe.even-better-toml"
99
],
10-
"unwantedRecommendations": [
11-
"ms-pyright.pyright",
12-
"ms-python.vscode-pylance"
13-
]
10+
"unwantedRecommendations": ["ms-pyright.pyright", "ms-python.vscode-pylance"],
1411
}

β€Ž.vscode/settings.json

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,45 @@
11
{
2-
"[json][jsonc][yaml][yml]": {
3-
"editor.tabSize": 2
2+
"[json]": {
3+
"editor.defaultFormatter": "dprint.dprint",
4+
"editor.rulers": [100],
5+
"editor.tabSize": 2,
6+
},
7+
"[jsonc]": {
8+
"editor.defaultFormatter": "dprint.dprint",
9+
"editor.rulers": [100],
10+
"editor.tabSize": 2,
411
},
512
"[markdown]": {
6-
"editor.rulers": [
7-
200
8-
]
13+
"editor.defaultFormatter": "dprint.dprint",
14+
"editor.rulers": [200],
915
},
1016
"[python]": {
11-
"editor.rulers": [
12-
130
13-
]
17+
"editor.rulers": [130],
18+
"editor.tabSize": 4,
1419
},
1520
"[toml]": {
16-
"editor.rulers": [
17-
100
18-
]
21+
"editor.defaultFormatter": "dprint.dprint",
22+
"editor.rulers": [100],
23+
"editor.tabSize": 2,
24+
},
25+
"[yaml]": {
26+
"editor.defaultFormatter": "dprint.dprint",
27+
"editor.rulers": [100],
28+
"editor.tabSize": 2,
29+
},
30+
"[yml]": {
31+
"editor.defaultFormatter": "dprint.dprint",
32+
"editor.rulers": [100],
33+
"editor.tabSize": 2,
1934
},
20-
"editor.tabSize": 4,
21-
"evenBetterToml.formatter.alignComments": true,
22-
"evenBetterToml.formatter.allowedBlankLines": 2,
23-
"evenBetterToml.formatter.arrayTrailingComma": true,
24-
"evenBetterToml.formatter.columnWidth": 100,
25-
"evenBetterToml.formatter.compactArrays": true,
26-
"evenBetterToml.formatter.compactInlineTables": true,
27-
"evenBetterToml.formatter.indentString": " ",
28-
"evenBetterToml.formatter.indentTables": true,
29-
"evenBetterToml.formatter.trailingNewline": true,
35+
"dprint.path": ".venv/bin/dprint",
3036
"mypy-type-checker.path": [
3137
"uv",
3238
"run",
3339
"--frozen",
3440
"--isolated",
3541
"--no-editable",
3642
"--refresh-package=scipy-stubs",
37-
"mypy"
38-
]
43+
"mypy",
44+
],
3945
}

β€ŽREADME.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,32 +89,32 @@ conda install conda-forge::scipy-typed
8989
### Q: Do I need to change my existing code?
9090

9191
**A:** No! `scipy-stubs` works with your existing code without any modifications.
92-
Just install it and your type checker and IDE will automatically use the type information.
92+
Just install it and your type checker and IDE will automatically use the type information.
9393

9494
### Q: Will this slow down my code?
9595

9696
**A:** Not at all. Type stubs are only used during development and type checking.
97-
They have zero runtime overhead since they're not imported when your code runs.
97+
They have zero runtime overhead since they're not imported when your code runs.
9898

9999
### Q: What if I don't use type hints in my code?
100100

101101
**A:** You'll still benefit! Your IDE will provide better autocompletion and error detection
102-
even without explicit type annotations in your code.
102+
even without explicit type annotations in your code.
103103

104104
### Q: Can I use this with Jupyter notebooks?
105105

106106
**A:** Yes! Most modern Jupyter environments (JupyterLab, VS Code notebooks) support
107-
type checking and will benefit from `scipy-stubs`.
107+
type checking and will benefit from `scipy-stubs`.
108108

109109
### Q: What's the difference between this and the built-in scipy typing?
110110

111111
**A:** SciPy itself has limited type annotations. `scipy-stubs` provides comprehensive,
112-
precise type information for the entire SciPy API, including shape-typing and advanced type features.
112+
precise type information for the entire SciPy API, including shape-typing and advanced type features.
113113

114114
### Q: How do I know if it's working?
115115

116116
**A:** You should see improved autocompletion in your IDE and more precise type information.
117-
You can also run `pyright` or another type checker on your code to see type checking in action.
117+
You can also run `pyright` or another type checker on your code to see type checking in action.
118118

119119
### Q: How much of SciPy is covered?
120120

@@ -123,8 +123,8 @@ conda install conda-forge::scipy-typed
123123
### Q: What static type-checkers are supported?
124124

125125
**A:** `scipy-stubs` is compatible with [`pyright`](https://pyright.readthedocs.io/en/latest/index.html) (a.k.a. pylance),
126-
[`basedpyright`](https://github.com/DetachHead/basedpyright), and [`mypy`](https://github.com/python/mypy).
127-
We only support the latest versions of these type-checkers, so make sure to keep them up to date.
126+
[`basedpyright`](https://github.com/DetachHead/basedpyright), and [`mypy`](https://github.com/python/mypy).
127+
We only support the latest versions of these type-checkers, so make sure to keep them up to date.
128128

129129
## Versioning and requirements
130130

β€Žlefthook.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ templates:
44
pre-commit:
55
parallel: true
66
jobs:
7+
- name: dprint
8+
glob: "*.{json,jsonc,md,toml,yaml,yml}"
9+
stage_fixed: true
10+
run: uv {run} dprint fmt --incremental=false
711
- name: ruff
812
glob: "*.{py,pyi}"
913
stage_fixed: true

0 commit comments

Comments
Β (0)