Skip to content

Commit 936e5b0

Browse files
authored
🔧 .toml auto-format config for vscode users (#444)
2 parents 23cd0a3 + 0a09dd7 commit 936e5b0

File tree

4 files changed

+89
-85
lines changed

4 files changed

+89
-85
lines changed

‎.vscode/extensions.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
"charliermarsh.ruff",
44
"detachhead.basedpyright",
55
"ms-python.mypy-type-checker",
6-
"ms-python.python"
6+
"ms-python.python",
7+
"tamasfe.even-better-toml",
8+
"tekumara.typos-vscode"
79
],
810
"unwantedRecommendations": ["ms-pyright.pyright", "ms-python.vscode-pylance"]
911
}

‎.vscode/settings.json

+16-20
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,30 @@
11
{
2-
"[json]": {
2+
"[json|jsonc|yaml|yml]": {
33
"editor.tabSize": 2
44
},
5-
"[jsonc]": {
6-
"editor.tabSize": 2
7-
},
8-
"[markdown]": {
5+
"[markdown|python]": {
96
"editor.rulers": [130]
107
},
11-
"[python]": {
12-
"editor.rulers": [130]
8+
"[toml]": {
9+
"editor.rulers": [100],
10+
"editor.tabSize": 4
1311
},
14-
"[yaml]": {
15-
"editor.autoIndent": "advanced",
16-
"editor.tabSize": 2
17-
},
18-
"editor.rulers": [88],
19-
"editor.tabSize": 4,
20-
"git.branchProtection": ["master"],
21-
"mypy-type-checker.args": [
22-
"--ide",
23-
"--config-file=${workspaceFolder}/pyproject.toml"
24-
],
25-
"mypy-type-checker.cwd": "${fileDirname}",
12+
"evenBetterToml.formatter.alignComments": true,
13+
"evenBetterToml.formatter.allowedBlankLines": 2,
14+
"evenBetterToml.formatter.arrayTrailingComma": true,
15+
"evenBetterToml.formatter.columnWidth": 100,
16+
"evenBetterToml.formatter.compactArrays": true,
17+
"evenBetterToml.formatter.compactInlineTables": true,
18+
"evenBetterToml.formatter.indentString": " ",
19+
"evenBetterToml.formatter.indentTables": true,
20+
"evenBetterToml.formatter.trailingNewline": true,
21+
"mypy-type-checker.args": ["--ide"],
2622
"mypy-type-checker.path": [
2723
"uv",
2824
"run",
2925
"--frozen",
30-
"--no-editable",
3126
"--isolated",
27+
"--no-editable",
3228
"--refresh-package=scipy-stubs",
3329
"mypy"
3430
]

‎pyproject.toml

+68-63
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ classifiers = [
3535
requires-python = ">=3.10"
3636
dependencies = ["optype>=0.9.0"]
3737

38-
[project.optional-dependencies]
39-
scipy = ["scipy>=1.15.1,<1.16"]
38+
[project.optional-dependencies]
39+
scipy = ["scipy>=1.15.1,<1.16"]
4040

41-
[project.urls]
42-
Homepage = "https://scipy.org/"
43-
Repository = "https://github.com/jorenham/scipy-stubs/"
44-
Issues = "https://github.com/jorenham/scipy-stubs/issues"
45-
Changelog = "https://github.com/jorenham/scipy-stubs/releases"
41+
[project.urls]
42+
Homepage = "https://scipy.org/"
43+
Repository = "https://github.com/jorenham/scipy-stubs/"
44+
Issues = "https://github.com/jorenham/scipy-stubs/issues"
45+
Changelog = "https://github.com/jorenham/scipy-stubs/releases"
4646

4747

4848
[dependency-groups]
@@ -76,9 +76,10 @@ dev = [
7676
[tool.hatch.build]
7777
packages = ["scipy-stubs"]
7878

79-
[tool.hatch.build.targets.sdist]
80-
exclude = ["CODE_OF_CONDUCT.md", "README.md", "SECURITY.md", "uv.lock"]
81-
force-include = {".mypyignore" = ".mypyignore"} # for scipy-stubs-feedstock
79+
[tool.hatch.build.targets.sdist]
80+
exclude = ["CODE_OF_CONDUCT.md", "README.md", "SECURITY.md", "uv.lock"]
81+
force-include = {".mypyignore" = ".mypyignore"} # for scipy-stubs-feedstock
82+
8283

8384
[tool.poe.tasks.clean]
8485
cmd = """
@@ -123,22 +124,25 @@ args = [
123124
{name = "path", positional = true, multiple = false, default = "scipy-stubs"},
124125
]
125126

127+
126128
[tool.typos.files]
127129
extend-exclude = ["*.pyi", ".mypyignore"]
128130

131+
129132
[tool.mypy]
130133
files = ["codegen/**/*.py", "scripts/**/*.py", "tests/**/*.py", "scipy-stubs/**/*.pyi"]
131-
exclude = ['^\.git$', '^\.ruff_cache$','^\.tox$']
134+
exclude = ['^\.git$', '^\.ruff_cache$', '^\.tox$']
132135
python_version = "3.10"
133136
plugins = ["numpy.typing.mypy_plugin"]
134137
strict = true
135138
disable_bytearray_promotion = true
136139
disable_memoryview_promotion = true
137140
warn_unreachable = false
138141
warn_unused_ignores = false
139-
disallow_any_explicit = false # no other way to type e.g. `float64 <: number[Any]`
142+
disallow_any_explicit = false # no other way to type e.g. `float64 <: number[Any]`
140143
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
141144

145+
142146
[tool.pyright]
143147
include = ["scipy-stubs", "codegen", "scripts", "tests"]
144148
ignore = [".venv"]
@@ -152,25 +156,25 @@ typeCheckingMode = "strict"
152156
deprecateTypingAliases = true
153157
enableReachabilityAnalysis = false
154158
enableTypeIgnoreComments = false
155-
failOnWarnings = true # based
159+
failOnWarnings = true # based
156160
reportCallInDefaultInitializer = true
157-
reportIgnoreCommentWithoutRule = true # based
158-
reportImplicitAbstractClass = true # based
161+
reportIgnoreCommentWithoutRule = true # based
162+
reportImplicitAbstractClass = true # based
159163
reportImplicitOverride = true
160-
reportImplicitRelativeImport = true # based
164+
reportImplicitRelativeImport = true # based
161165
reportImplicitStringConcatenation = false # based, but I disagree
162166
reportImportCycles = true
163-
reportInvalidCast = true # based
164-
reportInvalidStubStatement = false # see execution environments
167+
reportInvalidCast = true # based
168+
reportInvalidStubStatement = false # see execution environments
165169
reportMissingSuperCall = true
166-
reportPrivateLocalImportUsage = true # based
170+
reportPrivateLocalImportUsage = true # based
167171
reportPrivateUsage = false
168172
reportPropertyTypeMismatch = false
169173
reportShadowedImports = true
170-
reportUnannotatedClassAttribute = true # based
174+
reportUnannotatedClassAttribute = true # based
171175
reportUninitializedInstanceVariable = true
172176
reportUnnecessaryTypeIgnoreComment = true # mypy compat
173-
strictGenericNarrowing = true # based
177+
strictGenericNarrowing = true # based
174178

175179
[[executionEnvironments]]
176180
root = "scipy-stubs"
@@ -179,21 +183,21 @@ reportUnusedCallResult = true
179183

180184
[[executionEnvironments]]
181185
root = "codegen"
182-
reportAny = true # based
183-
reportExplicitAny = true # based
186+
reportAny = true # based
187+
reportExplicitAny = true # based
184188
reportInvalidStubStatement = true
185189
reportPrivateUsage = true
186190
reportUnreachable = true
187-
reportUnsafeMultipleInheritance = true # based
191+
reportUnsafeMultipleInheritance = true # based
188192
reportUnusedCallResult = true
189193

190194
[[executionEnvironments]]
191195
root = "tests"
192-
reportAny = true # based
193-
reportExplicitAny = true # based
196+
reportAny = true # based
197+
reportExplicitAny = true # based
194198
reportPrivateUsage = true
195199
reportUnreachable = true
196-
reportUnsafeMultipleInheritance = true # based
200+
reportUnsafeMultipleInheritance = true # based
197201

198202

199203
[tool.repo-review]
@@ -207,46 +211,47 @@ ignore = [
207211
"RTD", # no RTD
208212
]
209213

214+
210215
[tool.ruff]
211216
src = ["scipy-stubs", "codegen", "scripts"]
212217
extend-exclude = [".venv", ".git", ".mypy_cache", ".tox"]
213218
force-exclude = true
214219
# https://typing.readthedocs.io/en/latest/guides/writing_stubs.html#maximum-line-length
215220
line-length = 130
216221

217-
[tool.ruff.format]
218-
docstring-code-format = true
219-
line-ending = "lf"
220-
221-
[tool.ruff.lint]
222-
preview = true
223-
select = ["ALL"]
224-
ignore = ["D", "FBT", "COM812", "CPY", "EM", "TD", "FIX", "DOC"]
225-
226-
[tool.ruff.lint.per-file-ignores]
227-
"*.pyi" = ["F", "E741", "N", "A", "PYI054", "PLC2701", "PLW3201", "PLR", "FURB"]
228-
229-
[tool.ruff.lint.flake8-import-conventions]
230-
banned-from = ["numpy", "numpy.typing", "optype", "optype.numpy", "optype.typing"]
231-
[tool.ruff.lint.flake8-import-conventions.extend-aliases]
232-
"ctypes" = "ct"
233-
"datetime" = "dt"
234-
"numpy" = "np"
235-
"numpy.typing" = "npt"
236-
"optype" = "op"
237-
"optype.numpy" = "onp"
238-
"optype.typing" = "opt"
239-
240-
[tool.ruff.lint.isort]
241-
combine-as-imports = true
242-
known-first-party = ["scipy"]
243-
no-lines-before = ["typing", "first-party", "local-folder"]
244-
section-order = ["standard-library", "typing", "third-party", "first-party", "local-folder"]
245-
split-on-trailing-comma = true
246-
247-
[tool.ruff.lint.isort.sections]
248-
typing = ["collections.abc", "types", "typing", "typing_extensions"]
249-
250-
[tool.ruff.lint.flake8-annotations]
251-
allow-star-arg-any = true
252-
mypy-init-return = true
222+
[tool.ruff.format]
223+
docstring-code-format = true
224+
line-ending = "lf"
225+
226+
[tool.ruff.lint]
227+
preview = true
228+
select = ["ALL"]
229+
ignore = ["D", "FBT", "COM812", "CPY", "EM", "TD", "FIX", "DOC"]
230+
231+
[tool.ruff.lint.per-file-ignores]
232+
"*.pyi" = ["F", "E741", "N", "A", "PYI054", "PLC2701", "PLW3201", "PLR", "FURB"]
233+
234+
[tool.ruff.lint.flake8-import-conventions]
235+
banned-from = ["numpy", "numpy.typing", "optype", "optype.numpy", "optype.typing"]
236+
[tool.ruff.lint.flake8-import-conventions.extend-aliases]
237+
"ctypes" = "ct"
238+
"datetime" = "dt"
239+
"numpy" = "np"
240+
"numpy.typing" = "npt"
241+
"optype" = "op"
242+
"optype.numpy" = "onp"
243+
"optype.typing" = "opt"
244+
245+
[tool.ruff.lint.isort]
246+
combine-as-imports = true
247+
known-first-party = ["scipy"]
248+
no-lines-before = ["typing", "first-party", "local-folder"]
249+
section-order = ["standard-library", "typing", "third-party", "first-party", "local-folder"]
250+
split-on-trailing-comma = true
251+
252+
[tool.ruff.lint.isort.sections]
253+
typing = ["collections.abc", "types", "typing", "typing_extensions"]
254+
255+
[tool.ruff.lint.flake8-annotations]
256+
allow-star-arg-any = true
257+
mypy-init-return = true

‎tox.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ commands = [
5151
"--tb",
5252
"--hide-error-context",
5353
"--hide-error-code-links",
54+
"--no-pretty",
5455
{replace = "posargs", default = ["."], extend = true},
55-
]
56+
],
5657
]

0 commit comments

Comments
 (0)