auto-resolve controllers, use _raw_dict for cast#19
Merged
Merged
Conversation
Contributor
simontaurus
commented
May 11, 2026
- feat: auto-resolve controllers from _controller_types registry
- feat: _raw_dict for cast, BaseController.setattr, cleanup
- Add _controller_types registry alongside _types (v1 + v2) - Controllers registered via metaclass on class definition - resolve_type(): if exactly 1 controller for a type IRI, return it - If >1 controllers: log info with available options, return pure model - If controller construction fails: warn and fall back to pure model - Enables: OpcUaServer[iri] returns controller instance directly
…tattr__ All controllers inherit private attr handling, no need for per-mixin __setattr__ overrides.
- _raw_dict(): serialize object tree preserving inline objects at all depths. IRI-only fields included as strings. Replaces super().dict() + _recursive_object_to_iri(preserve_inline) in cast. - cast() and __init__: use _raw_dict for reliable nested object preservation through reconstruction - BaseController.__setattr__: route private attrs via object.__setattr__ - BaseController.to_jsonld: use strip approach (consistent with to_json) - Remove _cast_to_pure (unused), remove preserve_inline parameter - _controller_types registry, resolve_type, auto-resolution
Try Pydantic's __setattr__ first, catch ValueError/AttributeError and warn the user to declare the field properly or use _private name.
Contributor
📊 Benchmark ResultsClick to see benchmark comparisonThreshold: 1.3x (30% slower triggers a regression warning) Note: Benchmarks are informational only and won't fail the build. 💡 Tip: Download the |
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.