Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve visibility of Python public APIs to type checkers #6462

Merged
merged 5 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions rerun_py/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ lint.unfixable = [

[tool.ruff.lint.isort]
required-imports = ["from __future__ import annotations"]
combine-as-imports = true # needed so keep rerun_sdk/__init__.py clean

[tool.maturin]
# We use a python package from inside the rerun_sdk folder to avoid conflicting
Expand Down
204 changes: 118 additions & 86 deletions rerun_py/rerun_sdk/rerun/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,106 +9,139 @@

# =====================================
# API RE-EXPORTS
# Important: always us the `import _ as _` format to make it explicit to type-checkers that these are public APIs.
# Background: https://github.com/microsoft/pyright/blob/1.1.365/docs/typed-libraries.md#library-interface
#
import rerun_bindings as bindings # type: ignore[attr-defined]

from ._image import ImageEncoded, ImageFormat
from . import (
blueprint as blueprint,
experimental as experimental,
)
from ._image import (
ImageEncoded as ImageEncoded,
ImageFormat as ImageFormat,
)
from ._log import (
AsComponents,
ComponentBatchLike,
IndicatorComponentBatch,
escape_entity_path_part,
log,
log_components,
log_file_from_contents,
log_file_from_path,
new_entity_path,
AsComponents as AsComponents,
ComponentBatchLike as ComponentBatchLike,
IndicatorComponentBatch as IndicatorComponentBatch,
escape_entity_path_part as escape_entity_path_part,
log as log,
log_components as log_components,
log_file_from_contents as log_file_from_contents,
log_file_from_path as log_file_from_path,
new_entity_path as new_entity_path,
)
from .any_value import (
AnyValues as AnyValues,
)
from .any_value import AnyValues
from .archetypes import (
AnnotationContext,
Arrows2D,
Arrows3D,
Asset3D,
BarChart,
Boxes2D,
Boxes3D,
Clear,
DepthImage,
DisconnectedSpace,
Image,
LineStrips2D,
LineStrips3D,
Mesh3D,
Pinhole,
Points2D,
Points3D,
Scalar,
SegmentationImage,
SeriesLine,
SeriesPoint,
Tensor,
TextDocument,
TextLog,
Transform3D,
ViewCoordinates,
AnnotationContext as AnnotationContext,
Arrows2D as Arrows2D,
Arrows3D as Arrows3D,
Asset3D as Asset3D,
BarChart as BarChart,
Boxes2D as Boxes2D,
Boxes3D as Boxes3D,
Clear as Clear,
DepthImage as DepthImage,
DisconnectedSpace as DisconnectedSpace,
Image as Image,
LineStrips2D as LineStrips2D,
LineStrips3D as LineStrips3D,
Mesh3D as Mesh3D,
Pinhole as Pinhole,
Points2D as Points2D,
Points3D as Points3D,
Scalar as Scalar,
SegmentationImage as SegmentationImage,
SeriesLine as SeriesLine,
SeriesPoint as SeriesPoint,
Tensor as Tensor,
TextDocument as TextDocument,
TextLog as TextLog,
Transform3D as Transform3D,
ViewCoordinates as ViewCoordinates,
)
from .archetypes.boxes2d_ext import (
Box2DFormat as Box2DFormat,
)
from .blueprint.api import (
BlueprintLike as BlueprintLike,
)
from .archetypes.boxes2d_ext import Box2DFormat
from .blueprint.api import BlueprintLike
from .components import (
Material,
MediaType,
OutOfTreeTransform3D,
OutOfTreeTransform3DBatch,
TextLogLevel,
Material as Material,
MediaType as MediaType,
OutOfTreeTransform3D as OutOfTreeTransform3D,
OutOfTreeTransform3DBatch as OutOfTreeTransform3DBatch,
TextLogLevel as TextLogLevel,
)
from .datatypes import (
AnnotationInfo,
ClassDescription,
Quaternion,
RotationAxisAngle,
Scale3D,
TensorData,
TimeInt,
TimeRange,
TimeRangeBoundary,
TranslationAndMat3x3,
TranslationRotationScale3D,
VisibleTimeRange,
AnnotationInfo as AnnotationInfo,
ClassDescription as ClassDescription,
Quaternion as Quaternion,
RotationAxisAngle as RotationAxisAngle,
Scale3D as Scale3D,
TensorData as TensorData,
TimeInt as TimeInt,
TimeRange as TimeRange,
TimeRangeBoundary as TimeRangeBoundary,
TranslationAndMat3x3 as TranslationAndMat3x3,
TranslationRotationScale3D as TranslationRotationScale3D,
VisibleTimeRange as VisibleTimeRange,
)
from .error_utils import (
set_strict_mode as set_strict_mode,
)
from .logging_handler import (
LoggingHandler as LoggingHandler,
)
from .memory import (
MemoryRecording as MemoryRecording,
memory_recording as memory_recording,
)
from .notebook import (
notebook_show as notebook_show,
)
from .error_utils import set_strict_mode
from .logging_handler import LoggingHandler
from .memory import MemoryRecording, memory_recording
from .notebook import notebook_show
from .recording_stream import (
BinaryStream,
RecordingStream,
binary_stream,
get_application_id,
get_data_recording,
get_global_data_recording,
get_recording_id,
get_thread_local_data_recording,
is_enabled,
new_recording,
recording_stream_generator_ctx,
set_global_data_recording,
set_thread_local_data_recording,
thread_local_stream,
BinaryStream as BinaryStream,
RecordingStream as RecordingStream,
binary_stream as binary_stream,
get_application_id as get_application_id,
get_data_recording as get_data_recording,
get_global_data_recording as get_global_data_recording,
get_recording_id as get_recording_id,
get_thread_local_data_recording as get_thread_local_data_recording,
is_enabled as is_enabled,
new_recording as new_recording,
recording_stream_generator_ctx as recording_stream_generator_ctx,
set_global_data_recording as set_global_data_recording,
set_thread_local_data_recording as set_thread_local_data_recording,
thread_local_stream as thread_local_stream,
)
from .script_helpers import (
script_add_args as script_add_args,
script_setup as script_setup,
script_teardown as script_teardown,
)
from .sinks import (
connect as connect,
disconnect as disconnect,
save as save,
send_blueprint as send_blueprint,
serve as serve,
spawn as spawn,
stdout as stdout,
)
from .script_helpers import script_add_args, script_setup, script_teardown
from .sinks import connect, disconnect, save, send_blueprint, serve, spawn, stdout
from .time import (
disable_timeline,
reset_time,
set_time_nanos,
set_time_seconds,
set_time_sequence,
disable_timeline as disable_timeline,
reset_time as reset_time,
set_time_nanos as set_time_nanos,
set_time_seconds as set_time_seconds,
set_time_sequence as set_time_sequence,
)

# Import experimental last
from . import experimental # isort: skip
from . import blueprint

# =====================================
# UTILITIES

Expand Down Expand Up @@ -321,7 +354,6 @@ def _register_on_fork() -> None:

_register_on_fork()


_TFunc = TypeVar("_TFunc", bound=Callable[..., Any])


Expand Down
77 changes: 44 additions & 33 deletions rerun_py/rerun_sdk/rerun/blueprint/__init__.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions rerun_py/rerun_sdk/rerun/blueprint/views/spatial2d_view.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions rerun_py/rerun_sdk/rerun/blueprint/views/spatial3d_view.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions rerun_py/rerun_sdk/rerun/blueprint/views/time_series_view.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions rerun_py/tests/unit/test_box2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,9 @@
labels_expected,
radii_arrays,
radii_expected,
)
from .common_arrays import (
vec2ds_arrays as centers_arrays,
)
from .common_arrays import (
vec2ds_arrays as half_sizes_arrays,
)
from .common_arrays import (
vec2ds_expected as centers_expected,
)
from .common_arrays import (
vec2ds_expected as half_sizes_expected,
)

Expand Down
8 changes: 0 additions & 8 deletions rerun_py/tests/unit/test_box3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,9 @@
radii_arrays,
radii_expected,
rotations_arrays,
)
from .common_arrays import (
vec3ds_arrays as centers_arrays,
)
from .common_arrays import (
vec3ds_arrays as half_sizes_arrays,
)
from .common_arrays import (
vec3ds_expected as centers_expected,
)
from .common_arrays import (
vec3ds_expected as half_sizes_expected,
)

Expand Down
Loading
Loading