Conversation
Return the (template, bounds) pair from BaseTemplate._homogenize_ranges as a
tuple rather than a list, and introduce type aliases so every annotation in
the template modules states what the code actually accepts and returns.
Each module now declares the same four aliases: the template or its link, the
canonical pair as a tuple, the same pair spelled as a list, and the union of
everything the setters take. Collapsing the nested unions into these aliases
removes the six-line annotations that the formatter had exploded.
Correct three annotations that the aliases exposed. The conditions and
parameters getters claimed to return bare templates when they return pairs.
The input annotations omitted the list form, which is not merely tolerated:
JSON arrays deserialize to lists, so every load path supplies the pair that
way.
This changes observable behavior. Pairs read back from a template are now
immutable, so code that assigned to one element must replace the pair
instead:
template.conditions[0][1] = None # before
template.conditions[0] = (template.conditions[0][0], None) # after
Objects built by earlier versions hold list pairs and do not compare equal to
objects built by this one. Data persisted as JSON is unaffected, since the
pair is rebuilt on load. The serialized form is byte-identical either way.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
kroenlein
marked this pull request as ready for review
September 28, 2026 23:03
This branch has not been deployed
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.
A quick follow on to #233 that consolidates type definitions to aid code readability. The clean up demonstrated ways in which the typing was subtly wrong, and so this includes changing the actual return and storage type of Template-Bounds pairs to tuples instead of lists. This should be transparent for nearly all workflows, barring if users were directly editing the tuples (a tuple is immutable).