ros2 / rclpy

rclpy (ROS Client Library for Python)
Apache License 2.0
268 stars 221 forks source link

Using Generics for messages #1239

Closed InvincibleRMC closed 2 months ago

InvincibleRMC commented 4 months ago

First Draft.

InvincibleRMC commented 3 months ago

Noticed bug in protocol definitions working on a fix.

InvincibleRMC commented 3 months ago

Until this gets merged https://github.com/ros2/rosidl_python/pull/205 the type of all messages/services/actions have to be inferred as Any due to PEP 561. Because messages are all inferred to be Any It won't currently alert user about putting in the wrong message type. But I tested it by adding a py.typed file into std_msgs it correctly warns the user about different messages.

InvincibleRMC commented 3 months ago

Limited scope to Generics for publishers and subscribers only because couldn't get generics of services and clients working the way I wanted.

sloretz commented 2 months ago

Mini CI just to see what happens (repos file build: --packages-up-to rclpy test: --packages-select rclpy)

Linux: Build Status

sloretz commented 2 months ago

CI (repos file build: --packages-up-to rclpy test: --packages-select rclpy)

sloretz commented 2 months ago

Thank you for the PR!

InvincibleRMC commented 2 months ago

Thank you for the PR! @sloretz Would it be possible to backport this and future typing changes into Jazzy as well?

sloretz commented 2 months ago

Seems safe to back port to me

@mergifyio backport jazzy

clalancette commented 1 month ago

Seems safe to back port to me

While I'm OK with backporting this, I'm going to suggest we hold off on doing it until after Jazzy is released. That way we can be certain that only critical bugfixes are going in at this time.

InvincibleRMC commented 1 month ago

Seems safe to back port to me

While I'm OK with backporting this, I'm going to suggest we hold off on doing it until after Jazzy is released. That way we can be certain that only critical bugfixes are going in at this time.

Seems very reasonable.