You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Add support for schema 46 metadata fields
Schema 46 (upstream PR #1501) adds two metadata fields:
- `allowed`: list of allowed values for numeric value metadata and
configuration metadata, where each entry is either a single value
(`{value}`) or an inclusive range (`{from, to, step?}`)
- `purpose`: free-form string on configuration metadata
`AllowedValue` is exposed as a discriminated union of two frozen
dataclasses (`AllowedSingleValue`, `AllowedRangeValue`) so consumers
use `isinstance()` to discriminate. The `ValueMetadata.allowed`
accessor is a `cached_property` because parsing allocates new dataclass
instances; the cache is invalidated in `update()` only when the
incoming patch contains the `allowed` key.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Address Copilot review: use cast instead of dict copy in allowed parser
Copilot flagged that `ValueMetadata.allowed` built a new `dict(entry)`
on every iteration (plus a `type: ignore`) inside a method explicitly
cached to reduce allocations. Replace with `typing.cast`, which is a
runtime no-op, so each iteration now touches the original entry dict
directly and drops the `type: ignore`.
Only the `if` branch needs an explicit cast — mypy narrows the `else`
branch automatically from `"value" in entry` being false.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Add from_dict classmethods to AllowedSingleValue/AllowedRangeValue
Follow the codebase convention of putting dict-to-dataclass conversion
into a `from_dict` classmethod rather than inline in the caller. The
`allowed` property accessor now delegates to these methods.
No `to_dict` needed — `AllowedValue` is read-only server metadata that
is never sent back, matching the event model precedent.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix ref to self
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
0 commit comments