Skip to content

Fix expr resolving to None when source class name contains a space#174

Closed
matentzn wants to merge 2 commits intomainfrom
fix/expr-space-class-name-170
Closed

Fix expr resolving to None when source class name contains a space#174
matentzn wants to merge 2 commits intomainfrom
fix/expr-space-class-name-170

Conversation

@matentzn
Copy link
Copy Markdown
Contributor

Summary

  • dynamic_object() creates Python types with type(target, (DynObj,), {}), using the raw class name (e.g. "my record")
  • ObjectIndex._class_map is keyed by SchemaView.class_name_mappings(), which applies camelcase() (e.g. "MyRecord")
  • When ObjectIndex.bless() looked up type(obj).__name__ in the class map, the mismatch caused a KeyError, silently returning None for all expr-based slot derivations
  • Fix: apply camelcase() to the type name in dynamic_object() so it matches ObjectIndex's expectations
  • populated_from was unaffected because it reads directly from the source dict without going through ObjectIndex

Test plan

  • Added regression tests for expr with spaced class names (with and without index)
  • Added test for expr with string concatenation and spaced class names
  • Full test suite passes (534 passed, 4 skipped)

Fixes #170
Supersedes #171 (addresses review feedback: removed unused imports)

🤖 Generated with Claude Code

matentzn and others added 2 commits March 29, 2026 00:16
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>
@matentzn matentzn closed this Mar 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

expr slot derivations resolve to None when source class name contains a space

1 participant