-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpyproject.toml
359 lines (334 loc) · 10.5 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
[build-system]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"
[project]
name = "mloq-template"
description = "Automate project creation following ML best practices."
readme = "README.md"
requires-python = ">=3.10"
license = { file = "LICENSE" }
# keywords for easier look-up on PyPI
keywords = [] # ToDo: Modify according to your needs!
authors = [
{ name = "Guillem Duran Ballester", email = "[email protected]" },
]
maintainers = [
{ name = "Guillem Duran Ballester", email = "[email protected]" },
]
# options under https://pypi.org/classifiers/
classifiers = [
# complete classifier list: http://pypi.python.org/pypi?%3Aaction=list_classifiers
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: Unix",
"Operating System :: POSIX",
"Operating System :: Microsoft :: Windows",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
# uncomment if you test on these interpreters:
# "Programming Language :: Python :: Implementation :: IronPython",
# "Programming Language :: Python :: Implementation :: Jython",
# "Programming Language :: Python :: Implementation :: Stackless",
"Topic :: Utilities",
]
dynamic = ["version"]
# direct dependencies of this package, installed when users `pip install mloq-template` later.
dependencies = [
"flogging",
"pre-commit",
"click",
] # ToDo: Modify according to your needs!
[project.urls]
# important URLs for this project
Documentation = "https://mloq-template.readthedocs.io/"
Changelog = "https://mloq-template.readthedocs.io/en/latest/changelog.html"
Tracker = "https://github.com/FragileTech/mloq-template/issues"
[project.scripts]
mloq-template = "mloq_template.__main__:run"
[project.optional-dependencies]
lint= ["mypy", "ruff", "mypy"]
test = ["pytest", "pytest-cov", "pytest-xdist"]
docs = [
"autoapi",
"jupyter-book",
"sphinx",
"linkify-it-py",
"myst-parser",
"myst-nb",
"ruyaml",
"sphinx-autoapi",
"pydata-sphinx-theme",
"sphinx-autodoc2",
"sphinxcontrib-mermaid",
"sphinx_book_theme",
"sphinx_rtd_theme",
"jupyter-cache",
"sphinx-copybutton",
"sphinx-togglebutton",
"sphinxext-opengraph",
"sphinxcontrib-bibtex",
]
[tool.rye]
managed = true
universal = true
dev-dependencies = ["hatch"]
[tool.hatch.metadata]
# direct dependency references, e.g `pip @ git+https://github.com/pypa/pip.git@master`
allow-direct-references = true
[tool.hatch.version]
path = "src/mloq_template/version.py"
[tool.hatch.build]
packages = ["src/mloq_template"]
[tool.hatch.build.targets.sdist]
exclude = [
"/.github",
]
[tool.rye.scripts]
lint = { cmd = "hatch run lint:all" }
style = { cmd = "hatch run lint:style" }
check = { cmd = "hatch run lint:check" }
test = { cmd = "hatch run test:test" }
doctest = { cmd = "hatch run test:doctest" }
cov = { cmd = "hatch run test:cov" }
no-cov = { cmd = "hatch run test:no-cov" }
debug = { cmd = "hatch run test:debug" }
docs = { cmd = "hatch run docs:docs" }
build-docs = { cmd = "hatch run docs:build"}
sphinx = { cmd = "hatch run docs:sphinx" }
serve-docs = { cmd = "hatch run docs:serve" }
all = {chain= ["lint", "build-docs", "test"]}
[tool.ruff]
# Assume Python 3.10
target-version = "py310"
preview = true
include = ["*.py", "*.pyi", "**/pyproject.toml"]
# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".mypy_cache",
".nox",
".pants.d",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
".idea",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"output",
"venv",
"experimental",
".pytest_cache",
"**/.ipynb_checkpoints/**",
"**/proto/**",
"data",
"config",
"docs/conf.py", # Autogenerated by jupyter-book
]
# Same as Black.
line-length = 99
[tool.ruff.lint]
# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
select = [
"ARG", "C4", "D", "E", "EM", "F", "FBT",
"FLY", "FIX", "FURB", "N", "NPY",
"INP", "ISC", "PERF", "PIE", "PL",
"PTH", "RET", "RUF", "S", "T10",
"TD", "T20", "UP", "YTT", "W", "I",
]
ignore = [
"D100", "D211", "D213", "D104", "D203", "D301", "D407", "S101",
"FBT001", "FBT002", "FIX002", "ISC001", "PLR0913", "RUF012", "TD003",
"PTH123", "PLR6301", "PLR0917", "S311", "S403", "PLR0914", "PLR0915", "S608",
"EM102", "PTH111", "FIX004", "UP035", "PLW2901", "S318", "S404",
"S408", 'S405', 'S607', 'S603',
'E902', "TD001", "TD002", "FIX001", "T201",
]
# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
# unfixable = ["I"]
[tool.ruff.lint.flake8-import-conventions.aliases]
# Declare the default aliases.
altair = "alt"
"matplotlib.pyplot" = "plt"
numpy = "np"
pandas = "pd"
seaborn = "sns"
scipy = "sp"
holoviews = "hv"
panel = "pn"
polars = "pl"
"polars.selectors" = "cs"
[tool.ruff.lint.flake8-quotes]
docstring-quotes = "double"
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["E402", "F401"]
"cli.py" = ["PLC0415", "D205", "D400", "D415"]
"**/docs/**" = ["INP001", "PTH100"]
"**/{tests,docs}/*" = [
"E402", "F401", "F811", "D", "S101", "PLR2004", "S105",
"PLW1514", "PTH123", "PTH107", "N811", "PLC0415", "ARG002",
]
# Enable reformatting of code snippets in docstrings.
[tool.ruff.format]
docstring-code-line-length = 99
docstring-code-format = true
indent-style = "space"
line-ending = "auto"
preview = true
quote-style = "double"
[tool.ruff.lint.isort]
known-first-party = ["mloq_template"]
forced-separate = ["conftest"]
force-single-line = true
order-by-type = false
force-sort-within-sections = true
combine-as-imports = true
lines-after-imports = 2
detect-same-package = true
[tool.ruff.lint.flake8-pytest-style]
fixture-parentheses = false
mark-parentheses = false
[tool.ruff.lint.flake8-tidy-imports]
ban-relative-imports = "all"
[tool.mypy]
files = ["src/mloq_template", "tests"]
exclude = ["docs/conf.py"]
disallow_untyped_defs = false
follow_imports = "normal" # "silent" for not following
ignore_missing_imports = true
pretty = true
show_column_numbers = true
warn_no_return = false
warn_unused_ignores = true
[tool.pylint.master]
ignore = 'tests'
load-plugins =' pylint.extensions.docparams'
[tool.pylint.messages_control]
disable = 'all,'
enable = """,
missing-param-doc,
differing-param-doc,
differing-type-doc,
missing-return-doc,
"""
[tool.pytest.ini_options]
# To disable a specific warning --> action:message:category:module:line
filterwarnings = ["ignore::UserWarning", 'ignore::DeprecationWarning']
addopts = "--ignore=scripts --doctest-continue-on-failure"
python_files = ["test_*.py", "tests.py", "test.py"]
# Code coverage config
[tool.coverage.run]
branch = true
source = ["src/mloq_template"]
omit = [
"version.py", # automatically created by hatch-vcs, not in repo
]
[tool.coverage.paths]
source = ["src/", "*/site-packages/"]
[tool.coverage.report]
# Regexes for lines to exclude from consideration
exclude_lines = [
# Have to re-enable the standard pragma
"pragma: no cover",
# Don't complain about missing debug-only code:
"def __repr__",
"if self\\.debug",
# Don't complain if tests don't hit defensive assertion code:
"raise AssertionError",
"raise NotImplementedError",
# Don't complain if non-runnable code isn't run:
"if 0:",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
]
ignore_errors = true
omit = ["tests/*"]
#####################
# Environment Setup #
#####################
# Default environment with production dependencies
[tool.hatch.envs.default]
installer = "uv"
python = "3.10"
post-install-commands = ["pre-commit install"]
dependencies = []
# Test environment with test-only dependencies
[tool.hatch.envs.test]
description = "Run tests and coverage"
features = ["test"]
[tool.hatch.envs.test.scripts]
run_pytest = "pytest -s -o log_cli=true -o log_cli_level=info {args}"
doctest = "run_pytest --doctest-modules --doctest-glob=\\*.md -n 0 {args:src}"
test = ["doctest", "run_pytest {args:tests}"]
cov = "run_pytest -n auto --cov-report=term-missing --cov-config=pyproject.toml --cov=src/mloq_template --cov=tests {args}"
no-cov = "cov --no-cov {args}"
debug = "cov --no-cov --pdb --pdbcls=IPython.core.debugger:Pdb {args}"
[tool.hatch.envs.test.env-vars]
N = "auto"
# Docs environment
[tool.hatch.envs.docs]
description = "Build and serve documentation using Jupyter Book and Sphinx"
features = ["docs"]
[tool.hatch.envs.docs.env-vars]
SOURCE_DATE_EPOCH = "1580601600"
PYTHONUNBUFFERED = "1"
[tool.hatch.envs.docs.scripts]
features = ["docs"]
build = [
"cp AUTHORS.md docs/source/project/",
"cp CHANGELOG.md docs/source/project/",
"cp CONTRIBUTING.md docs/source/project/",
"cp README.md docs/source/project/",
"jupyter-book build docs/ ",
"uv pip freeze > docs/requirements.txt",
]
validate = "linkchecker --config .linkcheckerrc --ignore-url=/reference --ignore-url=None site"
build-check = ["build"] #, "validate"]
serve = "python3 -m http.server --directory docs/_build/html {args}"
sphinx = [
"jupyter-book config sphinx docs/ --overwrite",
"sphinx-build -b html docs/ docs/_build/html",
"uv pip freeze > docs/requirements.txt",
]
docs = ["build", "serve"]
# Lint environment
[tool.hatch.envs.lint]
description = "Run linting checks with ruff and mypi"
template = "lint" # don't inherit from default!
features = ["lint"]
skip-install = true
[tool.hatch.envs.lint.scripts]
typing = [
"echo \"MYPY VERSION: `mypy --version`\"",
"mypy --install-types --non-interactive {args}"
]
style = [
"echo \"RUFF VERSION: `ruff --version`\"",
"ruff check --fix-only --unsafe-fixes {args:.}", "ruff format {args:.}",
]
check = ["ruff check {args:.}", "ruff format --diff {args:.}"]
all = ["style", "check", "typing"]
# Test matrix for various Python versions replacing the functionality of tox
[[tool.hatch.envs.py-test.matrix]]
template = ["test"]
python = ["39", "310", "311", "312"]