Skip to content

Replace hand-written sync wrappers with a blocking_wrapper; german word 'programm' - #47

Open
TeTi89 wants to merge 3 commits into
CommonplaceRobotics:masterfrom
TeTi89:pr_blocking_wrapper_fn
Open

TeTi89 wants to merge 3 commits into
CommonplaceRobotics:masterfrom
TeTi89:pr_blocking_wrapper_fn

Conversation

@TeTi89

@TeTi89 TeTi89 commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Changes

Adds a small blocking_wrapper decorator and uses it to generate the blocking (sync) version of the *_async methods in CRIController, replacing the hand-written return _run_sync(self.xxx_async(...)) wrappers.

stop_move = blocking_wrapper(stop_move_async)
set_dout = blocking_wrapper(set_dout_async)
...

Function names with the german spelling 'programm' are changed into 'program'.

Details

  • The decorator is typed with ParamSpec, so IDEs still show the real parameters and return type of each sync method (e.g. set_dout(id: int, value: bool)).
  • The docstring is generated: Blocking wrapper around :meth:CRIController.xxx_async``.

Notes for review

  • With the old hand-written wrappers, PyCharm reported wrong arguments (e.g. set_dout("a")) as errors. With the generated methods it may not, so such mistakes only show up at runtime or in an external type check.
  • If better IDE support is more important than removing the boilerplate, the explicit wrappers can be kept for the most commonly used methods. This wrapper function replaced about 200 lines of code.

Testing

  • Existing examples start_program.py and relative_move pass

@cpr-mab cpr-mab added the enhancement New feature or request label Oct 9, 2026
@cpr-mab
cpr-mab requested a review from cpr-bar October 9, 2026 07:53
@cpr-mab

cpr-mab commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

This seems good to me but since I'm unfamiliar with ParamSpec I can't tell if there are any undesirable effects. @cpr-bar can you evaluate this?

@cpr-mab

cpr-mab commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

I got issues running the examples but that should be caused by your branch being behind our repo rather than the change (that issue was fixed recently)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Development

Successfully merging this pull request may close these issues.

3 participants