-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathpyproject.toml
More file actions
262 lines (236 loc) · 9.83 KB
/
pyproject.toml
File metadata and controls
262 lines (236 loc) · 9.83 KB
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
[build-system]
requires = ["hatchling >=1.26", "hatch-vcs", "hatch-fancy-pypi-readme"]
build-backend = "hatchling.build"
[project]
name = "spatch"
authors = [{ name = "Scientific Python Developers" }]
dynamic = ["version"]
description = "Coming soon: Python library for enabling dispatching to backends"
readme = "README.md"
license = "BSD-3-Clause"
requires-python = ">=3.10"
classifiers = [
"Development Status :: 3 - Alpha",
"Environment :: Console",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3 :: Only",
"Topic :: Scientific/Engineering",
"Topic :: Software Development :: Libraries :: Python Modules",
]
keywords = ["dispatching"]
dependencies = ['tomli ; python_version < "3.11"']
[project.urls]
homepage = "https://github.com/scientific-python/spatch"
documentation = "https://scientific-python.github.io/spatch"
source = "https://github.com/scientific-python/spatch"
changelog = "https://github.com/scientific-python/spatch/releases"
[dependency-groups]
# tomlkit is used to format entry-point files
backend_utils = ["tomlkit"]
test = [
"pytest >=6",
"pytest-cov >=3",
"pytest-doctestplus",
{ include-group = "backend_utils" },
]
dev = [
"pre-commit >=4.1",
{ include-group = "test" },
{ include-group = "docs" },
]
docs = [
"sphinx >=7.0",
"sphinx-copybutton",
"pydata-sphinx-theme",
"myst-parser >=0.13",
]
[tool.hatch.version]
source = "vcs"
[tool.hatch.metadata.hooks.fancy-pypi-readme]
content-type = "text/markdown"
[[tool.hatch.metadata.hooks.fancy-pypi-readme.fragments]]
path = "README.md"
[project.entry-points._spatch_example_backends]
backend1 = 'spatch._spatch_example:entry_point.toml'
backend2 = 'spatch._spatch_example:entry_point2.toml'
[[tool.spatch.update_functions]]
backend1 = "spatch._spatch_example.backend"
backend2 = "spatch._spatch_example.backend"
[tool.pixi.workspace]
channels = ["https://prefix.dev/conda-forge"]
preview = ["pixi-build"]
[tool.pixi.package]
name = "spatch"
# TODO: dynamic version https://github.com/prefix-dev/pixi-build-backends/issues/61
version = "0.0.0.dev0"
[tool.pixi.package.build.backend]
name = "pixi-build-python"
version = "*"
[tool.pixi.package.host-dependencies]
uv = "*"
hatchling = "*"
hatch-vcs = "*"
hatch-fancy-pypi-readme = "*"
[tool.pixi.package.run-dependencies]
importlib_metadata = "*"
[tool.pytest.ini_options]
minversion = "6.0"
doctest_plus = "enabled"
testpaths = [
"tests",
"src/spatch", # for doc testing
"docs",
]
xfail_strict = true
norecursedirs = ["src"]
addopts = [
"--doctest-glob=docs/source/**.md",
"--strict-config", # Force error if config is misspelled
"--strict-markers", # Force error if marker is misspelled (must be defined in config)
"-ra", # Print summary of all fails/errors
]
log_cli_level = "info"
filterwarnings = ["error"]
[tool.black]
line-length = 100
target-version = ["py310", "py311", "py312", "py313"]
[tool.ruff]
line-length = 100
[tool.ruff.lint]
extend-select = [
# Defaults from https://github.com/scientific-python/cookie excluding ARG and EM
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"EXE", # flake8-executable
"G", # flake8-logging-format
"I", # isort
"ICN", # flake8-import-conventions
"NPY", # NumPy-specific rules
"PGH", # pygrep-hooks
"PIE", # flake8-pie
"PL", # pylint
"PT", # flake8-pytest-style
"PTH", # flake8-use-pathlib
"RET", # flake8-return
"RUF", # Ruff-specific
"SIM", # flake8-simplify
"T20", # flake8-print
"UP", # pyupgrade
"YTT", # flake8-2020
# Additional ones (may be unnecessary, low value, or a nuisance).
# It's okay to experiment and add or remove checks from here
"S", # bandit
"A", # flake8-builtins
"COM", # flake8-commas
"DTZ", # flake8-datetimez
"T10", # flake8-debugger
"ISC", # flake8-implicit-str-concat
"INP", # flake8-no-pep420
"Q", # flake8-quotes
"RSE", # flake8-raise
"N", # pep8-naming
"PLC", # pylint Convention
"PLE", # pylint Error
"PLR", # pylint Refactor
"PLW", # pylint Warning
"E", # pycodestyle Error
"W", # pycodestyle Warning
"F", # pyflakes
"TRY", # tryceratops
# Maybe consider
# "EM", # flake8-errmsg (Perhaps nicer, but it's a lot of work)
# "ALL", # to see everything!
]
unfixable = [
"F841", # unused-variable (Note: can leave useless expression)
"B905", # zip-without-explicit-strict (Note: prefer `zip(x, y, strict=True)`)
]
ignore = [
# Maybe consider
"ANN", # flake8-annotations (We don't fully use annotations yet)
"B904", # Use `raise from` to specify exception cause (Note: sometimes okay to raise original exception)
"PERF401", # Use a list comprehension to create a transformed list (Note: poorly implemented atm)
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar` (Note: no annotations yet)
"RUF021", # parenthesize-chained-operators (Note: results don't look good yet)
"RUF023", # unsorted-dunder-slots (Note: maybe fine, but noisy changes)
"S310", # Audit URL open for permitted schemes (Note: we don't download URLs in normal usage)
"TRY004", # Prefer `TypeError` exception for invalid type (Note: good advice, but not worth the nuisance)
"TRY301", # Abstract `raise` to an inner function
# Intentionally ignored
"B019", # Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks
"COM812", # Trailing comma missing
"D203", # 1 blank line required before class docstring (Note: conflicts with D211, which is preferred)
"D213", # (Note: conflicts with D212, which is preferred)
"D400", # First line should end with a period (Note: prefer D415, which also allows "?" and "!")
"N801", # Class name ... should use CapWords convention (Note:we have a few exceptions to this)
"N802", # Function name ... should be lowercase
"N803", # Argument name ... should be lowercase (Maybe okay--except in tests)
"N806", # Variable ... in function should be lowercase
"N807", # Function name should not start and end with `__`
"N818", # Exception name ... should be named with an Error suffix (Note: good advice)
"PERF203", # `try`-`except` within a loop incurs performance overhead (Note: too strict)
"PLC0205", # Class `__slots__` should be a non-string iterable (Note: string is fine)
"PLC0415", # `import` should be at the top-level of a file (Note: good advice, too strict)
"PLR0124", # Name compared with itself, consider replacing `x == x` (Note: too strict)
"PLR0911", # Too many return statements
"PLR0912", # Too many branches
"PLR0913", # Too many arguments to function call
"PLR0915", # Too many statements
"PLR2004", # Magic number used in comparison, consider replacing magic with a constant variable
"PLW0603", # Using the global statement to update ... is discouraged (Note: yeah, discouraged, but too strict)
"PLW0642", # Reassigned `self` variable in instance method (Note: too strict for us)
"PLW2901", # Outer for loop variable ... overwritten by inner assignment target (Note: good advice, but too strict)
"RET502", # Do not implicitly `return None` in function able to return non-`None` value
"RET503", # Missing explicit `return` at the end of function able to return non-`None` value
"RET504", # Unnecessary variable assignment before `return` statement
"RUF018", # Avoid assignment expressions in `assert` statements
"S110", # `try`-`except`-`pass` detected, consider logging the exception (Note: good advice, but we don't log)
"S112", # `try`-`except`-`continue` detected, consider logging the exception (Note: good advice, but we don't log)
"S603", # `subprocess` call: check for execution of untrusted input (Note: not important for us)
"S607", # Starting a process with a partial executable path (Note: not important for us)
"SIM102", # Use a single `if` statement instead of nested `if` statements (Note: often necessary)
"SIM105", # Use contextlib.suppress(...) instead of try-except-pass (Note: try-except-pass is much faster)
"SIM108", # Use ternary operator ... instead of if-else-block (Note: if-else better for coverage and sometimes clearer)
"TID251", # flake8-tidy-imports.banned-api
"TRY003", # Avoid specifying long messages outside the exception class (Note: why?)
"UP038", # Use `X | Y` in `isinstance` call instead of `(X, Y)` (Note: using `|` is slower atm)
# Ignored categories
"C90", # mccabe (Too strict, but maybe we should make things less complex)
"BLE", # flake8-blind-except (Maybe consider)
"FBT", # flake8-boolean-trap (Why?)
"DJ", # flake8-django (We don't use django)
"PYI", # flake8-pyi (We don't have stub files yet)
"SLF", # flake8-self (We can use our own private variables--sheesh!)
"TCH", # flake8-type-checking (Note: figure out type checking later)
"ARG", # flake8-unused-arguments (Sometimes helpful, but too strict)
"TD", # flake8-todos (Maybe okay to add some of these)
"FIX", # flake8-fixme (like flake8-todos)
"ERA", # eradicate (We like code in comments!)
"PD", # pandas-vet (Intended for scripts that use pandas, not libraries)
]
[tool.ruff.lint.per-file-ignores]
"src/spatch/**/__init__.py" = [
"F401", # Allow unused import (w/o defining `__all__`)
]
"src/spatch/_spatch_example/backend.py" = ["T201"] # Allow print
"docs/**/*.py" = ["INP001"] # Not a package
"tests/*.py" = [
"S101", # Allow assert
"INP001", # Not a package
]
[tool.ruff.lint.flake8-builtins]
builtins-ignorelist = ["copyright", "type"]
[tool.ruff.lint.flake8-pytest-style]
fixture-parentheses = false
mark-parentheses = false
[tool.ruff.lint.pydocstyle]
convention = "numpy"
[tool.coverage]
run.source = ["spatch"]