-
Notifications
You must be signed in to change notification settings - Fork 108
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
add mypy support for linters/testing #154
Conversation
937f75a
to
c27e7fe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great @Arnatious, thank you! A couple of small changes suggested, but overall this seems to work well at least for the python projects on which I've been testing it (I haven't tested the cmake bits). It's also missing tests.
Signed-off-by: Ted Kern <ted.kern@canonical.com>
c27e7fe
to
1ef5070
Compare
Co-Authored-By: Kyle Fazzari <github@status.e4ward.com> Signed-off-by: Ted Kern <ted.kern@canonical.com>
Signed-off-by: Ted Kern <ted.kern@canonical.com>
051cddf
to
ad03a5b
Compare
Signed-off-by: Ted Kern <ted.kern@canonical.com>
Signed-off-by: Ted Kern <ted.kern@canonical.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imo this shouldn't be merged with the pending "admittedly-not-ideal-but-hopefully-works-in-most-common-cases" approach.
Wait, didn't we agree that there was no better way to do that? What exactly would you like to see? |
Yes, we don't see a better way to do that atm. Imo that doesn't mean that the approach is good enough to be merged into If other reviewers have a different opinion and think this should be merged anyway please feel free to comment here. |
To be clear, if someone puts the build and install spaces somewhere other than the default, the side effect is that mypy won't find all ros2 imports, which can be ignored by the project. It doesn't break anything, just makes mypy not as useful. The only alternatives (such as not supporting There are multiple ROS packages today using the static typing, but without the ability to check them in CI they get out of date to the point of being harmful (for example, rosidl_python will fail mypy checks). Getting this into master will increase quality of the overall ecosystem, not decrease it. |
The developer expects that the linting is happening and for whatever reason it doesn't perform the checks as intended. So it does break user expectation. If the linter doesn't find the right paths it might not generate a warning where one would be expected. I don't think that case should be silently ignored. At the very least the linter should respond with a skipped check (probably in addition to the ones it was able to perform) in the generated report. Otherwise the user has no indication whatsoever that the linting was not completed as intended. |
mypy will raise an error indeed, and the project has the option to ignore it in a mypy.ini file. This is how mypy works, @dirk-thomas. Would you prefer that this linter only finds ros2 imports that are contained within |
Signed-off-by: Ted Kern <ted.kern@canonical.com>
8195331
to
f088f5f
Compare
Signed-off-by: Ted Kern <tkern@arnatious.com> Co-Authored-By: Kyle Fazzari <github@status.e4ward.com>
bd064bc
to
b9aba81
Compare
Signed-off-by: Ted Kern <ted.kern@canonical.com>
Signed-off-by: Ted Kern <ted.kern@canonical.com>
Signed-off-by: Ted Kern <ted.kern@canonical.com>
Signed-off-by: Ted Kern <ted.kern@canonical.com>
This comment still applies. |
Signed-off-by: Ted Kern <ted.kern@canonical.com>
Signed-off-by: Ted Kern <ted.kern@canonical.com>
27367a1
to
8df8bc7
Compare
Signed-off-by: Ted Kern <ted.kern@canonical.com>
5434b0a
to
3a85e9f
Compare
@dirk-thomas I'm getting different results? I'm running a source checkout of dashing atm
|
@dirk-thomas Those jenkins failures are all related to pytest-mock |
I added the With that the CI status on Linux looks good: Is the plan to get this merged as is and iterate on enhancements like include Python modules outside of the tested package in a separate PR? |
@dirk-thomas that's the plan, a longer discussion will need to be had about how to traverse the imports and how that fits with mypy's expectation of "all local code and imported packages should pass or else you'll need to micromanage." |
Signed-off-by: Ted Kern <ted.kern@canonical.com>
@dirk-thomas should I squash these commits prior to any merge? |
No need for that - I will use the "Squash and merge" option of the GitHub UI. Thank you for contributing |
Is there a recommended way to add this to a pure Python package (like |
@wjwwood aye, that's a good idea |
@wjwwood while waiting for better docs you can also refer to this SROS 2 PR. It's the simplest use-case, no args, config file or anything, but docs will outline how to do that better. |
I think there's missing install instructions for the default configuration file, |
See ros2/ci#333 for a follow-up. |
Add support for mypy based static type checking, in the vein of ament_flake8 and ament_pyflakes.
Signed-off-by: Ted Kern ted.kern@canonical.com