-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpyproject.toml
359 lines (323 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
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "copier-hatch"
version = "2025.1.0"
description = "Hatch-based template"
readme = "README.md"
requires-python = ">=3.11,<3.14"
license = "MIT"
keywords = []
authors = [
{ name = "Reed Rosenberg", email = "spacecoffin@users.noreply.github.com" },
]
classifiers = [
"Development Status :: 4 - Beta",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: Implementation :: CPython",
]
dependencies = ["copier~=9.4", "copier-templates-extensions"]
[project.urls]
Documentation = "https://github.com/spacecoffin/copier-hatch#readme"
Homepage = "https://github.com/spacecoffin/copier-hatch"
Issues = "https://github.com/spacecoffin/copier-hatch/issues"
Source = "https://github.com/spacecoffin/copier-hatch"
[tool.hatch.env]
requires = ["hatch-pip-compile"]
[tool.hatch.envs.default]
installer = "uv"
# https://juftin.com/hatch-pip-compile/examples/
type = "pip-compile"
lock-filename = ".requirements/requirements-{env_name}.txt"
pip-compile-install-args = ["--compile"]
pip-compile-installer = "uv"
pip-compile-resolver = "uv"
skip-install = true
[tool.hatch.envs.default.scripts]
clean = [
"find . -maxdepth 3 -type d -name __pycache__ | xargs rm -rf",
"rm -rf .mypy_cache",
"rm -rf .ruff_cache",
"clean-test",
]
clean-ctt = "rm -rf .ctt"
clean-test = ["rm -f .coverage", "rm -rf .pytest_cache", "clean-ctt"]
init-envs = """\
for e in $(hatch env show --json \
| {env:HATCH_UV:uv}x jq -r 'keys[]' \
| grep -v '^hatch-'); \
do hatch run $e:echo "Preparing environment: $e"; done\
"""
update-reqs = ["hatch env prune", "rm -rf {root}/.requirements", "init-envs"]
[tool.hatch.envs.lint]
detached = true
skip-install = true
[tool.hatch.envs.lint.scripts]
install = ["{env:HATCH_UV:uv}x pre-commit install --install-hooks {args}"]
reinstall = [
"{env:HATCH_UV:uv}x pre-commit uninstall",
"{env:HATCH_UV:uv}x pre-commit clean",
"{env:HATCH_UV:uv}x pre-commit gc",
"install",
]
run = ["{env:HATCH_UV:uv}x pre-commit run {args}"]
run-all = ["{env:HATCH_UV:uv}x pre-commit run --all-files {args}"]
update = [
"{env:HATCH_UV:uv}x pre-commit autoupdate {args}",
"cp .pre-commit-config.yaml project/.pre-commit-config.yaml",
"reinstall",
]
[tool.hatch.envs.test]
extra-dependencies = [
"coverage[toml]",
"pytest",
"copier-template-tester",
"corallium==2.0.1",
"faker",
]
skip-install = false
[[tool.hatch.envs.test.matrix]]
python = ["3.11", "3.12", "3.13"]
[tool.hatch.envs.test.scripts]
test = "pytest {args:tests}"
test-cov = "coverage run -m pytest {args:tests}"
cov-report = ["- coverage combine", "coverage report"]
cov = ["test-cov", "cov-report"]
fast = "pytest -m 'not slow' {args:tests}"
ctt = "$(hatch env find test.py{matrix:python})/bin/ctt | ctt"
[tool.hatch.envs.typecheck]
extra-dependencies = [
# Type Checkers
"mypy~=1.13",
"basedpyright~=1.23",
# Tests
"pytest",
"faker",
]
skip-install = false
[tool.hatch.envs.typecheck.scripts]
check-mypy = "mypy {args:-p copier_hatch -p tests -p plumbum}"
check-pyright = "basedpyright {args}"
install-types = "mypy --install-types --non-interactive {args:-p copier_hatch -p tests -p plumbum}"
static = ["- check-mypy", "check-pyright"]
all = ["static"]
[tool.coverage.paths]
# https://coverage.readthedocs.io/en/stable/config.html#paths
extensions = ["copier_hatch", "src/copier_hatch"]
tests = ["tests"]
[tool.coverage.report]
# https://coverage.readthedocs.io/en/stable/config.html#report
exclude_lines = [
"pragma: no cover",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
]
fail_under = 90
show_missing = true
[tool.coverage.run]
# https://coverage.readthedocs.io/en/stable/config.html#run
branch = true
parallel = true
source_pkgs = ["copier_hatch", "tests"]
[tool.mypy]
# https://mypy.readthedocs.io/en/stable/config_file.html#configuring-error-messages
pretty = true
show_column_numbers = true
show_error_context = true
# https://mypy.readthedocs.io/en/stable/config_file.html#configuring-warnings
warn_unreachable = true
# https://mypy.readthedocs.io/en/stable/config_file.html#import-discovery
exclude = []
mypy_path = "$MYPY_CONFIG_FILE_DIR/typings"
# https://mypy.readthedocs.io/en/stable/config_file.html#miscellaneous-strictness-flags
strict = false
[tool.basedpyright]
# https://docs.basedpyright.com/#/configuration
include = ["src/copier_hatch", "tests", "typings"]
pythonPlatform = "All"
pythonVersion = "3.11"
reportIgnoreCommentWithoutRule = true
reportUnnecessaryTypeIgnoreComment = "warning"
typeCheckingMode = "basic"
[tool.pytest.ini_options]
addopts = "-s --strict-markers"
markers = ["slow: marks tests as slow (deselect with '-m \"not slow\"')"]
[tool.ruff]
# https://docs.astral.sh/ruff/settings/
extend-exclude = [".*"]
force-exclude = true
line-length = 88
src = ["src"]
target-version = "py311"
[tool.ruff.format]
# https://docs.astral.sh/ruff/settings/#format
docstring-code-format = true
line-ending = "lf"
[tool.ruff.lint]
# https://docs.astral.sh/ruff/settings/#lint
unfixable = ["ERA"]
select = [
# https://docs.astral.sh/ruff/rules/
# Default Rule Set
"E", # pycodestyle Error
"F", # Pyflakes
# Additional Rules
"W", # pycodestyle Warning
"ERA", # eradicate
"YTT", # flake8-2020
"S", # flake8-bandit
"BLE", # flake8-blind-except
"FBT", # flake8-boolean-trap
"B", # flake8-bugbear
"A", # flake8-builtins
"C4", # flake8-comprehensions
"DTZ", # flake8-datetimez
"T10", # flake8-debugger
"EM", # flake8-errmsg
"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
"RET", # flake8-return
"SLOT", # flake8-slots
"SIM", # flake8-simplify
"TID", # flake8-tidy-imports
"TC", # flake8-type-checking
"PTH", # flake8-use-pathlib
"ARG", # flake8-unused-arguments
"FLY", # flynt
"I", # isort
"C90", # mccabe (Complexity)
"N", # pep8-naming
"PERF", # Perflint
"D", # pydocstyle
"PGH", # pygrep-hooks
"PLC", # Pylint Convention
"PLE", # Pylint Error
"PLR", # Pylint Refactor
"PLW", # Pylint Warning
"UP", # pyupgrade
"FURB", # refurb
"RUF", # Ruff-specific rules
# Overrides
# https://docs.astral.sh/ruff/rules/multi-line-summary-second-line/
"D213",
]
ignore = [
# Rules that conflict with the Ruff Formatter
# https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
"W191",
"E111",
"E114",
"E117",
"E501",
"D206",
"D300",
"Q000",
"Q001",
"Q002",
"Q003",
"ISC001",
"ISC002",
# E203 (pycodestyle Error): Whitespace before ‘,’, ‘;’, or ‘:’
# https://docs.astral.sh/ruff/rules/whitespace-before-punctuation/
# Black adds a space before & after ':' in slice notation
"E203",
# B019 (flake8-bugbear): Use of functools.lru_cache or functools.cache on methods
# can lead to memory leaks
# https://docs.astral.sh/ruff/rules/cached-instance-method/
# Has known false positives
"B019",
# D200 (pydocstyle): One-line docstring should fit on one line
# https://docs.astral.sh/ruff/rules/fits-on-one-line/
# This is often ugly. Numpy's doc style does not have an explicit rule about this
# convention; therefore pydocstyle defers to PEP 257's recommendation.
"D200",
# SIM108 (flake8-simplify): Use ternary operator {contents} instead of if-else-block
# https://docs.astral.sh/ruff/rules/if-else-block-instead-of-if-exp/
# Suggests long ternary expressions
"SIM108",
# Pylint Refactor PLR09/"Too many" Rules
# https://docs.astral.sh/ruff/rules/#pylint-pl
# Without agreed upon team guidelines, these are too opinionated to employ
"PLR09",
]
[tool.ruff.lint.per-file-ignores]
# F401 (Pyflakes): {name} imported but unused
# https://docs.astral.sh/ruff/rules/unused-import/
# Init imports are for manipulating namespace
"*/__init__.py" = ["F401"]
"*/__init__.pyi" = ["F401"]
# D100 (pydocstyle): Missing docstring in public module
# https://docs.astral.sh/ruff/rules/undocumented-public-module/
# The purpose of `__about__.py` is a commonly known convention
"*/__about__.py" = ["D100"]
# D* (pydocstyle)
# https://docs.astral.sh/ruff/rules/#pydocstyle-d
# Good tests should not need docstrings. Tests aren't rendered for documentation.
# FBT001 (flake8-boolean-trap): Boolean-typed positional argument in function definition
# https://docs.astral.sh/ruff/rules/boolean-type-hint-positional-argument/
# Accommodates parameterization of tests of functions that return a boolean
# PLR2004 (Pylint Refactor): Magic value used in comparison, consider replacing {value}
# with a constant variable
# https://docs.astral.sh/ruff/rules/magic-value-comparison/
# Comparisions to magic values are not a problem in unit tests
# S101 (bandit): assert used
# https://docs.astral.sh/ruff/rules/assert/
# assert is ubiquitous in pytest tests
"tests/*.py" = ["D", "FBT001", "PLR2004", "S101"]
# A002 (flake8-builtins): Argument {name} is shadowing a Python builtin
# https://docs.astral.sh/ruff/rules/builtin-argument-shadowing/
# FBT* (flake8-boolean-trap)
# https://docs.astral.sh/ruff/rules/#flake8-boolean-trap-fbt
# N8* (pep8-naming)
# https://docs.astral.sh/ruff/rules/#pep8-naming-n
# PYI042 (flake8-pyi)
# https://docs.astral.sh/ruff/rules/snake-case-type-alias/
# Not ours to fix in type stubs for third party modules
# D* (pydocstyle)
# https://docs.astral.sh/ruff/rules/#pydocstyle-d
# Conflicts with PYI021
"typings/*.pyi" = ["A002", "D", "FBT", "N8", "PYI042"]
# D* (pydocstyle)
# https://docs.astral.sh/ruff/rules/#pydocstyle-d
# Docstrings unnecessary for in-project files
# N999 (pep8-naming): Invalid module name
# https://docs.astral.sh/ruff/rules/invalid-module-name/
# Module name will be formatted during template rendering
"project/*" = ["D", "N999"]
[tool.ruff.lint.flake8-tidy-imports]
# https://docs.astral.sh/ruff/settings/#lint_flake8-tidy-imports_ban-relative-imports
ban-relative-imports = "parents"
[tool.ruff.lint.flake8-unused-arguments]
# https://docs.astral.sh/ruff/settings/#lint_flake8-unused-arguments
ignore-variadic-names = true
[tool.ruff.lint.isort]
# https://docs.astral.sh/ruff/settings/#lint_isort_extra-standard-library
extra-standard-library = ["_typeshed"]
# https://docs.astral.sh/ruff/settings/#lint_isort_known-first-party
known-first-party = ["tests"]
# https://docs.astral.sh/ruff/settings/#lint_isort_section-order
section-order = [
"future",
"standard-library",
"third-party",
"first-party",
"local-folder",
]
[tool.ruff.lint.pydocstyle]
# https://docs.astral.sh/ruff/settings/#lint_pydocstyle
convention = "numpy"