Skip to content

lifecycle_py: Add ament_mypy support#778

Open
mohit-swaran wants to merge 12 commits intoros2:rollingfrom
mohit-swaran:feature/add-mypy-lifecycle-py#768
Open

lifecycle_py: Add ament_mypy support#778
mohit-swaran wants to merge 12 commits intoros2:rollingfrom
mohit-swaran:feature/add-mypy-lifecycle-py#768

Conversation

@mohit-swaran
Copy link
Contributor

Description

This PR adds ament_mypy support and resolves type-checking errors in the lifecycle_py package

  • Add test/test_mypy.py
  • Used Dict[str, Any] in test_lifecycle.py for the generate_test_description() return type
  • Resolved all mypy --strict errors found locally

Fixes (#768)

Is this user-facing behavior change?

Did you use Generative AI?

No

Additional Information

mohit-swaran and others added 9 commits March 3, 2026 19:12
Signed-off-by: mohit-swaran <mohit.swaran@gmail.com>
Signed-off-by: mohit-swaran <mohit.swaran@gmail.com>
Signed-off-by: mohit-swaran <mohit.swaran@gmail.com>
…and client ros2#766

Signed-off-by: mohit-swaran <mohit.swaran@gmail.com>
Signed-off-by: mohit-swaran <mohit.swaran@gmail.com>
Signed-off-by: mohit-swaran <mohit.swaran@gmail.com>
Signed-off-by: mohit-swaran <mohit.swaran@gmail.com>
Copy link
Contributor

@InvincibleRMC InvincibleRMC left a comment

Choose a reason for hiding this comment

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

Looks good. Just small nits about using the modern typing syntax.

Signed-off-by: mohit-swaran <mohit.swaran@gmail.com>
@mohit-swaran
Copy link
Contributor Author

Understood! I will keep this in mind. Thank you for the catch!!

@InvincibleRMC
Copy link
Contributor

Pulls: #778
Gist: https://gist.githubusercontent.com/InvincibleRMC/4077f59c7ce03b8028f616c2e41e910b/raw/6a2215cef572715b38436cdd1b8bdb4d088937ab/ros2.repos
BUILD args: --continue-on-error --packages-above-and-dependencies lifecycle_py
TEST args: --packages-above lifecycle_py
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/18439

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

@mohit-swaran
Copy link
Contributor Author

lifecycle_py/talker.py: note: In member "__init__" of class "LifecycleTalker":
lifecycle_py/talker.py:38:50: error: "Unpack" is not supported by mypy yet

Looks like it is not supported with mypy 0.20.3 version? . What should I do about this ?

@InvincibleRMC
Copy link
Contributor

You can probably add a # type: ignore since only rhel is affect since it is so.

Signed-off-by: mohit-swaran <mohit.swaran@gmail.com>
Signed-off-by: mohit-swaran <mohit.swaran@gmail.com>
@InvincibleRMC
Copy link
Contributor

Pulls: #778
Gist: https://gist.githubusercontent.com/InvincibleRMC/5683309c62e93e177be70845c54b4c48/raw/6a2215cef572715b38436cdd1b8bdb4d088937ab/ros2.repos
BUILD args: --continue-on-error --packages-above-and-dependencies lifecycle_py
TEST args: --packages-above lifecycle_py
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/18452

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

@mohit-swaran
Copy link
Contributor Author

Same error

2 errors
lifecycle_py/talker.py: note: In member "__init__" of class "LifecycleTalker":
lifecycle_py/talker.py:38:50: error: "Unpack" is not supported by mypy yet
Found 1 error in 1 file (checked 10 source files)

Should I change it to Any ?

@InvincibleRMC
Copy link
Contributor

Your type ignore I believe has to be line with the code not above it. And I would make a generic one. not speficically about unused-ignore

@mohit-swaran
Copy link
Contributor Author

Your type ignore I believe has to be line with the code not above it. And I would make a generic one. not speficically about unused-ignore

So is it okay to throw error unused-ignore in current version of mypy

talker.py:39: error: Unused "type: ignore" comment  [unused-ignore]
Found 1 error in 1 file (checked 2 source files)

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