Repository navigation
Expand file tree
/
Copy pathpyproject.toml
More file actions
457 lines (435 loc) · 17 KB
/
Copy pathpyproject.toml
File metadata and controls
457 lines (435 loc) · 17 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
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
[build-system]
requires = ["hatchling", "setuptools>=77"]
build-backend = "hatchling.build"
[tool.hatch.build.targets.wheel.hooks.custom]
path = "hatch_build.py"
[tool.cibuildwheel]
build = "cp3{12,13,14,15}-*"
archs = ["auto64"]
test-extras = ["serde", "crypto", "compress", "containers", "rand", "math"]
test-requires = ["pytest>=8.2", "hypothesis>=6.100", "packaging>=24.2"]
test-command = [
"python {project}/tests/tooling/runtime/tls.py --json",
"python -c \"import unstd.serde._json_native, unstd.clone._clone_native, unstd.crypto._stream_native, unstd.text._text_native, unstd.compress._gzip_native, unstd.containers._sorted_native, unstd.proc._proc_native, unstd.rand._rand_native, unstd.pack._pack_native, unstd.math._math_native, unstd.dataset._dataset_native\"",
"python -c \"import importlib, sys; sys.platform != 'linux' or importlib.import_module('unstd.fs._fs_native')\"",
"python {project}/tests/tooling/runtime/json_acceleration.py --json",
"python {project}/tests/tooling/release/wheel_tests.py --workers 4",
]
# Keep the existing Intel wheel floor without losing the provider's optimization flags.
[[tool.cibuildwheel.overrides]]
select = "cp3{12,13}-macosx_x86_64"
inherit.environment = "append"
[tool.cibuildwheel.overrides.environment]
MACOSX_DEPLOYMENT_TARGET = "10.13"
CFLAGS = '''$(python -c 'import os, sysconfig; print(os.environ.get("CFLAGS", sysconfig.get_config_var("CFLAGS") or ""))') -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET'''
LDFLAGS = "$LDFLAGS -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET"
[project]
name = "unstd"
version = "4.0.5"
description = "stdlib-faithful accelerated replacements behind optional extras"
readme = "README.md"
requires-python = ">=3.12"
license = "Apache-2.0 AND MIT AND Zlib AND BSD-3-Clause"
license-files = [
"LICENSE",
"NOTICE",
"native/compress/vendor/libdeflate/COPYING",
"native/compress/vendor/zlib/LICENSE",
"native/compress/vendor/isa-l/LICENSE",
]
authors = [{ name = "The Billy Company" }]
keywords = [
"stdlib",
"orjson",
"msgspec",
"json",
"blake3",
"uuid",
"extras",
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: 3.15",
"Topic :: Software Development :: Libraries :: Python Modules",
]
dependencies = []
# Every entry below is a FLOOR, never an `==` pin. A library that pins a patch
# decides its consumers' resolutions for them, and two libraries doing that are
# simply not co-installable. Applications are where an exact pin belongs, and a
# consumer that wants one still has its own manifest and lockfile to say so in.
#
# Floors normally sit at the MINOR series, where backend APIs change. A patch
# floor needs a documented security or correctness fix, rather than the version
# we happened to develop against. CI's
# `floors` job resolves `--resolution lowest-direct` and runs the whole suite
# there, so each of these is a claim under test rather than a guess.
[project.optional-dependencies]
serde = [
"orjson>=3.12",
"msgspec>=0.22",
"pybase64>=1.5",
]
ids = [
"uuid-utils>=0.17",
]
crypto = [
# 1.0.10 fixes a shared parallel-update deadlock and removes arrayref after
# its publisher compromise. Older locked arrayref 0.3.9 was unaffected.
# https://github.com/oconnor663/blake3-py/releases/tag/1.0.10
"blake3>=1.0.10",
]
time = [
"whenever>=0.10",
]
# `timeutil`'s protobuf Timestamp bridge only. Kept out of `time` so a
# `whenever` consumer does not inherit protobuf, and out of the base install so
# the rest of `timeutil` stays pure stdlib.
proto = [
"protobuf>=7.36",
]
model = [
"pydantic>=2.13",
"pydantic-settings>=2.15",
]
rex = [
"irregex>=2.6.0",
]
containers = [
"sortedcontainers>=2.4",
"immutables>=0.21",
]
math = [
"numpy>=2.5",
]
rand = [
"numpy>=2.5",
]
pack = [
"numpy>=2.5",
]
# `clone` is pure stdlib since 1.1. The extra stays declared, empty, so an
# existing `unstd[clone]` requirement keeps resolving without a missing-extra
# warning.
clone = []
text = [
"rapidfuzz>=3.12.0 ; python_version < '3.14'",
# 3.14 adds CPython 3.14 wheels; older releases cannot build on that runtime.
# https://github.com/rapidfuzz/RapidFuzz/releases/tag/v3.14.0
"rapidfuzz>=3.14 ; python_version >= '3.14'",
]
audio = [
"soundfile>=0.14",
"numpy>=2.5",
]
toml = [
"tomlkit>=0.15",
]
yaml = [
"ruamel-yaml>=0.19",
"pyyaml>=6.0.3",
]
compress = [
"zlib-ng>=1.0",
]
zstd = [
"zstandard>=0.25",
]
archives = [
"libarchive-c>=5.3 ; sys_platform != 'win32'",
]
[project.urls]
Homepage = "https://github.com/The-Billy-Company/unstd"
Repository = "https://github.com/The-Billy-Company/unstd"
Changelog = "https://github.com/The-Billy-Company/unstd/blob/main/CHANGELOG.md"
Issues = "https://github.com/The-Billy-Company/unstd/issues"
[dependency-groups]
bench = ["ijson>=3.6"]
# Dedicated analyzers are development tools, never runtime dependencies.
static-analysis = ["bandit==1.9.4", "pylint==4.1.3"]
# The supply gate needs neither compilers, runtime extras, nor type/lint tools.
supply-chain = [
"pytest>=8.2",
"hypothesis>=6.100",
"packaging>=24.2",
"ruamel-yaml>=0.19",
]
# Build and release tools belong to the audited lock, outside runtime extras.
build = ["hatchling", "setuptools>=77"]
backend-build = [
"setuptools>=77",
# Immutables needs wheel when newer CPython installs its source distribution.
"wheel>=0.45",
# zlib-ng and BLAKE3 need source builds on CPython 3.15 and Windows ARM.
# Authenticate their Python build backends before installing wheel-test extras.
"setuptools-scm>=8 ; python_version >= '3.15' or (sys_platform == 'win32' and platform_machine == 'ARM64')",
"maturin>=1.15,<2 ; python_version >= '3.15' or (sys_platform == 'win32' and platform_machine == 'ARM64')",
# VS 2026 ARM runners need this external compiler prerequisite from a wheel.
"cmake>=4.2,<5 ; sys_platform == 'win32' and platform_machine == 'ARM64'",
]
# Linux build containers carry their own frontend independently of the host.
release-uv = ["uv==0.13.6"]
release = [
"cibuildwheel==4.3.1",
"delocate==0.13.0 ; sys_platform == 'darwin'",
"delvewheel==1.13.2 ; sys_platform == 'win32'",
# GHSA-6q48-6c7w-9gw2: do not restore compromised certificate roots.
"certifi>=2026.10.19",
]
dev = [
"pytest>=8.2",
"hypothesis>=6.100",
"mypy>=2.4",
"ruff>=0.16.10",
# Only the TLS policy tests need it, and only to mint a throwaway self-signed
# certificate: `load_cert_chain` is the behavior under test, so there is no
# faking it. Without this the mTLS and pinned-root cases skip rather than fail,
# which is the quiet way a security test stops being one.
"cryptography>=44.0",
"types-protobuf>=7.35.1.20260906",
"types-PyYAML>=6.0",
"sortedcontainers-stubs>=2.4.3",
]
fuzz = [
# A tested development engine/protocol, kept outside the runtime closure.
# The binary-wheel platform is explicit; other hosts retain replay/mutation.
"atheris==3.0.0 ; python_full_version == '3.12.*' and platform_machine == 'x86_64' and sys_platform == 'linux'",
]
[tool.uv]
# Keep development, optional backends and isolated builds behind the same
# two-day release quarantine as the applications that consume this package.
exclude-newer = "P2D"
[tool.uv.exclude-newer-package]
# Our engine is released by the same verified publisher; upstreams keep P2D.
irregex = false
# Security fix reviewed against GHSA-6q48-6c7w-9gw2. Keep a one-day
# quarantine for certifi so the repaired CA bundle can enter the release tools.
certifi = "P1D"
[tool.pytest.ini_options]
testpaths = ["tests/suites"]
addopts = "--strict-markers --strict-config --import-mode=importlib -m 'not perf and not chaos and not concurrency and not resources'"
markers = [
"unit: module API contracts, including retained historical mixed cases",
"parity: independent stdlib or backend differential contracts",
"properties: Hypothesis generated contracts, including mixed modules",
"security: module-owned authentication, transport and untrusted-input contracts",
"gates: package, harness, inventory and runner checks",
"regression: minimized reproducer of a confirmed defect",
"integration: real cross-module boundaries and installed artifacts",
"packaging: offline built artifacts and pristine installed consumers",
"pentest: behavioral probes against concrete trust boundaries",
"security_structure: runtime canaries for approved security primitives",
"chaos: explicit bounded injected-failure experiments",
"concurrency: thread, process and fork safety contracts",
"resources: bounded memory, CPU, descriptor and streaming growth",
"perf: performance evidence requiring a quiet dedicated worker",
"fuzz_replay: deterministic replay of committed fuzz corpora",
]
# The repo root, so the assurance/gates/bench tests can import `bench`. `bench`
# is a development tool and deliberately outside `src/`, so it is not on the path
# the installed wheel puts there.
pythonpath = ["."]
# Target Python version is INFERRED from `[project].requires-python` (3.12), per
# ruff's own recommendation — so the lint target can never drift from the floor
# the package actually claims to support.
[tool.ruff]
# 88 — ruff's default, and what the tree is already formatted to. Pinned rather
# than inherited so a future ruff default change can't silently reflow the repo.
line-length = 88
[tool.ruff.lint]
select = [
"E",
"W",
"F",
"I",
"UP",
"B",
"S",
"C4",
"PT",
"SIM",
"RUF",
"PTH",
"TC",
"ASYNC",
"FURB",
"DTZ",
"PERF",
"RET",
"TRY",
"EM",
"N",
"D",
"ANN",
"PYI",
"FA",
"PGH",
"PLC0131",
]
# D401 (imperative mood) is deselected deliberately, not to go green. It suits
# commands; this package's voice names what a pure accessor *returns* as a noun
# phrase ("The digest of everything absorbed so far"), which reads better than
# "Return the digest of …" and is the house convention throughout. The
# load-bearing half of pydocstyle — a docstring must EXIST (D100-D107) and be
# shaped correctly (D2xx) — stays enforced.
# E501 — line length is owned by `ruff format`, which deliberately leaves long
# docstrings and prose strings alone; selecting it would double-punish them.
# D203/D213 — the two mutually-exclusive halves of the docstring-whitespace
# rules; D211/D212 (this package's shape) are the other side of each pair.
# RUF001/RUF002/RUF003 — the whole trio, one decision: this package deliberately
# uses typographic characters (· × —) as prose in strings, docstrings and
# comments alike. `×` in "5.9× faster" is a multiplication sign because that is
# what it means; there is nothing ambiguous to resolve.
# ANN401 — the JSON, clone and backend-faithful APIs deliberately accept and
# return arbitrary values. Their existing Any annotations describe that dynamic
# boundary; missing annotations remain errors in production and benchmark code.
# PYI021 — module docstrings document native extension stubs and satisfy D100.
ignore = [
"E501",
"D203",
"D213",
"D401",
"RUF001",
"RUF002",
"RUF003",
"ANN401",
"PYI021",
]
[tool.ruff.lint.pydocstyle]
convention = "pep257"
[tool.ruff.lint.isort]
known-first-party = ["unstd"]
force-sort-within-sections = true
lines-after-imports = 2
[tool.ruff.lint.per-file-ignores]
# The copyright gate runs with the Python standard library on fresh checkouts.
# Its unittest assertions and exception contexts deliberately need no pytest.
"tools/copyright/test_check.py" = ["PT009", "PT027"]
# Tests assert (S101). A test's own name is its documentation, and the law each
# suite enforces lives in the module docstring — so the per-function/class/
# method docstring rules are noise there. Module docstrings stay required (D100).
# D205 too: a test docstring is one law sentence that happens to wrap past a
# line, not a summary followed by a description, so there is no blank line to
# insert without splitting the sentence. It stays enforced on `src`, which ships.
# ANN — tests deliberately pass invalid inputs and replace modules/functions
# with small fixture doubles. Production and benchmark signatures are checked;
# test signatures do not claim the stricter runtime contracts they challenge.
# PYI024 — namedtuple fixtures exercise the stdlib type itself, including its
# construction and copy/serialization behavior.
"tests/**" = [
"S101",
"D101",
"D102",
"D103",
"D105",
"D106",
"D107",
"D205",
"ANN001",
"ANN002",
"ANN003",
"ANN201",
"ANN202",
"ANN204",
"ANN205",
"ANN206",
"PYI024",
]
# Benchmarks print their measurements; that is their entire output contract
# (T201), and they seed `random.Random` to build deterministic payloads, which is
# the opposite of a cryptographic use (S311). D102 covers one-line properties
# (`per_op_us`, `ratio`, `skipped`) whose names already say everything a docstring
# would; the ones carrying a real invariant have one anyway.
# PYI024 preserves the stdlib namedtuple fixture being measured.
"bench/**" = ["S101", "D102", "D103", "S311", "T201", "PYI024"]
# FURB167 rewrites `re.S` → `re.DOTALL`. `rex` MUST re-export stdlib's full flag
# vocabulary — short aliases included — or it is not a drop-in `re` surface, so
# the finding is wrong here on its own terms. It is also actively destructive:
# ruff marks the fix `safe`, and its replacement content is the bare token
# `DOTALL`, which a plain `ruff --fix` splices over the PEP 695 type parameter
# `S` in every generic signature in this file. That is exactly how the nine
# `pattern: DOTALL` annotations got here. Do not re-enable.
"src/unstd/rex/**" = ["FURB167"]
# `unstd.fs` is an `os`-faithful surface: `os.chmod` is the function it stands in
# for, so rewriting it to `Path.chmod` would break the contract the module exists
# to keep.
"src/unstd/fs/**" = ["PTH"]
[tool.mypy]
# The floor from `requires-python`, so the type gate judges the oldest
# interpreter the package claims rather than whichever one CI happens to run.
python_version = "3.12"
# `bench` is checked too. It is the only thing standing behind the speedup
# numbers the READMEs print, so a harness that silently stopped comparing what
# it claims to compare would be worse than no harness — it would launder a
# regression as a measurement.
files = ["src/unstd", "bench"]
strict = true
# JSON values, cloning hooks, and regex forwarding retain explicit Any where
# their stdlib contracts are dynamic. Banning every Any expression/annotation
# would misdescribe those APIs; imported and decorated Any leaks are checked.
# Keep these explicit rather than inheriting permissive version defaults.
# Missing third-party types are supplied by the development stub dependencies;
# an unknown import must never silently turn a public contract into Any.
ignore_missing_imports = false
disallow_any_unimported = true
disallow_any_decorated = true
disallow_untyped_globals = true
local_partial_types = true
implicit_optional = false
strict_optional = true
strict_bytes = true
strict_equality_for_none = true
warn_incomplete_stub = true
warn_unused_configs = true
# `warn_unreachable` and `redundant-expr` are deliberately NOT enabled. Both are
# structurally incompatible with this package's central idiom: a backend is
# imported for real under `if TYPE_CHECKING:` and guarded by try/except at
# runtime, so mypy — which always resolves the TYPE_CHECKING branch as true —
# sees every runtime fallback guard as dead code. Enabling them would mean
# suppressing the fallback contract the library is built on, one `type: ignore`
# at a time. mypy's numeric promotion (`int` satisfies `float`) makes
# `redundant-expr` misread the sample-coercion isinstance checks the same way.
enable_error_code = [
"truthy-bool",
"truthy-iterable",
"ignore-without-code",
"redundant-self",
"unused-awaitable",
"possibly-undefined",
"explicit-override",
"mutable-override",
"unimported-reveal",
"exhaustive-match",
"deprecated",
]
[[tool.mypy.overrides]]
# CPython's private regex compiler/parser expose no installed stubs. These
# implementation details stay behind the typed public regex facade; other
# missing imports, including misspelled project imports, remain errors.
module = ["_sre", "re._compiler", "re._constants", "re._parser"]
ignore_missing_imports = true
[[tool.mypy.overrides]]
# functools.wraps intentionally preserves stdlib json's dynamic input/output
# contract. Any in those decorated signatures is part of the public API.
module = "unstd.serde.jsonx"
disallow_any_decorated = false
# R0801 compares executable lines across production modules. Ignore signatures
# and prose so shared API shapes do not count as duplicated implementation.
# Eight lines catches substantial repeated branches without treating explicit
# export lists as shared mutable policy. No baseline or file exclusions.
[tool.pylint.main]
py-version = "3.12"
[tool.pylint.messages_control]
disable = ["all"]
enable = ["duplicate-code"]
[tool.pylint.similarities]
min-similarity-lines = 8
ignore-comments = true
ignore-docstrings = true
ignore-imports = true
ignore-signatures = true