dataclass-values
A number that remembers where it came from, and still is the number. Stdlib only.
from dataclasses import dataclass
from dataclass_values import Basis, Normal, Space, Value, plain
@dataclass(frozen=True)
class Belt:
width_m: float = Value(1.2, "m", low=0.6, high=1.85, basis=Basis.CHOSEN, source="site survey")
speed_mps: float = Value(0.5, "m/s", dist=Normal(0.5, 0.05), low=0.2, high=0.8)
belt = Belt()
belt.width_m * 2 # 2.4, a plain float
Space(belt).sample() # a Belt, every ranged field redrawn, basis=SAMPLED
Space(belt).violations(Belt(9.0, 0.5)) # ["width_m=9.0 outside [0.6, 1.85]"]
plain(belt) # the same Belt with bare floats, for ROS / JSON
Why
The syntax applies to any domain, so it is its own package: robot_msgs is one vocabulary built on it, py_dataclass_viewer is one app built on it (Zach, 2026-11-10: "the pydataclass syntax can technically apply to any domain! robot_msgs is just a particular domain.").
Zach's rule (Oct 5 2026, do not re-litigate):
Value(1.2, "m", low=0.6, high=1.85, basis=Basis.CHOSEN, source="...")IS the builtin: a float/int/str/tuple subclass. "I definitely don't want to have to dowidth_m.value."- Spaces are derived:
Space(obj).sample()returns the same class, every ranged value markedbasis=SAMPLED. No secondPoseSpaceclass to drift from the one it shadows. plain()strips the notes at a runtime boundary. "We can use Value wherever we use a raw value normally and we can always strip it back to the plain value."
API
Value(raw, unit=None, *, low, high, step, choices, dist, basis, source, measured_by, notes, date_accessed)returnsFloatValue | IntValue | StrValue | TupleValue(also exported). Refused at construction when outside[low, high](tuples elementwise) or not inchoices.vis a short alias.meta(x)the evidence dict orNone;plain(obj)strips everyValue, through dataclasses, lists and tuples.Basis:CHOSEN DATASHEET MARKET ASSUMED MEASURED SAMPLED(aStrEnum).Uniform,Normal,LogUniform,Choice: per-value distributions with.draw(rng).Space(instance):.sample(rng=None),.contains(other),.violations(other)(dotted field paths). Subclasses add bounds by overriding the hooksextra_draw(drawn, rng)andextra_violations(other); robot_msgs uses them for numpy array bounds.
Tests
env -u VIRTUAL_ENV uv run --isolated --extra test python -m pytest -q
Metadata
Release files for dataclass-values 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dataclass_values-0.1.0.tar.gz | 12.3 kB | Without provenance | Details for dataclass_values-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dataclass_values-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for dataclass_values-0.1.0-py3-none-any.whl |
Total release size: 21.8 kB
Release files / dataclass_values-0.1.0.tar.gz
| Download URL | dataclass_values-0.1.0.tar.gz |
|---|---|
| Size | 12.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e95bafd4b96ef74bdb99d475ede4bac76115b1f8562407e42e0eabd7e9cbe3bc
|
|
BLAKE2b-256 checksum How to use checksums |
6cca387a299f05bcd7f76b26e0951f95527e9e68e29c02676c8d5186113ce7df
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / dataclass_values-0.1.0-py3-none-any.whl
| Download URL | dataclass_values-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
98faeb88a13c555d5e10ce5e17a9e5d6821483d1088d69ae72490269393e3ec7
|
|
BLAKE2b-256 checksum How to use checksums |
32d50269abcf68c59a3a9a032f52e84b5c88b3d50fb76b9aaf73783b7eb4fca8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for dataclass-values 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.