Fix expr resolving to None when source class name contains a space#174
Closed
Fix expr resolving to None when source class name contains a space#174
Conversation
When a slot has `range=None` and no `any_of` enums, `_map_value_by_range` now returns scalar values directly instead of recursing into `map_object` with `None` as the source type. This eliminates spurious "Unexpected: ... for type None" warnings.
dynamic_object() created Python types using the raw class name (e.g. "my record"), but ObjectIndex._class_map is keyed by camelcase names via SchemaView.class_name_mappings() (e.g. "MyRecord"). When ObjectIndex.bless() looked up type(obj).__name__, the mismatch caused a KeyError, silently returning None for all expr-based slot derivations. Apply camelcase() to the type name in dynamic_object() to match ObjectIndex's class map. The populated_from path was unaffected because it reads directly from the source dict without going through ObjectIndex. Fixes #170 Co-Authored-By: Claude Opus 4.6 (1M context) <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
dynamic_object()creates Python types withtype(target, (DynObj,), {}), using the raw class name (e.g."my record")ObjectIndex._class_mapis keyed bySchemaView.class_name_mappings(), which appliescamelcase()(e.g."MyRecord")ObjectIndex.bless()looked uptype(obj).__name__in the class map, the mismatch caused aKeyError, silently returningNonefor allexpr-based slot derivationscamelcase()to the type name indynamic_object()so it matchesObjectIndex's expectationspopulated_fromwas unaffected because it reads directly from the source dict without going throughObjectIndexTest plan
exprwith spaced class names (with and without index)exprwith string concatenation and spaced class namesFixes #170
Supersedes #171 (addresses review feedback: removed unused imports)
🤖 Generated with Claude Code