Repository navigation
fix(spec): read numbers in drawn text as the text drawn - #571
Merged
Merged
Conversation
The Python API drew a numeric description, reference, formula, sheet name, section heading, table-sheet number, note, box row or table header as text, but the spec reader refused the same value with a SpecError, so to_dict() wrote a spec from_dict() could not read. Drawn-text fields now read any scalar as its text; names, settings and annotation titles stay strict, and a list or mapping in drawn text is still refused. A float loop or instrument number drew as F-303.0, so add_loop(), Loop and Instrument now raise TypeError for one; text and any integer type, numpy included, are accepted. Closes #534
Alpha9463
force-pushed
the
fix/534-read-drawn-text
branch
from
October 2, 2026 04:36
9bdc794 to
126ca23
Compare
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
The Python API draws a number given for drawn text, such as a description, reference or table cell, as text. The spec reader refused the same value with a
SpecError, soto_dict()wrote a spec thatfrom_dict()could not read. Drawn-text fields now read any scalar as the text the sheet draws. Names, settings and annotation titles must still be text. A float loop or instrument number, which drew asF-303.0, is now refused. No drawing changes.Related Issues
Closes #534
Refs: #532, #533, #536
Changes
Spec reader (
pandid/spec.py): a new_drawnhelper reads a drawn-text field throughdocument._drawn_text, the same conversion the renderer uses, and refuses a list, tuple, set or mapping. It is used for:name;formula;descriptionandreference;sheet_subtitleandsheet_drawing_number;Still strict (
_text): unit, stream and component names;variant,displayandlabel_pos; section keys, which are matched against property names;col_align; and annotationtitle(per to_dict() silently drops a stated value and the sheet is redrawn differently: a fractional number-start, and a falsey annotation title #533).Python API:
Loop/add_loop()andInstrumentraiseTypeErrorfor a loop number that is neither text nor a whole number. Anynumbers.Integral,numpy.int64included, is accepted.Tests:
tests/test_stated_values.pyadds 9 tests:variant, annotationtitleand a list in drawn text are refused;8 of the 9 fail on
main.Docs:
docs/api.mdstates the loop-number and drawn-text rules.CHANGELOG.mdhas[Unreleased]entries.How to Test
Evidence
from_dict(to_dict())SpecErrorvariant,col_alignor annotation titleSpecErrorSpecErroradd_loop("F", 303.0),Instrument("LIC", 101.0)F-303.0,LIC-101.0TypeErrornumpy.int64loop numbermainfor 46 drawings (the 21 examples as authored and with placement stripped, plus four benchmark sheets).git diff --checkare clean. Pyright reports 0 errors plus the existing__all__warning, and 0 errors on the test file.Not changed
to_dict()still writes a numeric drawn-text value as the number given; the reader converts it.Checklist
mainand the branch is mergeable🤖 Generated with Claude Code