Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Static Type Checking With ament_mypy #1257

Open
InvincibleRMC opened this issue Mar 22, 2024 · 3 comments
Open

[Feature] Static Type Checking With ament_mypy #1257

InvincibleRMC opened this issue Mar 22, 2024 · 3 comments
Labels

Comments

@InvincibleRMC
Copy link
Contributor

Feature request

Feature description

Using ament_mypy to assure future code has proper typing annotations. First and foremost this change would need to wait on many pull requests as there are over 100 mypy errors still remaining on rolling. This change would also likely require any upstream dependencies to adopt ament_mypy to avoid [no-untyped-call] error and other similar errors being raised from a new upstream function being added and called. I bring up this question now so if this feature is desired I can start getting those upstream dependencies checked with ament_mypy earlier to avoid future waiting. For CI time considerations ament_mypy runs in about 2.4s. The benefits of this would be improved code readability, helping catch unexpected edge cases, as well remove the need for downstream dependencies who type check to suppress [no-untyped-call] and other similar errors whenever using rclpy.

Implementation considerations

For implementation currently only ament_mypy exists. The alternative would be perhaps creating an ament_pyright and using that instead for static type checking.

If this is a feature the maintainers are willing to support I will gladly help accomplish this goal. And if anyone else wants to help test with ament_mypy or add type annotations to rclpy or any other ROS2 python file that would be greatly appreciated.

@fujitatomoya
Copy link
Collaborator

@InvincibleRMC 1st of all, really appreciate all the contribution you have been and are making for rclpy type check.

we expected that this feature request would come up.
i think mostly your consideration describes pretty much everything like dependencies, benefits and concerns so on. (IMO, this should be integrated into CI/CD pipeline, so that we can sustain the type checking.)

i think that this will be better consistent and readable for sure, but that is gonna be the work and a long run. i also would like to hear from more opinion here.

let's keep this open to get more feedback!

@InvincibleRMC
Copy link
Contributor Author

InvincibleRMC commented Sep 13, 2024

@fujitatomoya The current default for ament_mypy doesn't include no-untyped-def (more info found here). I think this should be updated either in ament_mypy's default for every ROS package or at a minimum for rclpy since it gets new features and modifications quite often. Otherwise in a few years a bunch of code will accrew no type annotations and we will be back where we started.

@clalancette
Copy link
Contributor

I think this should be updated either in ament_mypy's default for every ROS package

We can discuss this, but we'll need to discuss with the whole community. Changing this default will affect all packages (though looking through the packages released into Rolling, there are only maybe a dozen that use ament_mypy).

or at a minimum for rclpy since it gets new features and modifications quite often.

This is pretty straightforward, so I would suggest starting there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants