-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
pyproject.toml
264 lines (233 loc) · 7.31 KB
/
pyproject.toml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
[build-system]
build-backend = "poetry.core.masonry.api"
requires = ["poetry-core"]
[tool.poetry]
name = "scipy-stubs"
description = "Typing Stubs for SciPy"
version = "1.14.1.5.dev0"
authors = ["Joren Hammudoglu <[email protected]>"]
license = "BSD-3-Clause"
readme = "README.md"
packages = [{include = "scipy-stubs"}]
classifiers = [
"Development Status :: 4 - Beta",
"Operating System :: OS Independent",
"Typing :: Stubs Only",
"Typing :: Typed",
]
repository = "https://github.com/jorenham/scipy-stubs/"
documentation = "https://github.com/jorenham/scipy-stubs?tab=readme-ov-file#scipy-stubs"
[tool.poetry.urls]
Issues = "https://github.com/jorenham/scipy-stubs/issues"
Changelog = "https://github.com/jorenham/scipy-stubs/releases"
Funding = "https://github.com/sponsors/jorenham"
[tool.poetry.extras]
scipy = ["scipy"]
[tool.poetry.dependencies]
python = "^3.10"
optype = ">=0.7.2"
scipy = {version = ">=1.10", optional = true}
[tool.poetry.group.dev.dependencies]
scipy = "1.14.1"
poethepoet = "^0.31.1"
pre-commit = "^4.0.1"
tox = "^4.23.2"
[tool.poetry.group.lint.dependencies]
basedmypy = {version = "^2.7.0", extras = ["faster-cache"]}
basedpyright = "^1.22.0"
codespell = "^2.3.0"
mdformat = "^0.7.19"
mdformat-gfm = "^0.3.7"
mdformat-gfm-alerts = "^1.0.1"
mdformat-pyproject = "^0.0.2"
ruff = "^0.8.0"
sp-repo-review = {version = "^2024.8.19", extras = ["cli"]}
[tool.poetry.group.codegen]
optional = true
dependencies = {libcst = "^1.5.1"}
[tool.poe.executor]
type = "poetry"
[tool.poe.tasks]
clean = """
rm -rf
codegen/*.pyc
codegen/__pycache__
scipy-stubs/**/*.pyc
scipy-stubs/**/__pycache__
./**/.mypy_cache
./**/.ruff_cache
./**/.tox
"""
mdformat = """
mdformat
CODE_OF_CONDUCT.md
CONTRIBUTING.md
README.md
SECURITY.md
tests/README.md
"""
_ruff_format = "ruff format"
_ruff_check = "ruff check --show-fixes"
codespell = "codespell"
repo-review = "repo-review ."
format = ["mdformat", "_ruff_format"]
ruff = ["_ruff_format", "_ruff_check"]
check = ["mdformat --check", "repo-review", "codespell", "ruff"]
lint = ["check", "format"]
pre-commit = "pre-commit run --all-files"
tox = "tox -p all"
_test_bpr = "basedpyright tests"
_test_mypy = "mypy --config-file=pyproject.toml tests"
typetest = ["_test_bpr", "_test_mypy"]
[tool.poe.tasks.pyright]
cmd = "basedpyright $path"
args = [{name = "path", positional = true, multiple = true, default = "scipy-stubs codegen"}]
[tool.poe.tasks.mypy]
cmd = "mypy --config-file=pyproject.toml $path"
args = [{name = "path", positional = true, multiple = true, default = "scipy-stubs codegen"}]
[tool.poe.tasks.stubtest]
cmd = """
stubtest
--mypy-config-file=pyproject.toml
--allowlist=.mypyignore
--ignore-unused-allowlist
$modules
"""
args = [{name = "modules", positional = true, multiple = true, default = "scipy"}]
[tool.poe.tasks.codemod]
cmd = "python -m libcst.tool codemod -x --hide-progress --include-stubs codegen.mods.$name $path"
args = [
{name = "name", positional = true, multiple = false, required = true},
{name = "path", positional = true, multiple = false, default = "scipy-stubs"}
]
[tool.codespell]
context = 2
skip = "*.lock,*.pyi"
[tool.mdformat]
end_of_line = "lf"
exclude = [".tox/**", ".venv/**", "**/*.m[!d]", "**/*.[!m]d"] # python >= 3.13
[tool.mypy]
python_version = "3.10"
strict = true
disable_bytearray_promotion = true
disable_memoryview_promotion = true
warn_unused_ignores = true
warn_unreachable = true
disallow_any_explicit = false # no other way to type e.g. `float64 <: number[Any]`
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
# plugins = ["numpy.typing.mypy_plugin"]
[tool.pyright]
include = ["codegen", "scipy-stubs", "tests"]
ignore = [".venv"]
venv = ".venv"
venvPath = "."
stubPath = "."
pythonVersion = "3.10"
pythonPlatform = "All"
typeCheckingMode = "strict"
# ignore comments
enableTypeIgnoreComments = false
reportIgnoreCommentWithoutRule = true # based
reportUnnecessaryTypeIgnoreComment = true
# imports
reportImplicitRelativeImport = true # based
reportPrivateLocalImportUsage = false # based
reportShadowedImports = true
# classes and inheritance
reportUnsafeMultipleInheritance = true # based
reportImplicitAbstractClass = true # based
reportImplicitOverride = true
reportUnannotatedClassAttribute = true # based
# linting
deprecateTypingAliases = true
enableReachabilityAnalysis = false # discouraged
reportCallInDefaultInitializer = true
reportImplicitStringConcatenation = true # based
reportPrivateUsage = false
# narrowing
strictGenericNarrowing = true # based
# TODO: enable once nothing is `Untyped`
reportAny = false # based
reportExplicitAny = false # based
# environment
failOnWarnings = true # based
executionEnvironments = [
{root = "scipy-stubs", reportDeprecated = false, reportUnsafeMultipleInheritance = false, reportUnreachable = false},
{root = "codegen", reportAny = true, reportExplicitAny = true, reportInvalidCast = true, reportPrivateUsage = true},
{root = "tests", reportAny = true, reportInvalidCast = true, reportInvalidStubStatement = false},
]
[tool.repo-review]
ignore = [
"PY004", # no /docs
"PP301", # pytest is irrelevant
"PC111", # no blacken-docs because markdown has no code
"PC140", # manual typecheck pre-commit hooks
"PC170", # no pygrep-hooks because no rST
"RTD", # no RTD
]
[tool.ruff]
builtins = ["reveal_locals", "reveal_type"]
exclude = [".venv"]
force-exclude = true
target-version = "py310"
# https://typing.readthedocs.io/en/latest/guides/writing_stubs.html#maximum-line-length
line-length = 130
src = ["scipy-stubs", "codegen"]
[tool.ruff.format]
docstring-code-format = true
line-ending = "lf"
[tool.ruff.lint]
preview = true
select = ["ALL"]
ignore = ["D", "FBT", "COM812", "CPY", "EM", "TD", "FIX", "DOC"]
[tool.ruff.lint.per-file-ignores]
# TODO: enable F (pyflakes)
"*.pyi" = ["F", "E741", "N", "A", "PYI054", "PLC2701", "PLW3201", "PLR", "FURB"]
[tool.ruff.lint.flake8-import-conventions]
banned-from = ["numpy", "numpy.typing", "optype", "optype.numpy", "optype.typing"]
[tool.ruff.lint.flake8-import-conventions.extend-aliases]
"ctypes" = "ct"
"datetime" = "dt"
"numpy" = "np"
"numpy.typing" = "npt"
"optype" = "op"
"optype.numpy" = "onp"
"optype.typing" = "opt"
[tool.ruff.lint.isort]
combine-as-imports = true
known-first-party = ["scipy"]
no-lines-before = ["typing", "first-party", "local-folder"]
section-order = [
"standard-library",
"typing",
"third-party",
"first-party",
"local-folder",
]
split-on-trailing-comma = true
[tool.ruff.lint.isort.sections]
typing = ["collections.abc", "types", "typing", "typing_extensions"]
[tool.ruff.lint.flake8-annotations]
allow-star-arg-any = true
mypy-init-return = true
[tool.tox]
isolated_build = true
env_list = ["repo-review", "pre-commit", "3.10", "3.11", "3.12", "3.13"]
[tool.tox.env_run_base]
description = "stubtest with {base_python}"
skip_install = true
allowlist_externals = ["poetry", "poe"]
commands_pre = [["poetry", "install"]]
commands = [["poe", "stubtest"]]
[tool.tox.env.pre-commit]
description = "pre-commit"
skip_install = true
allowlist_externals = ["poetry", "poe"]
commands_pre = [["poetry", "install"]]
commands = [["poe", "pre-commit"]]
[tool.tox.env.repo-review]
description = "repo-review"
skip_install = true
allowlist_externals = ["poetry", "poe"]
commands_pre = [["poetry", "install"]]
commands = [["poe", "repo-review"]]