RFC-4: enforce the anatomical orientation vocabulary again - #595
Merged
Conversation
`orientation.yml` defines `AnatomicalOrientationValues` and its 24 values, but no slot takes it as a range, so the generated artifacts accept anything: ```python AnatomicalOrientation(type="planetary", value="north-to-south") ``` 535e661 made `name` and `type` reusable across the specification and removed the `attributes` block of `AnatomicalOrientation`, which carried the range on `value` along with it. `slot_usage` narrows an inherited slot inside one class, which is what `ChannelAxis`, `SpaceAxis` and `TimeAxis` already do here, so the shared slots stay as they are. `orientation.schema.json` gets back `"const": "anatomical"` and the `$ref` to `AnatomicalOrientationValues`; `orientation.py` gets `type: Literal["anatomical"]` and `value: AnatomicalOrientationValues`. Both now refuse the example above and accept `left-to-right`. `orientation.ts` is unchanged: `gen-typescript` emits `AnatomicalOrientation` as an empty interface extending `Orientation` and does not apply the subclass `slot_usage`. The markdown keeps the `orphan: true` front matter 0d68c8b added by hand, which `gen-markdown` does not emit.
Contributor
Automated Review URLs |
thewtex
approved these changes
Aug 27, 2026
Contributor
|
Thank you, @vboussot! Merging it here... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #585.
AnatomicalOrientationValuesis defined in the model, but nothing uses it as a range, so the generated artifacts let anything through:This adds a
slot_usageblock toAnatomicalOrientationthat narrows the two inherited slots, the same wayChannelAxis,SpaceAxisandTimeAxisalready do. The sharednameandtypeslots are left alone.After
pixi run gen-all, the JSON Schema has"const": "anatomical"and a$refto the vocabulary again, andorientation.pyhastype: Literal["anatomical"]andvalue: AnatomicalOrientationValues. Both reject the example above and acceptleft-to-right.orientation.tsdoes not change, becausegen-typescriptwritesAnatomicalOrientationas an empty interface extendingOrientation.The markdown keeps the
orphan: truefront matter from 0d68c8b, whichgen-markdowndoes not write itself.