diff --git a/rerun_py/rerun_sdk/rerun/_log.py b/rerun_py/rerun_sdk/rerun/_log.py index d0f30509728..8530e50f083 100644 --- a/rerun_py/rerun_sdk/rerun/_log.py +++ b/rerun_py/rerun_sdk/rerun/_log.py @@ -123,14 +123,24 @@ def log( # structural checks in performance-sensitive code. hasattr is if hasattr(entity, "as_component_batches"): components = list(entity.as_component_batches()) - else: + elif isinstance(entity, Iterable): components = list(entity) + else: + raise TypeError( + f"Expected an object implementing rerun.AsComponents or an iterable of rerun.ComponentBatchLike, " + f"but got {type(entity)} instead." + ) for ext in extra: if hasattr(ext, "as_component_batches"): components.extend(ext.as_component_batches()) - else: + elif isinstance(ext, Iterable): components.extend(ext) + else: + raise TypeError( + f"Expected an object implementing rerun.AsComponents or an iterable of rerun.ComponentBatchLike, " + f"but got {type(entity)} instead." + ) if hasattr(entity, "num_instances"): num_instances = entity.num_instances() diff --git a/rerun_py/tests/unit/test_expected_warnings.py b/rerun_py/tests/unit/test_expected_warnings.py index 715793ab469..08ee62c3e1b 100644 --- a/rerun_py/tests/unit/test_expected_warnings.py +++ b/rerun_py/tests/unit/test_expected_warnings.py @@ -39,6 +39,10 @@ def test_expected_warnings() -> None: rr.log("test_transform", rr.Transform3D(mat3x3=[1, 2, 3, 4, 5])), "cannot reshape array of size 5 into shape (3,3))", ), + ( + rr.log("test_transform", rr.TranslationAndMat3x3(translation=[1, 0, 0])), # type: ignore[arg-type] + "Expected an object implementing rerun.AsComponents or an iterable of rerun.ComponentBatchLike, but got", + ), ] assert len(warnings) == len(expected_warnings)