Read an attribute or mapping key from a heterogeneous object. Forked messages can arrive as dataclass instances, plain dicts, or Pydantic-style objects. This helper unifies the reads.
(obj: Any, name: str, default: Any)
| 273 | |
| 274 | |
| 275 | def _get_attr(obj: Any, name: str, default: Any) -> Any: |
| 276 | """Read an attribute or mapping key from a heterogeneous object. |
| 277 | |
| 278 | Forked messages can arrive as dataclass instances, plain dicts, or |
| 279 | Pydantic-style objects. This helper unifies the reads. |
| 280 | """ |
| 281 | if obj is None: |
| 282 | return default |
| 283 | if isinstance(obj, dict): |
| 284 | return obj.get(name, default) |
| 285 | return getattr(obj, name, default) |
| 286 | |
| 287 | |
| 288 | __all__ = [ |
no test coverage detected