-
Notifications
You must be signed in to change notification settings - Fork 0
/
pyproject.toml
496 lines (451 loc) · 15.4 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
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
# SPDX-FileCopyrightText: Copyright 2020-2024, Contributors to Ralized
# SPDX-PackageHomePage: https://github.com/dmyersturnbull/realized
# SPDX-License-Identifier: Apache-2.0
###################
# build-system
###################
[build-system]
requires = ["hatchling~=1.24"]
build-backend = "hatchling.build"
###################
# Project
###################
[project]
name = "realized"
requires-python = "~=3.12"
readme = { file = "README.md", content-type = "text/markdown" }
version = "0.0.1-alpha0"
description = "Human-readable string serializations for many data types"
maintainers = [
{ name = "Douglas Myers-Turnbull", email = " [email protected]" }
]
authors = [
{ name = "Douglas Myers-Turnbull", email = " [email protected]" }
]
license = { text = "Apache-2.0" }
keywords = ["serialization", "format", "string", 'microplate']
classifiers = [
"Natural Language :: English",
"Programming Language :: Python :: 3 :: Only",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Environment :: Console",
"Topic :: Software Development :: Build Tools",
]
dependencies = [
"regex >2024.5",
"orjson >=3.10",
"tzdata >=2024",
]
[project.optional-dependencies]
quantities = [
"Pint >0.24"
]
#===== URLs =====#
[project.urls]
# :tyranno: "https://github.com/${.frag}"
Homepage = "https://github.com/dmyersturnbull/realized"
# :tyranno: "https://github.com/${.frag}"
Source = "https://github.com/dmyersturnbull/realized"
# :tyranno: https://${.vendor}.github.io/${project.name}
Documentation = "https://dmyersturnbull.github.io/realized"
# :tyranno: ${.home}/issues
Tracker = "https://github.com/dmyersturnbull/realized/issues"
# :tyranno: https://pypi.org/project/${project.name}
Download = "https://pypi.org/project/realized/"
# :tyranno: ${.home}/blob/main/CHANGELOG.md
Changelog = "https://github.com/dmyersturnbull/realized/blob/main/CHANGELOG.md"
###################
# Hatch
###################
[tool.hatch.envs.default]
dependencies = [
"dramatiq[watch] >=1.17",
"pre-commit >=3.7",
"hypothesis >=6.100",
"pytest >=8.2",
"tzdata >=2024",
"coverage[toml] >=7.5",
"pytest-cov >=5.0",
"mypy >=1.10",
"ruff >=0.4.8",
"mkdocs >=1.6",
"mike >=2.1",
"mkdocs-literate-nav >=0.6",
"mkdocs-material >=9.5",
"mkdocs-minify-plugin >=0.8",
"mkdocstrings[python] >=0.25",
"mkdocs-table-reader-plugin >=2.2",
]
#skip-install = true
[tool.hatch.envs.default.scripts]
commit = "cz commit {args}"
test = "pytest"
clean = "tyranno clean"
changelog = "cz changelog"
build-docs = "mkdocs build --clean --strict"
serve-docs = "mike serve --config-file mkdocs.yaml"
deploy-docs = "mike deploy --config-file mkdocs.yaml {args}"
deploy-docs-latest = "mike deploy --config-file mkdocs.yaml {args} latest --update-aliases"
obliterate-docs = ["mike delete --config-file mkdocs.yaml --all"]
set-default-docs = "mike set-default --config-file mkdocs.yaml latest"
fmt = "pre-commit run --all-files"
bandit = "ruff --select S {args:.}"
lint = [
"pre-commit run --all-files",
"mypy --non-interactive {args:src/realized tests}"
]
###################
# Ruff
###################
[tool.ruff]
line-length = 120 # 120 is hatch's default via 'hatch init'
include = [
"*.py", # Source
"*.pyi", # Compiled
"pyproject.toml", # This (RUF checks)
"*.ipynb"
# Jupyter notebooks
]
select = [
"A", # flake8-builtins
"ANN", # flake8-annotations
"ASYNC", # flake8-async
"B", # flake8-bugbear
"BLE", # flake8-blind-exception
"C", # flake8-comprehensions
"COM", # flake8-commas
"DTZ", # flake8-datetimez
"EM", # flake8-errmsg
"F", # pyflakes
"FA", # flake8-future-annotations
"E", # flake8 errors (most fixed by black; rest are nitpicky)
"G", # flake8-logging-concat
"I", # isort
"INP", # flake8-no-pep420
"ISC", # flake8-implicit-str-concat
"N", # flake8-naming
"NPY", # numpy-specific rules
"PERF", # perflint
"PGH", # pygrep-hooks
"PIE", # flake8-pie
"PL", # pylint
"PTH", # flake8-use-pathlib
"Q", # flake8-quotes
"RUF", # Ruff-specific tests
"S", # bandit
"SIM", # flake8-simplify
"SLOT", # flake8-slots
"T10", # debugger
"TCH", # flake8-type-checking
"TID", # flake8-tidy-imports (mostly bans relative imports)
"UP", # pyupgrade
"W", # warnings (most fixed by Black, but W605 is invalid escape char)
"YTT", # flake8-2020 (unlikely problematic checks for Python version)
"RUF"
# Ruff-specific rules
]
exclude = [
"ARG", # flake8-unused (unused parameters are almost always intentional, like when overriding)
"FBT", # flake8-boolean-trap (debatable, and might not have a choice)
"ICN", # flake8-import-conventionals (isort does this)
]
ignore = [
"COM812", # contradicts Ruff formatter
"D107", # Missing docstring in __init__ (put in class docstring)
"D212", # Multi-line docstring start (contradictory)
"E203", # Colons with space before (sometimes useful expand)
"E225", # Missing whitespace around operator (sometimes useful to condense)
"E501", # Line > 79 chars (we use black)
"INP001", # missing __init__ -- false positives
"ISC001", # contradicts Ruff formatter
]
unfixable = [
"RUF100", # Unused noqa (should fix manually)
]
flake8-bandit.check-typed-exception = true
pydocstyle.convention = "google"
# This probably isn't needed
# :tyranno: ["${project.name}"]
#isort.known-first-party = ["realized"]
flake8-tidy-imports.ban-relative-imports = "all"
[tool.ruff.per-file-ignores]
"tests/**/*" = [
"INP001", # missing __init__
"PLR2004", # magic values
"S101", # assert
"TID252", # relative imports
"S105", # Ignore checks for possible passwords
"S106",
"S107",
"S108", # Harcoded temp file
]
###################
# pytest
###################
#[tool.pytest] # in a future version of pytest
[tool.pytest.ini_options]
pythonpath = "./src" # critical!
# coverage stops recursing after it finds one dir without an __init__.py
# so if it finds src/java-app before src/pyapp, it won't find pyapp
# So specify exactly which directories to test
# :tyranno: addopts = "--cov=src/${project.name} --cov-report xml:coverage.xml --cov-report term --cov-config=pyproject.toml"
addopts = "--cov=src/realized --cov-report xml:coverage.xml --cov-report term --cov-config=pyproject.toml tests/"
# show log output from the tests
# in the tests/ code, name the logger {pkg}-TEST to differentiate
log_cli = true
log_cli_level = "INFO"
log_cli_format = "%(asctime)s [%(levelname)8s] %(name)s: %(message)s (%(filename)s:%(lineno)s)"
log_cli_date_format = "%Y-%m-%d %H:%M:%S"
# create markers so we can disable integration, network-connected, or very slow tests if desired
markers = [
"integration: marks integration tests (deselect with '-m \"not integration\"')",
"network: marks tests that require network access (deselect with '-m \"not network\"')"
]
doctest_optionflags = [
"DONT_ACCEPT_TRUE_FOR_1", # 1 is not True
"NORMALIZE_WHITESPACE", # allows us to wrap expected output to 120 lines (ignores newlines)
]
###################
# coverage
###################
[tool.coverage.run]
data_file = "coverage.xml"
branch = true # quantify % coverage of execution branches
parallel = true # note that pytest-cov overrides this
# :tyranno: source_pkgs = ["src/${project.name}", "tests"]
source_pkgs = ["realized"]
omit = ["src/**/__main__.py"]
[tool.coverage.paths]
source = ["src/"]
[tool.coverage.report]
fail_under = 50 # 50% coverage required
precision = 1 # n decimal points for coverage %
show_missing = true
exclude_lines = [
"nocov",
"pragma: no cover",
"def __repr__",
"raise AssertionError",
"raise NotImplementedError",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
]
###################
# Black
###################
[tool.black]
# :tyranno: line-length = ${tool.ruff.line-length}
line-length = 120
###################
# MyPy
###################
[tool.mypy]
disallow_untyped_defs = true
disallow_incomplete_defs = true
pretty = true
show_column_numbers = true
warn_unused_ignores = true
###################
# Commitizen
###################
[tool.commitizen]
major_version_zero = true
annotated_tag = true
gpg_sign = true
version_scheme = "semver"
version_provider = "pep621"
bump_message = "chore: bump version $current_version → $new_version"
name = "cz_customize"
[tool.commitizen.customize]
example = "feat(i18n): add Japanese translation"
info = """
We use [Conventional Commits](https://www.conventionalcommits.org/) with the following types.
| Type | Label | Changelog section | semver | Description |
| ----------- | ------------------- | --------------------- | ------ | ----------------------------------- |
| `feat:` | `type: feature` | `✨ Features` | minor | Add or change a feature |
| `fix:` | `type: fix` | `🐛 Bug fixes` | patch | Fix a bug |
| `security:` | `type: security` | `🔒 Security` | minor | Security issue |
| `docs:` | `type: docs` | `📝 Documentation` | patch | Add or modify docs or examples |
| `build:` | `type: build` | `🔧 Build system` | minor | Modify build, including Docker |
| `perf:` | `type: performance` | `⚡️ Performance` | patch | Increase speed / decrease resources |
| `test:` | `type: test` | `🚨 Tests` | N/A | Add or modify tests |
| `refactor:` | `type: refactor` | ignored | N/A | Refactor source code |
| `ci:` | `type: ci` | ignored | N/A | Modify CI/CD |
| `style:` | `type: style` | ignored | N/A | Improve style of source code |
| `chore:` | `type: chore` | ignored | N/A | Change non-source code |
"""
commit_parser = """\
^\
(?P<change_type>feat|fix|security|perf|build|docs|test|refactor|ci|style|chore)\
(?:\\((?P<scope>[-a-z0-9]+)\\))?\
(?P<breaking>!)?\
: (?P<message>[^\n]+)\
.*\
"""
changelog_pattern = "^(feat|fix|security|perf|build|docs)?(!)?"
schema = """
<type>[(<scope>)][!]: <subject>
<body>
[BREAKING CHANGE: <breaking>]
[Closes: #<issue>]
[*: <author>]+
Signed-off-by: <author>
"""
# See https://lore.kernel.org/git/[email protected]/
schema_pattern = """\
(?s)"\
(feat|fix|security|perf|build|docs|test|refactor|ci|style|chore)\
(?:\\(\\([-a-z0-9]+)\\))?\
(!)?\
: ([^\n]+)\
\n?\
(?:\nBREAKING CHANGE: [^\n]+))?\
(?:\nCloses: (#\\d+))+\
(?:\n(Co-authored-by: [^\n]+))+\
(?:\n((?:Acked-by|Reviewed-by|Helped-by|Reported-by|Mentored-by|Suggested-by|CC|Noticed-by|Tested-by): [^\n]+))?\
(?:\nSigned-off-by: ([^\n]+))?\
"""
message_template = """\
{{change_type}}\
{% if scope %}{{scope | trim}}{% endif %}\
{% if breaking %}!{% endif %}\
: {{subject | trim}}\
\n{{body | trim}}\
{% if breaking != '' %}\nBREAKING CHANGE: {{breaking | trim}}{% endif %}\
{% if issues %}\
{% set issuelist = issues.split(',') %}\
{% for issue in issuelist %}\nCloses: #{{issue | trim}}{% endfor %}\
{% endif %}\
{% if trailers %}\
{% set trailerslist = trailers.split('||') %}\
{% for trailer in trailerslist %}\n{{trailer | trim}}{% endfor %}\
{% endif %}\
"""
bump_pattern = "^(feat|fix|security|perf|build|docs)"
change_type_order = [
"breaking",
"security",
"feat",
"fix",
"perf",
"build",
"docs",
"test",
"refactor",
"ci",
"style",
"chore"
]
[tool.commitizen.customize.bump_map]
breaking = "MAJOR"
feat = "MINOR"
fix = "PATCH"
security = "PATCH"
perf = "PATCH"
build = "PATCH"
docs = "PATCH"
refactor = "PATCH"
[tool.commitizen.customize.change_type_map]
security = "🔒 Security"
feat = "✨ Features"
fix = "🐛 Bug fixes"
perf = "⚡️ Performance"
build = "🔧 Build"
docs = "📚 Documentation"
refactor = "⛵ Miscellaneous"
test = "⛵ Miscellaneous"
[[tool.commitizen.customize.questions]]
type = "list"
name = "change_type"
message = "Select the type of change you are committing"
choices = [
{value = "feat", name = "feat: A new feature.", key="f"},
{value = "fix", name = "fix: A bug fix.", key="x"},
{value = "security", name = "security: An exploit fix.", key="v"},
{value = "perf", name = "perf: A performance improvement.", key="p"},
{value = "build", name = "build: A build system change.", key="b"},
{value = "test", name = "test: Add/change tests.", key="t"},
{value = "docs", name = "docs: A change to documentation.", key="d"},
{value = "refactor", name = "refactor: A code refactoring.", key="r"},
{value = "ci", name = "ci/cd: A change to CI/CD.", key="c"},
{value = "style", name = "code style: A change to code style.", key="s"},
{value = "chore", name = "chore: A change to something non-code.", key="z"},
]
[[tool.commitizen.customize.questions]]
type = "input"
name = "subject"
message = "A short, imperative summary: (lowercase and no period).\n"
[[tool.commitizen.customize.questions]]
type = "list"
name = "scope"
message = "Scope (press [enter] to skip).\n"
choices = [
{value = "", name = "[none]"},
{value = "i18n", name = "i18n: Internationalization."},
{value = "plugins", name = "plugins: Plugins."}
]
[[tool.commitizen.customize.questions]]
type = "input"
name = "body"
message = "Body. Additional information: (press [enter] to skip)\n"
[[tool.commitizen.customize.questions]]
type = "input"
name = "breaking"
message = "If a breaking change, provide details: (press [enter] to skip)\n"
[[tool.commitizen.customize.questions]]
type = "input"
name = "issues"
message = "Closed issues, separated by commas: (press [enter] to skip)\n"
[[tool.commitizen.customize.questions]]
type = "input"
name = "trailers"
message = "Git trailers, separated by '||'. Each must be in the form '<key>: <value>'; e.g., 'Reviewed-by: John Johnson <[email protected]>': (press [enter] to skip)\n"
###################
# Tyranno
###################
#===== Tyranno targets to sync =====#
[tool.tyranno.targets]
add-defaults = true
add = []
exclude = []
#===== Tyranno sync from web =====#
[tool.tyranno.web]
uris = [
"https://github.com/dmyersturnbull/tyranno/blob/main/.gitignore",
"https://github.com/dmyersturnbull/tyranno/blob/main/.dockerignore",
"https://github.com/dmyersturnbull/tyranno/blob/main/.editorconfig",
"https://github.com/dmyersturnbull/tyranno/blob/main/.gitattributes",
"https://github.com/dmyersturnbull/tyranno/blob/main/.prettierignore",
"https://github.com/dmyersturnbull/tyranno/blob/main/.scrutinizer.yaml",
"https://github.com/dmyersturnbull/tyranno/blob/main/.pre-commit-config.yaml",
"https://github.com/dmyersturnbull/suretime/blob/main/.github/dependabot.yaml",
"https://github.com/dmyersturnbull/suretime/tree/main/.github/workflows/",
"https://github.com/dmyersturnbull/suretime/tree/main/.github/DISCUSSION_TEMPLATE/",
"https://github.com/dmyersturnbull/suretime/tree/main/.github/ISSUE_TEMPLATE/",
"https://github.com/dmyersturnbull/suretime/tree/main/.github/PULL_REQUEST_TEMPLATE/",
]
#[[tool.tyranno.web.manual]]
#path = ""
#uri = ""
#===== Tyranno auto-add SPDX headers =====#
[tool.tyranno.headers]
text = "${.header}"
add = ["**/*"]
exclude = []
#===== Tyranno 'clean' command =====#
[tool.tyranno.trash]
add-defaults = true
add = []
exclude = []
#===== Tyranno main data =====#
[tool.tyranno.data]
src-dir = "src"
vendor = "dmyersturnbull"
frag = "${.vendor}/${project.name}"
copyright = "Copyright $2020–${~|year(now_utc())~}, Contributors to ${project.name}"
header = """
SPDX-FileCopyrightText: ${.copyright}
SPDX-PackageHomePage: ${project.urls.Homepage}
SPDX-License-Identifier: Apache-2.0
"""