-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpyproject.toml
374 lines (341 loc) · 10.9 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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "optype"
description = "Building blocks for precise & flexible type hints"
version = "0.9.1.dev0"
authors = [{name = "Joren Hammudoglu", email = "[email protected]"}]
license = "BSD-3-Clause"
readme = "README.md"
keywords = ["typing", "type hints", "numpy"]
classifiers = [
"Development Status :: 4 - Beta",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Typing :: Typed",
]
# https://scientific-python.org/specs/spec-0000/
requires-python = ">=3.10"
dependencies = ["typing-extensions>=4.10; python_version<'3.13'"]
[project.optional-dependencies]
numpy = ["numpy>=1.23.5"]
[project.urls]
Repository = "https://github.com/jorenham/optype/"
Documentation = "https://github.com/jorenham/optype/blob/master/README.md"
Issues = "https://github.com/jorenham/optype/issues"
Changelog = "https://github.com/jorenham/optype/releases"
Funding = "https://github.com/sponsors/jorenham"
[dependency-groups]
extra = ["optype[numpy]"]
lint = [
"ruff>=0.9.2",
"sp-repo-review[cli]>=2024.8.19",
]
type = [
"basedmypy[faster-cache]>=2.9.1",
"basedpyright>=1.24.0",
]
test = [
"beartype>=0.19.0",
"pytest>=8.3.4",
]
dev = [
{include-group = "extra"},
{include-group = "lint"},
{include-group = "type"},
{include-group = "test"},
"pre-commit>=4.1.0",
"tox>=4.23.2",
]
[tool.hatch.build.targets.sdist]
exclude = [
"/.cache",
"/.github",
"/.mypy_cache",
"/.pytest_cache",
"/.ruff_cache",
"/.tox",
"/.venv",
"/.vscode",
"/dist",
"/examples",
"/scripts",
"/tests",
".editorconfig",
".gitignore",
".markdownlint.yaml",
".pre-commit-config.yaml",
"CODE_OF_CONDUCT.md",
"CONTRIBUTING.md",
"SECURITY.md",
"uv.lock",
]
[tool.mypy]
python_version = "3.10"
packages = ["optype", "examples", "tests"]
strict = true
show_traceback = true
disable_bytearray_promotion = true
disable_memoryview_promotion = true
allow_redefinition = true
disallow_any_expr = false
disallow_any_decorated = false
disallow_any_explicit = false # https://github.com/KotlinIsland/basedmypy/issues/861
disallow_untyped_defs = true
disallow_incomplete_defs = true
enable_error_code = [
"ignore-without-code",
"redundant-expr",
"truthy-bool",
]
warn_return_any = false
warn_redundant_casts = true
warn_unreachable = true
warn_unused_ignores = true
warn_incomplete_stub = true
# incompatible basedmypy features
default_return = false
bare_literals = false
[[tool.mypy.overrides]]
module = ["tests.*", "tests.numpy.*"]
disable_error_code = ["unreachable"]
[tool.basedpyright]
pythonVersion = "3.10"
pythonPlatform = "All"
include = ["optype", "examples", "tests"]
ignore = [".venv"]
stubPath = "."
venvPath = "."
venv = ".venv"
typeCheckingMode = "all"
useLibraryCodeForTypes = false
enableReachabilityAnalysis = false
reportAny = false
reportExplicitAny = false # sometimes there's no way around it
reportImplicitStringConcatenation = false # not a linter
reportPrivateUsage = false # dupe of PLC2701
reportShadowedImports = false # buggy
reportUnreachable = false # nothing wrong with `if sys.version_info() >= ...`
reportUnusedCallResult = false # https://github.com/microsoft/pyright/issues/8650
reportUnusedImport = false # dupe of F401
reportUnusedVariable = false # dupe of F841
[tool.basedpyright.defineConstant]
NP123 = true
NP124 = true
NP125 = true
NP126 = true
NP20 = true
NP21 = true
NP22 = true
NP23 = false
NP30 = false
[tool.pytest.ini_options]
minversion = "8.0"
testpaths = ["optype", "examples", "tests"]
addopts = ["-ra", "--doctest-modules", "--strict-config", "--strict-markers"]
doctest_optionflags = ["NORMALIZE_WHITESPACE", "IGNORE_EXCEPTION_DETAIL", "ELLIPSIS"]
filterwarnings = ["error"]
log_cli_level = "INFO"
xfail_strict = true
[tool.repo-review]
ignore = [
"PY004", # no `docs/` (maybe later)
"PC140", # basedmypy > mypy
"PC170", # no sphinx
"PC180", # no css or js
"RTD", # no readthedocs
]
[tool.ruff]
src = ["optype", "examples", "tests"]
indent-width = 4
show-fixes = true
force-exclude = true
[tool.ruff.format]
# keep in sync with .editorconfig
indent-style = "space"
line-ending = "lf"
preview = true
[tool.ruff.lint]
preview = true
select = [
"F", # pyflakes
"E", # pycodestyle: error
"W", # pycodestyle: warning
"C90", # mccabe
"I", # isort
"N", # pep8-naming
"UP", # pyupgrade
"YTT", # flake8-2020
"ANN", # flake8-annotations
"ASYNC", # flake8-async
"BLE", # flake8-blind-except
"B", # flake8-bugbear
"A", # flake8-builtins
"COM", # flake8-commas
"C4", # flake8-comprehensions
"DTZ", # flake8-datetimez
"T10", # flake8-debugger
"EXE", # flake8-executable
"EM", # flake8-errmsg
"FA", # flake8-future-annotations
"ISC", # flake8-implicit-str-concat
"ICN", # flake8-import-conventions
"LOG", # flake8-logging
"G", # flake8-logging-format
"INP", # flake8-no-pep420
"PIE", # flake8-pie
"T20", # flake8-print
"PYI", # flake8-pyi
"PT", # flake8-pytest-style
"Q", # flake8-quotes
"RSE", # flake8-raise
"RET", # flake8-return
"SLF", # flake8-self
"SLOT", # flake8-slots
"SIM", # flake8-simplify
"TID", # flake8-tidy-imports
"TCH", # flake8-type-checking
"ARG", # flake8-unused-arguments
"PTH", # flake8-use-pathlib
"ERA", # eradicate
"PD", # pandas-vet
"PGH", # pygrep-hooks
"PL", # pylint
"TRY", # tryceratops
"FLY", # flynt
"NPY", # NumPy
"FAST", # FastAPI
"AIR", # airflow
"PERF", # perflint,
"FURB", # refurb
"RUF", # ruff
]
ignore = [
"ANN001", # flake8-annotations: missing-type-function-argument (deprecated)
"ANN002", # flake8-annotations: missing-type-args (deprecated)
"ANN401", # flake8-annotations: any-type
"COM812", # flake8-commas: missing-trailing-comma (ruff format)
"ISC001", # flake8-implicit-str-concat: single-line-implicit-string-concatenation (ruff format)
"PYI034", # flake8-pyi: non-self-return-type
"PYI036", # flake8-pyi: bad-exit-annotation
"PLR0904", # pylintLtoo-many-public-methods
"TRY003", # tryceratops: raise-vanilla-args
"FURB118", # refurb: reimplemented-operator
]
[tool.ruff.lint.per-file-ignores]
"examples/*" = [
"I001", # isort: unsorted-imports
"INP001", # flake8-no-pep420: implicit-namespace-package
"PLR2004", # pylint: magic-value-comparison
]
"tests/*" = [
"F841", # pyflakes: unused-variable
"ANN201", # flake8-annotations: missing-return-type
"PYI015", # flake8-pyi
"SLF001", # flake8-self: private-member-access
"PLC2701", # pylint: import-private-name
"PLR2004", # pylint: magic-value-comparison
"PLR0914", # pylint: too-many-locals
]
[tool.ruff.lint.flake8-builtins]
builtins-allowed-modules = [
"copy",
"dataclasses",
"inspect",
"io",
"json",
"pickle",
"string",
"types",
"typing",
]
[tool.ruff.lint.flake8-import-conventions.extend-aliases]
"ctypes" = "ct"
"datetime" = "dt"
"numpy.typing" = "npt"
"optype.numpy" = "onp"
"optype.typing" = "opt"
[tool.ruff.lint.flake8-errmsg]
max-string-length = 42 # this took a while to figure out
[tool.ruff.lint.flake8-type-checking]
exempt-modules = [
"collections.abc",
"types",
"typing",
"typing_extensions",
"._can",
"._do",
"._does",
"._has",
"._just",
]
[tool.ruff.lint.isort]
combine-as-imports = true
known-local-folder = ["optype"]
extra-standard-library = ["_typeshed", "typing_extensions"]
known-third-party = ["beartype", "numpy", "pytest"]
[tool.ruff.lint.pylint]
allow-dunder-method-names = [
"__name__", # attr of e.g. `type` and `function`
"__qualname__", # attr like `__name__`
"__replace__", # method used by `copy.replace` (py313+)
"__self__", # attr of a bound method
"__func__", # attr of e.g. `classmethod`
"__wrapped__", # attr of e.g. `classmethod`
"__type_params__", # attr of e.g. `Generic` instances
# used within the `typing` standard library
"__value__",
"__origin__",
"__args__",
"__metadata__",
"__parameters__",
"__typing_unpacked_tuple_args__",
"__typing_is_unpacked_typevartuple__",
# `dlpack`
"__dlpack__",
"__dlpack_device__",
# `numpy` special methods
"__array__",
"__array_finalize__",
"__array_function__",
"__array_priority__",
"__array_ufunc__",
"__array_wrap__",
"__array_interface__",
"__array_struct__",
]
allow-magic-value-types = ["int"]
[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 = "test with {base_python}"
skip_install = true
allowlist_externals = ["uv"]
commands_pre = [["uv", "sync", "--frozen"]]
commands = [["uv", "run", "pytest"]]
[tool.tox.env.pre-commit]
description = "pre-commit"
skip_install = true
allowlist_externals = ["uv"]
commands_pre = [["uv", "sync", "--frozen"]]
commands = [["uv", "run", "pre-commit", "run", "--all-files"]]
[tool.tox.env.repo-review]
description = "repo-review"
skip_install = true
allowlist_externals = ["uv"]
commands_pre = [["uv", "sync", "--frozen"]]
commands = [["uv", "run", "repo-review", "."]]
[tool.typos.default]
extend-ignore-identifiers-re = [
"ND|nd",
"(N|n)in",
"Mode(R|W|X|A|O|_)(B|T|_)(U|_)?",
"ba", # file mode string
]