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
{{ message }}
Repository navigation
Commit 89a8662
Browse filesBrowse the repository at this point in the historyBrowse files
fix: Expose the capability name as a FormatString, not a str
Review feedback on #373: consistency with the other v1 fields beats
consistency with v0 here.
openjd-rs#409 made template::AmountRequirement::name and
template::AttributeRequirement::name a FormatString. The first pass kept the
Python-facing `name` a `str` and parsed on the way in, on the grounds that
v0 models these as AmountCapabilityName / AttributeCapabilityName, both
subclasses of v0's FormatString, which subclasses str. That argument looks
at the wrong neighbour: every other FormatString-typed field on the v1
template types -- `min`, `max`, `anyOf`, `allOf`, `Action.command` -- is an
openjd.expr.FormatString and refuses a bare str. `name` now matches them.
This deletes more than it adds. parse_capability_name and its doc comment go
away, because the FormatString arrives already parsed, and both constructors
go back to being infallible. Validation moves to where it belongs: a
malformed name is rejected by FormatString's own constructor rather than by
a str-typed field that parses behind the caller's back. __repr__ keeps
.raw(), matching Action's treatment of its command.
This is a breaking change to the v1 Python API, and two pre-existing tests
prove it: TestPickle::test_amount_requirement and test_attribute_requirement
both passed `name=` a str, and TestStepTemplate::test_host_requirements
compared `.name` to one. All three are updated, so this is a behaviour
change and not a refactor.
Also from review: the spec edit that changed the documented ModelProfile repr
to `revision=v2023_09` was wrong -- PyModelProfile::__repr__ still emits the
uppercase-V form (rust-bindings/src/model/profile.rs:397), measured as
`ModelProfile(revision=V2023_09, extensions=[EXPR])`. Reverted. The two
`SpecificationRevision.v2023_09` corrections in the same block stand: that
repr is lowercase (profile.rs:63) and `V2023_09` is not an attribute at all.
The divergence between the two reprs is pre-existing and left alone here.
Verified: 6245 passed / 24 skipped / 3 xfailed, coverage 94.32%. ruff, black,
mypy, cargo fmt and clippy clean. Four mutants, each rebuilt and each caught:
reverting the pins to 0.9.0 kills 68 cases, formatting the FormatString in
both __repr__ sites kills 2, both getters returning a constant kills 12, and
both constructors discarding the supplied name kills 10.
Signed-off-by: David Leong <116610336+leongdl@users.noreply.github.com>
0 commit comments