Extend pySpecs translator to handle all service specification constructs#537
Merged
Extend pySpecs translator to handle all service specification constructs#537
Conversation
6a4f36f to
35aea85
Compare
shigoel
previously approved these changes
Mar 10, 2026
aqjune-aws
previously approved these changes
Mar 10, 2026
31940a2 to
8dfe875
Compare
- F-string assertion messages preserved as MessagePart arrays - For-loop quantifiers: forallList (List/Sequence) and forallDict (Dict/Mapping) - Conditional implication via assumeCondition for if/else blocks - __init__ class field extraction with constValue support - Type-checked float/int comparisons with fallback for mixed types - Negative integer bounds via extractIntBound (ConNeg, UnaryOp USub) - negInt DDM encoding with explicit 0 edge case handling - DDM operator precedences: subscript@50, comparison@15, implication@10 - Warn on unrecognized if-conditions, for/else, type_comment, type_params - Extract resolveBaseClasses and makeComparison helpers to reduce duplication - Remove dead Pred and Iterable types - Add positive tests (float, negative, __init__, else-branch, negative float) - Add negative warning tests (unsupported assert, bad init, for/else, skipped stmts) - Fix missing s! interpolation in 3 error messages - DDM Int round-trip tests via #guard Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
8dfe875 to
e6d663a
Compare
Contributor
Author
Review fixes (force-pushed)Addressed all 13 issues from code review, rebased on latest main, and squashed into a single commit. Correctness
Safety
Structure
Test Coverage
Style
|
shigoel
approved these changes
Mar 10, 2026
aqjune-aws
approved these changes
Mar 11, 2026
github-merge-queue bot
pushed a commit
that referenced
this pull request
Mar 11, 2026
## Summary - Remove `review_notes.md` that was accidentally committed as part of PR #537 review ## Test plan - No functional changes; only deletes a non-code file By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
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
Extend the Strata
pySpecsPython-to-spec translator to handle the fullrange of assertion patterns found across service specification files.
Before this change the translator emitted warnings on many common
patterns; after, it handles all constructs without warnings.
Builds on the robustness and API improvements from #512.
Details
are now preserved semantically (distinguishing literal text from
interpolated expressions) rather than being flattened to a single
string.
for item in kwargs["field"]loops aretranslated to
forallListquantifiers. The element type is inferredfrom
typing.Listortyping.Sequenceannotations in thecorresponding TypedDict.
for k, v in dict.items()tuple unpackingis handled similarly via
forallDict, with key/value types inferredfrom
DictorMappingannotations.ifblock (e.g.
if "Items" in kwargs:), the condition becomes anantecedent:
implies(condition, assertion). Else-branch assertionsreceive the negated condition.
__init__as class fields. Rather than treating__init__as aregular method, the translator now extracts
self.field = self._ClassName()assignments as typed class fieldswith an optional constant value. Unhandled
__init__patternsemit warnings.
(
>=,<=) now use type inference to choose between integer andfloating-point operators. When a float-typed field is compared
against an integer literal (e.g.
SampleSize >= 0), the bound ispromoted to float automatically. Negative integer bounds (
>= -1)are also supported.
negSuccround-trip inthe DDM serialization layer so that
-1renders as"-1"ratherthan
"-0".operators have explicit precedences so the pretty-printer no longer
emits unnecessary parentheses.
iteration, conditionals,
__init__fields, float/int comparisons,and negative bounds. A separate negative-test file (
warnings.py)verifies that unsupported patterns produce the expected warnings.
Test assertions now throw descriptive errors instead of panicking.
By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your choice.