Skip to content

Add ament_mypy support and strict typing to lifecycle_py#779

Closed
andrearichichi wants to merge 6 commits intoros2:rollingfrom
andrearichichi:fix-lifecycle-mypy
Closed

Add ament_mypy support and strict typing to lifecycle_py#779
andrearichichi wants to merge 6 commits intoros2:rollingfrom
andrearichichi:fix-lifecycle-mypy

Conversation

@andrearichichi
Copy link

@andrearichichi andrearichichi commented Mar 17, 2026

Description

This PR adds ament_mypy support to lifecycle_py and updates the package to pass strict mypy checks.

Changes include:

  • adding ament_mypy as a test dependency
  • adding a test_mypy.py test
  • adding type annotations in talker.py
  • annotating test and launch functions
  • limiting type: ignore usage to required cases

Validation:

python3 -m mypy --strict . --ignore-missing-imports --allow-untyped-calls
ament_mypy

Is this user-facing behavior change?

No.

Did you use Generative AI?

Yes, partially, with manual review.

Closes #768

Signed-off-by: Andrea Richichi <andrea.richichi@studenti.unitn.it>
… notice

Signed-off-by: Andrea Richichi <andrea.richichi@studenti.unitn.it>
Signed-off-by: Andrea Richichi <andrea.richichi@studenti.unitn.it>
Signed-off-by: Andrea Richichi <andrea.richichi@studenti.unitn.it>
Signed-off-by: Andrea Richichi <andrea.richichi@studenti.unitn.it>
@andrearichichi andrearichichi force-pushed the fix-lifecycle-mypy branch 12 times, most recently from f1bd54a to d7d7e3b Compare March 17, 2026 22:51
Signed-off-by: Andrea Richichi <andrea.richichi@studenti.unitn.it>
@@ -0,0 +1,65 @@
# Copyright 2019 Canonical, Ltd.
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is fragile? if the package directory structure ever changes, or if a subdirectory is renamed, this test will silently skip files or fail for structural reasons rather than type errors. this should be replaced with the standard minimal form. IMO, if main(argv=[]) doesn't discover the right files in the ament test harness, that's an ament_mypy bug, not something to work around in every consumer package.

@InvincibleRMC
Copy link
Contributor

Is a dupe of #778. Feel free to work on an unclaimed typing issue here. You could also start adding typing hints into the basic ros2/examples repo.

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.

Add ament_mypy to lifecycle_py

3 participants