Skip to content

chore: annotate Sources and document the ImageSource base class - #255

Merged
petercorke merged 2 commits into
mainfrom
chore/types-sources
Nov 23, 2026
Merged

petercorke merged 2 commits into
mainfrom
chore/types-sources

Conversation

@petercorke

Copy link
Copy Markdown
Owner

Annotates Sources.py, the second largest gap in the type-hint work of Issue 60 (50 of 198 parameters and 17 of 200 returns were unannotated). Annotation and docstring changes only, no behaviour change.

  • The eight __exit__ methods take type[BaseException] | None, BaseException | None and TracebackType | None, and the one that took *_ is typed too.
  • ImageSource.tensor(normalize=) is str | tuple[Any, Any] | None, matching Image.tensor. disp(**kwargs), ROSBag.print(file=), _allowed, _stamp_to_ns and _resolve_typestore are typed.
  • The nested helpers of disp for images and for point clouds (_label, _make_overlay, _win_title, _update_cloud, the on_key handlers and the Open3D key callbacks _on_quit, _on_pause, _on_faster, _on_slower, _on_next, _mk_jump) have types. The Open3D callbacks return bool, as the library expects.
  • view_state is annotated dict[str, Any]. mypy had inferred dict[str, int] from the mixed literal and then rejected passing its first value as a bool.
  • The abstract class ImageSource had no docstring, and gets one.

I left alone the 24 :seealso: fields and 12 Example: blocks, which AGENTS.md says to migrate gradually, and the methods with no docstring that are documented by their class (__init__, __iter__, __len__). Issue 150 plans to split Sources.py into a package; these annotations move with the code.

mypy reports no issues and the full suite passes (2151 passed, 33 skipped).

AI-assisted: written with Claude Code (Claude Sonnet 5.5) and reviewed by the maintainer.

🤖 Generated with Claude Code

petercorke and others added 2 commits November 23, 2026 17:15
Part of Issue 60. Annotates the remaining parameters and returns in
Sources.py: __exit__, the nested display and key callbacks, tensor,
disp, print and the ROS helpers. view_state is annotated dict[str, Any] so
that mypy does not infer int values from the mixed literal.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@petercorke
petercorke merged commit 719af13 into main Nov 23, 2026
34 checks passed
@petercorke
petercorke deleted the chore/types-sources branch November 23, 2026 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant