diff --git a/crates/re_types_builder/src/codegen/python/mod.rs b/crates/re_types_builder/src/codegen/python/mod.rs index 944533449758..568761db0b38 100644 --- a/crates/re_types_builder/src/codegen/python/mod.rs +++ b/crates/re_types_builder/src/codegen/python/mod.rs @@ -633,6 +633,20 @@ fn code_for_struct( code.push_indented(1, quote_init_method(reporter, obj, ext_class, objects), 2); } + // Generate __bool__ operator if this is a single field struct with a bool field. + if fields.len() == 1 && fields[0].typ == Type::Bool { + code.push_indented( + 1, + format!( + "def __bool__(self) -> bool: + return self.{} +", + fields[0].name + ), + 2, + ); + } + if obj.kind == ObjectKind::Archetype { code.push_indented(1, quote_clear_methods(obj), 2); } @@ -722,7 +736,11 @@ fn code_for_struct( if *kind == ObjectKind::Archetype { code.push_indented(1, "__str__ = Archetype.__str__", 1); - code.push_indented(1, "__repr__ = Archetype.__repr__", 1); + code.push_indented( + 1, + "__repr__ = Archetype.__repr__ # type: ignore[assignment] ", + 1, + ); } code.push_indented(1, quote_array_method_from_obj(ext_class, objects, obj), 1); diff --git a/rerun_py/rerun_sdk/rerun/__init__.py b/rerun_py/rerun_sdk/rerun/__init__.py index 2cbe560e54af..16087f9ff5dc 100644 --- a/rerun_py/rerun_sdk/rerun/__init__.py +++ b/rerun_py/rerun_sdk/rerun/__init__.py @@ -527,8 +527,9 @@ def _register_on_fork() -> None: try: import os - os.register_at_fork(after_in_child=cleanup_if_forked_child) + os.register_at_fork(after_in_child=cleanup_if_forked_child) # type: ignore[attr-defined] except AttributeError: + # not defined on all OSes pass diff --git a/rerun_py/rerun_sdk/rerun/archetypes/annotation_context.py b/rerun_py/rerun_sdk/rerun/archetypes/annotation_context.py index 81001eacac03..eb8ca1b1d6d6 100644 --- a/rerun_py/rerun_sdk/rerun/archetypes/annotation_context.py +++ b/rerun_py/rerun_sdk/rerun/archetypes/annotation_context.py @@ -99,4 +99,4 @@ def _clear(cls) -> AnnotationContext: # (Docstring intentionally commented out to hide this field from the docs) __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/archetypes/arrows2d.py b/rerun_py/rerun_sdk/rerun/archetypes/arrows2d.py index 7e4092bc5aa0..ffedc295a3bb 100644 --- a/rerun_py/rerun_sdk/rerun/archetypes/arrows2d.py +++ b/rerun_py/rerun_sdk/rerun/archetypes/arrows2d.py @@ -141,4 +141,4 @@ def _clear(cls) -> Arrows2D: # (Docstring intentionally commented out to hide this field from the docs) __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/archetypes/arrows3d.py b/rerun_py/rerun_sdk/rerun/archetypes/arrows3d.py index 001d29e00c3b..49721abf0625 100644 --- a/rerun_py/rerun_sdk/rerun/archetypes/arrows3d.py +++ b/rerun_py/rerun_sdk/rerun/archetypes/arrows3d.py @@ -141,4 +141,4 @@ def _clear(cls) -> Arrows3D: # (Docstring intentionally commented out to hide this field from the docs) __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/archetypes/asset3d.py b/rerun_py/rerun_sdk/rerun/archetypes/asset3d.py index db427cd479fa..3d7701dd8728 100644 --- a/rerun_py/rerun_sdk/rerun/archetypes/asset3d.py +++ b/rerun_py/rerun_sdk/rerun/archetypes/asset3d.py @@ -105,4 +105,4 @@ def _clear(cls) -> Asset3D: # (Docstring intentionally commented out to hide this field from the docs) __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/archetypes/bar_chart.py b/rerun_py/rerun_sdk/rerun/archetypes/bar_chart.py index 4d4a3f0dfcee..f064752589cb 100644 --- a/rerun_py/rerun_sdk/rerun/archetypes/bar_chart.py +++ b/rerun_py/rerun_sdk/rerun/archetypes/bar_chart.py @@ -96,4 +96,4 @@ def _clear(cls) -> BarChart: # (Docstring intentionally commented out to hide this field from the docs) __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/archetypes/boxes2d.py b/rerun_py/rerun_sdk/rerun/archetypes/boxes2d.py index 6f9076623820..e734e77c255d 100644 --- a/rerun_py/rerun_sdk/rerun/archetypes/boxes2d.py +++ b/rerun_py/rerun_sdk/rerun/archetypes/boxes2d.py @@ -144,4 +144,4 @@ def _clear(cls) -> Boxes2D: # (Docstring intentionally commented out to hide this field from the docs) __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/archetypes/boxes3d.py b/rerun_py/rerun_sdk/rerun/archetypes/boxes3d.py index 5179145ede4d..388c6bff9d25 100644 --- a/rerun_py/rerun_sdk/rerun/archetypes/boxes3d.py +++ b/rerun_py/rerun_sdk/rerun/archetypes/boxes3d.py @@ -148,4 +148,4 @@ def _clear(cls) -> Boxes3D: # (Docstring intentionally commented out to hide this field from the docs) __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/archetypes/clear.py b/rerun_py/rerun_sdk/rerun/archetypes/clear.py index 6af7602ce2aa..7ef92b975bff 100644 --- a/rerun_py/rerun_sdk/rerun/archetypes/clear.py +++ b/rerun_py/rerun_sdk/rerun/archetypes/clear.py @@ -81,4 +81,4 @@ def _clear(cls) -> Clear: converter=components.ClearIsRecursiveBatch._required, # type: ignore[misc] ) __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/archetypes/depth_image.py b/rerun_py/rerun_sdk/rerun/archetypes/depth_image.py index eb60e5c21abf..24b0a8881c58 100644 --- a/rerun_py/rerun_sdk/rerun/archetypes/depth_image.py +++ b/rerun_py/rerun_sdk/rerun/archetypes/depth_image.py @@ -142,4 +142,4 @@ def _clear(cls) -> DepthImage: # (Docstring intentionally commented out to hide this field from the docs) __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/archetypes/disconnected_space.py b/rerun_py/rerun_sdk/rerun/archetypes/disconnected_space.py index ebd4a0a7b6c6..78cd13d92b58 100644 --- a/rerun_py/rerun_sdk/rerun/archetypes/disconnected_space.py +++ b/rerun_py/rerun_sdk/rerun/archetypes/disconnected_space.py @@ -72,4 +72,4 @@ def _clear(cls) -> DisconnectedSpace: converter=components.DisconnectedSpaceBatch._required, # type: ignore[misc] ) __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/archetypes/image.py b/rerun_py/rerun_sdk/rerun/archetypes/image.py index 207b6ab815a1..f92faa9add66 100644 --- a/rerun_py/rerun_sdk/rerun/archetypes/image.py +++ b/rerun_py/rerun_sdk/rerun/archetypes/image.py @@ -115,4 +115,4 @@ def _clear(cls) -> Image: # (Docstring intentionally commented out to hide this field from the docs) __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/archetypes/line_strips2d.py b/rerun_py/rerun_sdk/rerun/archetypes/line_strips2d.py index 162decb396f9..146a1c20cea5 100644 --- a/rerun_py/rerun_sdk/rerun/archetypes/line_strips2d.py +++ b/rerun_py/rerun_sdk/rerun/archetypes/line_strips2d.py @@ -194,4 +194,4 @@ def _clear(cls) -> LineStrips2D: # (Docstring intentionally commented out to hide this field from the docs) __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/archetypes/line_strips3d.py b/rerun_py/rerun_sdk/rerun/archetypes/line_strips3d.py index 9ea3bb995057..1f68bcec9a0d 100644 --- a/rerun_py/rerun_sdk/rerun/archetypes/line_strips3d.py +++ b/rerun_py/rerun_sdk/rerun/archetypes/line_strips3d.py @@ -187,4 +187,4 @@ def _clear(cls) -> LineStrips3D: # (Docstring intentionally commented out to hide this field from the docs) __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/archetypes/mesh3d.py b/rerun_py/rerun_sdk/rerun/archetypes/mesh3d.py index 2344e5a7a383..6ff112861516 100644 --- a/rerun_py/rerun_sdk/rerun/archetypes/mesh3d.py +++ b/rerun_py/rerun_sdk/rerun/archetypes/mesh3d.py @@ -165,4 +165,4 @@ def _clear(cls) -> Mesh3D: # (Docstring intentionally commented out to hide this field from the docs) __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/archetypes/pinhole.py b/rerun_py/rerun_sdk/rerun/archetypes/pinhole.py index c2dc129a75ee..6107a10c4e18 100644 --- a/rerun_py/rerun_sdk/rerun/archetypes/pinhole.py +++ b/rerun_py/rerun_sdk/rerun/archetypes/pinhole.py @@ -142,4 +142,4 @@ def _clear(cls) -> Pinhole: # (Docstring intentionally commented out to hide this field from the docs) __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/archetypes/points2d.py b/rerun_py/rerun_sdk/rerun/archetypes/points2d.py index b41e0bd5fef1..794cc646bbc5 100644 --- a/rerun_py/rerun_sdk/rerun/archetypes/points2d.py +++ b/rerun_py/rerun_sdk/rerun/archetypes/points2d.py @@ -158,4 +158,4 @@ def _clear(cls) -> Points2D: # (Docstring intentionally commented out to hide this field from the docs) __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/archetypes/points3d.py b/rerun_py/rerun_sdk/rerun/archetypes/points3d.py index 430636adc6b6..e94142e60079 100644 --- a/rerun_py/rerun_sdk/rerun/archetypes/points3d.py +++ b/rerun_py/rerun_sdk/rerun/archetypes/points3d.py @@ -143,4 +143,4 @@ def _clear(cls) -> Points3D: # (Docstring intentionally commented out to hide this field from the docs) __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/archetypes/scalar.py b/rerun_py/rerun_sdk/rerun/archetypes/scalar.py index 571cb411244c..57fa998e48eb 100644 --- a/rerun_py/rerun_sdk/rerun/archetypes/scalar.py +++ b/rerun_py/rerun_sdk/rerun/archetypes/scalar.py @@ -97,4 +97,4 @@ def _clear(cls) -> Scalar: # (Docstring intentionally commented out to hide this field from the docs) __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/archetypes/segmentation_image.py b/rerun_py/rerun_sdk/rerun/archetypes/segmentation_image.py index 2821b8f5dbda..a8af5f053ff5 100644 --- a/rerun_py/rerun_sdk/rerun/archetypes/segmentation_image.py +++ b/rerun_py/rerun_sdk/rerun/archetypes/segmentation_image.py @@ -119,4 +119,4 @@ def _clear(cls) -> SegmentationImage: # (Docstring intentionally commented out to hide this field from the docs) __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/archetypes/series_line.py b/rerun_py/rerun_sdk/rerun/archetypes/series_line.py index 4899d8ce5e6a..43f7f66119de 100644 --- a/rerun_py/rerun_sdk/rerun/archetypes/series_line.py +++ b/rerun_py/rerun_sdk/rerun/archetypes/series_line.py @@ -136,4 +136,4 @@ def _clear(cls) -> SeriesLine: # (Docstring intentionally commented out to hide this field from the docs) __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/archetypes/series_point.py b/rerun_py/rerun_sdk/rerun/archetypes/series_point.py index deee3202e0f7..bfc95f9581d2 100644 --- a/rerun_py/rerun_sdk/rerun/archetypes/series_point.py +++ b/rerun_py/rerun_sdk/rerun/archetypes/series_point.py @@ -167,4 +167,4 @@ def _clear(cls) -> SeriesPoint: # (Docstring intentionally commented out to hide this field from the docs) __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/archetypes/tensor.py b/rerun_py/rerun_sdk/rerun/archetypes/tensor.py index c75661464a3f..dc11c7376cdc 100644 --- a/rerun_py/rerun_sdk/rerun/archetypes/tensor.py +++ b/rerun_py/rerun_sdk/rerun/archetypes/tensor.py @@ -69,4 +69,4 @@ def _clear(cls) -> Tensor: # (Docstring intentionally commented out to hide this field from the docs) __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/archetypes/text_document.py b/rerun_py/rerun_sdk/rerun/archetypes/text_document.py index ec496069bd87..43f28c60a779 100644 --- a/rerun_py/rerun_sdk/rerun/archetypes/text_document.py +++ b/rerun_py/rerun_sdk/rerun/archetypes/text_document.py @@ -150,4 +150,4 @@ def _clear(cls) -> TextDocument: # (Docstring intentionally commented out to hide this field from the docs) __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/archetypes/text_log.py b/rerun_py/rerun_sdk/rerun/archetypes/text_log.py index 274200acd5c3..7b8251ad8c8e 100644 --- a/rerun_py/rerun_sdk/rerun/archetypes/text_log.py +++ b/rerun_py/rerun_sdk/rerun/archetypes/text_log.py @@ -124,4 +124,4 @@ def _clear(cls) -> TextLog: # (Docstring intentionally commented out to hide this field from the docs) __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/archetypes/time_series_scalar.py b/rerun_py/rerun_sdk/rerun/archetypes/time_series_scalar.py index 4332f8b434f4..56a076fca967 100644 --- a/rerun_py/rerun_sdk/rerun/archetypes/time_series_scalar.py +++ b/rerun_py/rerun_sdk/rerun/archetypes/time_series_scalar.py @@ -215,4 +215,4 @@ def _clear(cls) -> TimeSeriesScalar: # (Docstring intentionally commented out to hide this field from the docs) __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/archetypes/transform3d.py b/rerun_py/rerun_sdk/rerun/archetypes/transform3d.py index 98525aeb4a0c..49f89f85d1ee 100644 --- a/rerun_py/rerun_sdk/rerun/archetypes/transform3d.py +++ b/rerun_py/rerun_sdk/rerun/archetypes/transform3d.py @@ -82,4 +82,4 @@ def _clear(cls) -> Transform3D: # (Docstring intentionally commented out to hide this field from the docs) __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/archetypes/view_coordinates.py b/rerun_py/rerun_sdk/rerun/archetypes/view_coordinates.py index a5026315cc66..7eedfc433b8b 100644 --- a/rerun_py/rerun_sdk/rerun/archetypes/view_coordinates.py +++ b/rerun_py/rerun_sdk/rerun/archetypes/view_coordinates.py @@ -85,7 +85,7 @@ def _clear(cls) -> ViewCoordinates: converter=components.ViewCoordinatesBatch._required, # type: ignore[misc] ) __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] ViewCoordinatesExt.deferred_patch_class(ViewCoordinates) diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/container_blueprint.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/container_blueprint.py index d801e26f013c..97484792d2fa 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/container_blueprint.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/container_blueprint.py @@ -196,4 +196,4 @@ def _clear(cls) -> ContainerBlueprint: # (Docstring intentionally commented out to hide this field from the docs) __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/plot_legend.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/plot_legend.py index 0e2fd0b8a33a..e97ac8a9bc9d 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/plot_legend.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/plot_legend.py @@ -85,4 +85,4 @@ def _clear(cls) -> PlotLegend: # (Docstring intentionally commented out to hide this field from the docs) __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/scalar_axis.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/scalar_axis.py index 3998346dc287..77e0fe6c7556 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/scalar_axis.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/scalar_axis.py @@ -82,4 +82,4 @@ def _clear(cls) -> ScalarAxis: # (Docstring intentionally commented out to hide this field from the docs) __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/space_view_blueprint.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/space_view_blueprint.py index d73ab58da2d3..61eabd7d801d 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/space_view_blueprint.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/space_view_blueprint.py @@ -152,4 +152,4 @@ def _clear(cls) -> SpaceViewBlueprint: # (Docstring intentionally commented out to hide this field from the docs) __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/viewport_blueprint.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/viewport_blueprint.py index 537985c01a84..dcac87f9827b 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/viewport_blueprint.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/viewport_blueprint.py @@ -128,4 +128,4 @@ def _clear(cls) -> ViewportBlueprint: # (Docstring intentionally commented out to hide this field from the docs) __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/auto_layout.py b/rerun_py/rerun_sdk/rerun/blueprint/components/auto_layout.py index a53b953a6741..71e8613600a4 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/components/auto_layout.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/auto_layout.py @@ -30,6 +30,9 @@ def __init__(self: Any, auto_layout: AutoLayoutLike): # You can define your own __init__ function as a member of AutoLayoutExt in auto_layout_ext.py self.__attrs_init__(auto_layout=auto_layout) + def __bool__(self) -> bool: + return self.auto_layout + auto_layout: bool = field(converter=bool) diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/auto_space_views.py b/rerun_py/rerun_sdk/rerun/blueprint/components/auto_space_views.py index f3205556c56f..1b12e156e2b9 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/components/auto_space_views.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/auto_space_views.py @@ -36,6 +36,9 @@ def __init__(self: Any, auto_space_views: AutoSpaceViewsLike): # You can define your own __init__ function as a member of AutoSpaceViewsExt in auto_space_views_ext.py self.__attrs_init__(auto_space_views=auto_space_views) + def __bool__(self) -> bool: + return self.auto_space_views + auto_space_views: bool = field(converter=bool) diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/entities_determined_by_user.py b/rerun_py/rerun_sdk/rerun/blueprint/components/entities_determined_by_user.py index 3817582a77a4..b1dd1836cdd3 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/components/entities_determined_by_user.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/entities_determined_by_user.py @@ -31,6 +31,9 @@ def __init__(self: Any, value: EntitiesDeterminedByUserLike): # You can define your own __init__ function as a member of EntitiesDeterminedByUserExt in entities_determined_by_user_ext.py self.__attrs_init__(value=value) + def __bool__(self) -> bool: + return self.value + value: bool = field(converter=bool) diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/lock_range_during_zoom.py b/rerun_py/rerun_sdk/rerun/blueprint/components/lock_range_during_zoom.py index c49e2abee317..657d5d9dea7b 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/components/lock_range_during_zoom.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/lock_range_during_zoom.py @@ -35,6 +35,9 @@ def __init__(self: Any, lock_range: LockRangeDuringZoomLike): # You can define your own __init__ function as a member of LockRangeDuringZoomExt in lock_range_during_zoom_ext.py self.__attrs_init__(lock_range=lock_range) + def __bool__(self) -> bool: + return self.lock_range + lock_range: bool = field(converter=bool) diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/panel_view.py b/rerun_py/rerun_sdk/rerun/blueprint/components/panel_view.py index c240fa49a13d..6db8186d5dfb 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/components/panel_view.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/panel_view.py @@ -29,6 +29,9 @@ def __init__(self: Any, is_expanded: PanelViewLike): # You can define your own __init__ function as a member of PanelViewExt in panel_view_ext.py self.__attrs_init__(is_expanded=is_expanded) + def __bool__(self) -> bool: + return self.is_expanded + is_expanded: bool = field(converter=bool) diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/visible.py b/rerun_py/rerun_sdk/rerun/blueprint/components/visible.py index f2a95c6bd56a..57269d665ff9 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/components/visible.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/visible.py @@ -25,6 +25,9 @@ def __init__(self: Any, visible: VisibleLike): # You can define your own __init__ function as a member of VisibleExt in visible_ext.py self.__attrs_init__(visible=visible) + def __bool__(self) -> bool: + return self.visible + visible: bool = field(converter=bool) diff --git a/rerun_py/rerun_sdk/rerun/components/clear_is_recursive.py b/rerun_py/rerun_sdk/rerun/components/clear_is_recursive.py index 1ae85c10bf62..f6aaef5e515d 100644 --- a/rerun_py/rerun_sdk/rerun/components/clear_is_recursive.py +++ b/rerun_py/rerun_sdk/rerun/components/clear_is_recursive.py @@ -42,6 +42,9 @@ def __init__(self: Any, recursive: ClearIsRecursiveLike): # You can define your own __init__ function as a member of ClearIsRecursiveExt in clear_is_recursive_ext.py self.__attrs_init__(recursive=recursive) + def __bool__(self) -> bool: + return self.recursive + recursive: bool = field(converter=bool) # If true, also clears all recursive children entities. # diff --git a/rerun_py/rerun_sdk/rerun/components/disconnected_space.py b/rerun_py/rerun_sdk/rerun/components/disconnected_space.py index 6a676aeab3ce..c5c05849852d 100644 --- a/rerun_py/rerun_sdk/rerun/components/disconnected_space.py +++ b/rerun_py/rerun_sdk/rerun/components/disconnected_space.py @@ -37,6 +37,9 @@ class DisconnectedSpace(DisconnectedSpaceExt): # __init__ can be found in disconnected_space_ext.py + def __bool__(self) -> bool: + return self.is_disconnected + is_disconnected: bool = field(converter=bool) # Whether the entity path at which this is logged is disconnected from its parent. # diff --git a/rerun_py/rerun_sdk/rerun/components/scalar_scattering.py b/rerun_py/rerun_sdk/rerun/components/scalar_scattering.py index fe7fc3529c70..0759e4a512df 100644 --- a/rerun_py/rerun_sdk/rerun/components/scalar_scattering.py +++ b/rerun_py/rerun_sdk/rerun/components/scalar_scattering.py @@ -34,6 +34,9 @@ def __init__(self: Any, scattered: ScalarScatteringLike): # You can define your own __init__ function as a member of ScalarScatteringExt in scalar_scattering_ext.py self.__attrs_init__(scattered=scattered) + def __bool__(self) -> bool: + return self.scattered + scattered: bool = field(converter=bool) diff --git a/rerun_py/tests/test_types/archetypes/affix_fuzzer1.py b/rerun_py/tests/test_types/archetypes/affix_fuzzer1.py index 8738b4e2ee4d..f0c87eda052a 100644 --- a/rerun_py/tests/test_types/archetypes/affix_fuzzer1.py +++ b/rerun_py/tests/test_types/archetypes/affix_fuzzer1.py @@ -197,4 +197,4 @@ def _clear(cls) -> AffixFuzzer1: converter=components.AffixFuzzer22Batch._required, # type: ignore[misc] ) __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/tests/test_types/archetypes/affix_fuzzer2.py b/rerun_py/tests/test_types/archetypes/affix_fuzzer2.py index 3e8324450d47..66ab1810de23 100644 --- a/rerun_py/tests/test_types/archetypes/affix_fuzzer2.py +++ b/rerun_py/tests/test_types/archetypes/affix_fuzzer2.py @@ -176,4 +176,4 @@ def _clear(cls) -> AffixFuzzer2: converter=components.AffixFuzzer22Batch._required, # type: ignore[misc] ) __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/tests/test_types/archetypes/affix_fuzzer3.py b/rerun_py/tests/test_types/archetypes/affix_fuzzer3.py index 831a9bfa4537..75b47e0c1be5 100644 --- a/rerun_py/tests/test_types/archetypes/affix_fuzzer3.py +++ b/rerun_py/tests/test_types/archetypes/affix_fuzzer3.py @@ -188,4 +188,4 @@ def _clear(cls) -> AffixFuzzer3: converter=components.AffixFuzzer18Batch._optional, # type: ignore[misc] ) __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/tests/test_types/archetypes/affix_fuzzer4.py b/rerun_py/tests/test_types/archetypes/affix_fuzzer4.py index 54fdf6110bf4..58d745945694 100644 --- a/rerun_py/tests/test_types/archetypes/affix_fuzzer4.py +++ b/rerun_py/tests/test_types/archetypes/affix_fuzzer4.py @@ -188,4 +188,4 @@ def _clear(cls) -> AffixFuzzer4: converter=components.AffixFuzzer18Batch._optional, # type: ignore[misc] ) __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/tests/unit/test_clear.py b/rerun_py/tests/unit/test_clear.py index cea1a46d559b..bb6d1f1854b5 100644 --- a/rerun_py/tests/unit/test_clear.py +++ b/rerun_py/tests/unit/test_clear.py @@ -1,7 +1,8 @@ from __future__ import annotations +import numpy as np import rerun as rr -from rerun.components import ClearIsRecursiveBatch +from rerun.components import ClearIsRecursive, ClearIsRecursiveBatch def test_clear() -> None: @@ -19,5 +20,15 @@ def test_clear_factory_methods() -> None: assert rr.Clear(recursive=False) == rr.Clear.flat() +def test_truthiness() -> None: + assert ClearIsRecursive(recursive=True) + assert not ClearIsRecursive(recursive=False) + + assert np.array_equal( + np.array([ClearIsRecursive(recursive=True), ClearIsRecursive(recursive=False)], dtype=np.bool_), + np.array([True, False], dtype=np.bool_), + ) + + if __name__ == "__main__": test_clear()