Repository navigation
fix(spec): stop to_dict dropping stated number starts and titles - #569
Merged
Merged
Conversation
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.
Summary
Stops
to_dict()from silently changing a sheet on the way to a file. A float number start drewS1.0and read back asS1; a falsy annotation title was dropped and the box came back re-measured. Number starts now accept integers only, and a stated annotation title is written as stated, so reading back a non-text title fails loudly instead of silently.Related Issues
Closes #533
Changes
Flowsheet.stream_number_start,line_number_startandloop_number_startbecome validated properties. A float (even1.0),Decimal, string orboolraisesTypeErrornaming the attribute, at construction and on assignment. Any integer type, includingnumpy.int64, is stored as anint.to_dict()compares with the default exactly as before, which is now exact because the values are always integers._write_annotationwrites the title whenever it differs from the default"", rather than only when truthy. A title of0,FalseorNoneis written as stated and refused byfrom_dict()with aSpecErrornamingannotations[N].title. Rendering is unchanged.tests/test_stated_values.py(27 tests) covers both halves, forAnnotationandTableBox.docs/api.mdon integer number starts, plus[Unreleased]entries inCHANGELOG.md.A correction to the issue text:
Annotation(title=0)never drew a"0"title. The band is drawn only for a truthy title while the box is sized fromstr(title), so it drew an untitled box sized as if titled. That rendering is unchanged here; the round trip now refuses it instead of silently resizing the box.How to Test
Evidence
git diff --checkare clean. Pyright reports 0 errors plus the existing__all__warning, and 0 errors on the new test file.mainfor 46 drawings (the 21 examples as authored and with placement stripped, plus four benchmark sheets).Checklist
mainand the branch is mergeable🤖 Generated with Claude Code