Repository navigation
Fix circular imports between standalone and bundled code, and a set of expression and serialization defects - #332
Draft
dschwartznyc wants to merge 42 commits into
Draft
dschwartznyc wants to merge 42 commits into
dschwartznyc wants to merge 42 commits into
Conversation
…and circular dependency handling
…ing in generated bundles
… standalone functions
… in generated Python code
…tched value as item, and return nothing for absent values (#320)
…:scoped is written (#323)
…ization to match the Java implementation
…o fix-circular-import-error
…o fix-circular-import-error
dschwartznyc
requested review from
davidalk,
hugohills-regnosys and
plamen-neykov
November 12, 2026 20:35
…es in Python generator
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.
This branch started as the fix for circular
ImportErrors between standalone and bundled generated code, and grew to cover the generator defects found while checking generated Python against the DSL and Java. It also generates what the runtime needs to read and write choice types in Java's flat@typeformat, which rune.runtime 3.1.0 supports.Closes #312
Closes #313
Closes #314
Closes #315
Closes #316
Closes #317
Closes #318
Closes #319
Closes #320
Closes #322
Closes #323
Closes #324
Closes #331
Closes #333
Closes #337
Issues fixed
Bundling and imports
ImportErroror "Input should be None".setaren't lists, and standalone class conditions don't import the functions they call #315: multi-valued function outputs filled withsetare lists, and standalone class conditions import the functions they call.switch,with-meta, dispatch functions and extended enums #317: generated code imports what it uses, and uses the right enum, for references inswitch,with-meta, dispatch functions and extended enums.Expressions
extractover a single value and on unqualified enum values #313:extractover a single value and unqualified enum values no longer crash.countreturns the field count, or crashes, when applied to a single model object #314:counton a single model object returns 1, not the object's field count.filteron a single value fails in functions and gives wrong results in conditions #318:filteron a single value works in functions and gives the right result in conditions.to-enumwith a value that doesn't match the enum follows the DSL and Java.switchgives wrong results for types with subtypes, choice options and absent values #320:switchmatches cases by type and by nested choice option, binds the matched value asitem, and returns nothing for absent values.asto narrow to a data type fail withNameError#322: conditions that useasto narrow to a data type no longer fail withNameError.Model structure
int,str,boolordatetimeisn't validated, or stops its class from loading #331: an attribute named after a Python name its own type uses (int,str,bool,datetime,Decimal) is validated again. Its type is written through an alias (_builtins.int,_datetime.date,_decimal.Decimal), so the attribute's name doesn't shadow it. Covers standalone and bundled classes, and choice options such asint.Serialization
@key:scopedis lost when writing JSON #323: fields of bundled classes get their metadata serializer and validator, so@key:scopedis written.[metadata key]don't get their metadata serializer and validator, so@keyand@key:externalare lost when writing JSON #324: standalone fields whose type has[metadata key]get their metadata serializer and validator, so@keyand@key:externalare written._CHOICE_DISPATCHtable on choice classes, so the runtime can find the option for a choice's@type#333: choice classes are marked with_RUNE_CHOICEand carry a_CHOICE_DISPATCHtable mapping each@typethey can be read with to the option that holds it, so the runtime can read and write the flat choice format (Python and Java serialize Rune choice types differently rune-python-runtime#55). Keys are Rune names only: a data type or enum is keyed by its Rune FQN and a basic type by its option name, with or without metadata, and namespaces get no special treatment. Intermediate choices are listed only when their option has metadata (fix: prune redundant choice dispatch entries #334). A leaf reachable through two options of one choice fails generation; the DSL warns about this shape (Warn when nested choice options share a leaf type rune-dsl#1422). This supersedes Use Rune FQNs for enum choice dispatch #338.java.lang.String) for basic choice options with metadata, and the option name for plain enum options, so for those cases this output differs from Java's; that is being raised with finos/rune-common.Build and tests
validate, before the shade plugin moves the project base directory, so it checks files again (it had checked none since it was added). Missing headers added; local virtual environments excluded.PythonDependencyCollectormadefinal, themodel_fieldsprefix made a named constant, andPythonTomlGeneratorTestmoved to theutilpackage. Warnings down from 139 to 39 (35 line length, 3 parameter count, 1 method length).run_serialization_tests.shstages only the rune-common suites that can be generated together (the round-trip suite and the invalid-choice groups), plus the error-handling cases, which are now tracked in this repository. It clears earlier output before generating, installs the generated tests without dependencies when a local or GitHub runtime is configured, and leaves rune-common'sChoiceDeepNestedout of the run, along with its 3 fixtures, until the model is updated (Round-trip test modelchoicetype/choice.rosettaneeds updating when duplicate choice leaves become an error rune-dsl#1464).python-test/cdm-tests/java-validation/: a Java baseline for the CDM FpML ingestion samples (read, round-trip and validate with CDM's Java), for comparison with the generated Python.int,str,boolordatetimeisn't validated, or stops its class from loading #331).jvnet-nexus-releasesbuild warning (Build warning about the retired jvnet-nexus-releases repository with Maven 3.10+ (upstream: maven-checkstyle-plugin 3.6.0) #335, frommaven-checkstyle-plugin3.6.0) is documented inpom.xmlanddocs/BUILD_AND_TEST.md.build/removed;.gitignorecleaned up.Test results
At
8d2babd, with rune.runtime 3.1.0 from PyPI:mvn clean verify): 378 run, 0 failures, 1 skipped (the documented type alias condition gap). License check: 171 files, 0 missing.ChoiceDeepNestedfixtures).Dependencies
_RUNE_CHOICEand_CHOICE_DISPATCH. Generated projects now requirerune.runtime>=3.1.0,<4.0.0.main, restores the serializer and validator on standalone data-type fields. The subtype tests forswitchgives wrong results for types with subtypes, choice options and absent values #320 and Conditions that useasto narrow to a data type fail withNameError#322 (test_type_switch.py,test_as_in_condition.py) depend on it.Before marking ready
maininto this branch.@type: generated_CHOICE_DISPATCHtable (Generate a_CHOICE_DISPATCHtable on choice classes, so the runtime can find the option for a choice's@type#333).rune.runtimepin to the release with Support Java flat serialization for Rune choices rune-python-runtime#77:>=3.1.0,<4.0.0.Not included
jvnet-nexus-releasesbuild warning) needsmaven-checkstyle-plugin3.6.1; documented here, closes when that release is adopted.