Skip to content

Full type annotations + Doxygen docs; pyright clean - #10

Merged
mmmarinho merged 1 commit into
mainfrom
feature/full-annotations
Aug 24, 2026
Merged

Full type annotations + Doxygen docs; pyright clean#10
mmmarinho merged 1 commit into
mainfrom
feature/full-annotations

Conversation

@mmmarinho

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #9: makes the merged code fully annotated and checkable with pyright and adds Doxygen-style documentation everywhere it was missing.

  • pyright: 0 errors, 0 warnings (standard mode, 7 files analyzed — was 129 errors / 4 warnings before this work).
  • No behavioral change: all logic preserved. Verified by a logic-diff against origin/main (differences are annotations/docstrings/type-safety guards only), a full rebuild of the _core extension from the new C++ sources, and a runtime smoke test of the controller API.

Changes

Python (full annotations + Doxygen docstrings)

  • marinholab/working/needlemanipulation/_impl.py, icra2019_controller.py, needle_controller.py: complete parameter/return annotations, Args:/Returns:/Raises: docstrings, module docstrings.
  • Fixed real type bugs along the way:
    • np.array used as a type → np.ndarray
    • bare tuple return annotations (-> (A, B)) → Tuple[A, B]
    • last_x / last_Jx / last_error initialized to None without Optional
    • constraint_counter possibly-unbound (hoisted the = 0 out of the verbose branch)
    • ns_vessel typed list[DQ] but accepts Nonelist[DQ] | None
    • get_last_robot_pose() returns DQ | None from a DQ return type
  • example*.py and saul/insertion_1.py: module/function docstrings + annotations (examples are excluded from the pyright check via exclude in pyproject.toml).
  • marinholab/working/needlemanipulation/_core.pyi: fixed the self-referential ActuationType type alias.

C++ (Doxygen @file / @brief / @param / @return / @throws)

  • include/M3_SerialManipulatorSimulatorFriendly.h
  • src/M3_SerialManipulatorSimulatorFriendly.cpp (protected helpers _get_w, _joint_transformation + file header)

Type infrastructure

  • stubs/dqrobotics/: closed-set .pyi stubs (__init__, robot_modeling, utils, solvers) for the untyped compiled dqrobotics package, declaring only the symbols this project imports. This is what lets the rest of the codebase be checked without globally weakening the checks. Wired up via stubPath = "stubs" in pyproject.toml.
  • stubs/ is intentionally not packaged: [tool.setuptools.packages.find] include = ["marinholab*"] keeps it out of the wheel.

Documentation

Verification

  • pyright 1.1.411 (standard mode): 0 errors, 0 warnings, 0 informations (7 files analyzed).
  • ast.parse on every touched Python file: OK.
  • Logic diff vs origin/main (docstrings/comments/annotations stripped): identical for saul/insertion_1.py and _impl.py; for the two controllers, the only deltas are annotations and 3 defensive guards that cannot fire in normal operation (a last_x/last_Jx is None check right after it is set, a redundant w is not None alongside W is not None, and a bool() coercion of kwargs["verbose"]).
  • Rebuilt _core from the new sources and reinstalled: build OK.
  • Runtime smoke test (fresh install): all 6 package modules import; NeedleController._get_optimization_parameters returns finite H (9,9), f (9,), W (19–20, 9); get_last_robot_pose()DQ; all 11 _impl constraint functions present and callable, including with ns_vessel=None.

This PR was created by an AI agent (OpenHands) on behalf of the user.

Adds complete type annotations and Doxygen-style documentation across the
package, and makes the `marinholab` package pass pyright (standard mode)
with 0 errors / 0 warnings.

Python:
- _impl.py, icra2019_controller.py, needle_controller.py: full parameter/
  return annotations, Doxygen Args/Returns/Raises docstrings, module
  docstrings. Fixed real type bugs: np.array -> np.ndarray, bare-tuple
  return types -> Tuple[...], last_x/last_Jx/last_error -> Optional[...],
  constraint_counter possibly-unbound, ns_vessel -> list[DQ] | None.
- examples + saul/insertion_1.py: module/function docstrings + annotations.
- _core.pyi: fixed the self-referential ActuationType type alias
  (ClassVar[type["ActuationType"]]).

C++ (Doxygen @file/@brief/@param/@return/@throws):
- include/M3_SerialManipulatorSimulatorFriendly.h
- src/M3_SerialManipulatorSimulatorFriendly.cpp (protected helpers)

Tooling:
- stubs/dqrobotics/: closed-set .pyi stubs for the untyped third-party
  dqrobotics package so pyright can fully check the code without weakening
  the checks; wired via stubPath in pyproject.toml.
- AGENTS.md: documented the pyright/stubs workflow and the annotation +
  Doxygen conventions; fixed stale test/CI references.

No behavioral change: all logic preserved (verified by diff + a rebuild +
runtime smoke test of the controller API).

Co-authored-by: openhands <openhands@all-hands.dev>
@mmmarinho
mmmarinho marked this pull request as ready for review August 24, 2026 16:14

@mmmarinho mmmarinho left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@mmmarinho
mmmarinho merged commit 0ccbb72 into main Aug 24, 2026
14 checks passed
@mmmarinho
mmmarinho deleted the feature/full-annotations branch August 24, 2026 16:17
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.

2 participants