Repository navigation
0.2.0: generated source loads back every value it names - #4
Merged
Merged
Conversation
- imported_name: one qualified-name rule (import the root of __qualname__, spell the rest as attributes). Fixes nested enums (Outer.Mode.FAST imported Mode), nested dataclasses and callables; classes get a TypeFormatter instead of falling to repr. - PythonSourceLiteral: values that spell their own source through one source_fragment(context) method. - paths.py: document-level path factoring on FormatContext.paths; generate_python_source binds shared and repeated absolute paths once. FormatContext.extensions/extension() and the context= argument are removed. - Values without a formatter raise TypeError (FallbackFormatter emitted repr). - Full mode no longer replaces a None dataclass field with an all-None instance; init=False fields are skipped; ObjectState hasattr probes removed (objectstate.codegen owns lazy dataclasses). - frozenset, bytes, complex, non-finite floats, Flag combinations and named tuples load back exactly. - 0.2.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The contract is on native Path values: tests build absolute paths from this platform's anchor (and tmp_path), assert the source spells them with the platform's separators, and check the source loads back as equal Paths. Co-Authored-By: Claude Opus 5.5 <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.
Part of OpenHCS consolidation surface L6. Pipelines persist as pycodify-generated
.pyfiles, so a formatter gap is data loss.Fixes (each reproduced before the change)
Outer.Moderenderedfrom m import Mode/Mode.FAST, an ImportError on load. Nested dataclasses and callables had the same bug.<class 'm.X'>, a SyntaxError on load.FallbackFormatterwroterepr()for any value. Values with no formatter now raiseTypeError.Nonefield typed as a dataclass with an all-Noneinstance, so the value changed on load.init=Falsefields were written as constructor keywords, a TypeError on load.Adds
imported_name(module, qualname, context): the single qualified-name rule. Enum, class (TypeFormatter), callable, named-tuple and dataclass formatting all use it.PythonSourceLiteral: values that spell their own source throughsource_fragment(context).paths.py: document-level path factoring (path_root = Path(...),path_1 = path_root / 'x'), always on ingenerate_python_source.FormatContext.pathsis aPathRenderingfamily (plain, collecting, factored).frozenset,bytes,complex, non-finite floats,Flagcombinations and named tuples. Sets are sorted so output is stable.Removes (breaking, so 0.2.0):
FormatContext.extensions/extension(), thecontext=argument ofgenerate_python_source,FallbackFormatter, and the ObjectStatehasattrprobes, which move toobjectstate.codegenin ObjectState 2.1.0. This also covers the unreleased 0.1.4 branch (b6-release-0.1.4).Release order: release this first, then ObjectState 2.1.0, then repin OpenHCS.
Tests: local
pytestpassed (65).ruff,black --checkandmypyonsrc/report nothing. CI onmainwas already failing before this PR.🤖 Generated with Claude Code