-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Nacho/fix flake8 remaining tests #3942
Nacho/fix flake8 remaining tests #3942
Conversation
- F401 'ament_index_python.packages.get_package_share_directory' imported but unused
- nav2_common/nav2_common/launch/__init__.py:15:1: F401 '.has_node_params.HasNodeParams' imported but unused - nav2_common/nav2_common/launch/__init__.py:16:1: F401 '.rewritten_yaml.RewrittenYaml' imported but unused - nav2_common/nav2_common/launch/__init__.py:17:1: F401 '.replace_string.ReplaceString' imported but unused - nav2_common/nav2_common/launch/__init__.py:18:1: F401 '.parse_multirobot_pose.ParseMultiRobotPose' imported but unused
- nav2_common/nav2_common/launch/replace_string.py:97:100: E501 line too long (108 > 99 characters)
- nav2_common/nav2_common/launch/rewritten_yaml.py:142:16: E713 test for membership should be 'not in'
- nav2_common/nav2_common/launch/has_node_params.py:21:1: F401 'sys' imported but unused
This came after using black as formatter. So respecting the previous code
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3942 +/- ##
==========================================
+ Coverage 90.33% 90.37% +0.03%
==========================================
Files 415 415
Lines 18443 18443
==========================================
+ Hits 16660 16667 +7
+ Misses 1783 1776 -7 ☔ View full report in Codecov by Sentry. |
By the way, just as an additional piece of information: the first test I could catch failing is in #3877 which dates from 16 Oct, a few days after osrf/docker_images#641 got merged (the 6th of October). Which makes sense to me |
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.
I very looked in detail in the first couple of files and briefly scanned through a few randomly sampled other ones here. Did you only lint for all of them or anywhere did you reorder / change anything other than formatting? If just formatting, I can merge without a deeper look
This block you can ignore for sure: This as well, is just the linter saying "Add a If you skip those, then just clicking on the first few commits will show the "changes" which are basically formatting, removing unused imports, etc. @SteveMacenski please mind that this PR also includes #3941 (first commit). So if we don't want to add black here, then please DO NOT MERGE THIS PR |
I would like to have a PR that is just doing what is needed by OSRF's profile of flake8 to make CI turn over. Any conversation / changes about Black, if those changes are not overlapping with flake8, should be isolated to another PR / discussion. |
I agree :) all good. But it would take me a bit more time, I need to find again a spot where I can spend some time fixing by hand the thousand style errors like the following:
, since I could not find any formatter that just does what ament_flake8 is asking for, maybe some folk out there have a better solution (?) NOTE As a matter of fact, this PR in its current state, is not violating ANY ROS python style, that's why all the I leave it to you if you want to merge it or not. |
CI told me it was 133, but I get the point ;-)
It passes so yes. So you're saying that black has the same formatting as flake8's ROS 2 configuration? If so, we can use black in our CI potentially to auto-reformat (or at least run the option so that it can be handled). I thought you implied though that this was not the case when you closed the black PR. |
hehe, I like to be a bit dramatic 🤪
No, I'm not saying this. I'm saying that black + the changes in this PR have a ROS 2 happy configuration. If you checkout my branch and do What I wanted to say, is that there might be a few lines where black is changing the style, even when there was no violation to flake8 linters. Nevertheless, there is still no rule-breaking after all. I can't tell which line particularly falls into this category, which might NOT STRICTLY be REQUIRED by ROS2 styling, but also NOT VIOLAINTG ROS 2 styling. I closed #3941 because I believed that there was no interest in moving forward and let this open just for discussion (assuming black has no chance at all to interact here, then both PRs are useless) If you ask me, I would merge first #3941, just to keep a git story clean (in case one needs to do criminology in the future), and then this one. After the CI is happy, the next time there is a linter problem, it would be only in the files developers are changing in Python, so fixing this would be straightforward. Again, I leave this to you ;) PS: In case I was not clear (which seems to be the case). As long as ROS 2 still commits to We pick single quotes over double quotes as long as no escaping is necessary. (source) , There is NO ROOM for black. It is a shame, to leave the most popular Python formatter out, just because, (we) prefer single quotes over double. If we avoid this rule, then black can help to automatically format all the python3 scripts, and comply with flake8 guides (yes some rules can still be violated, but could also be fixed with |
@nachovizzo let me follow up with some folks about this and get back to you. It didn't always used to be this way, so the fact that it can auto reformat might push some support |
Thanks for your time and energy to fixing this! This is a good first contribution to Nav2 and really saves me some time to focus on other elements. Your time is very appreciated :-) |
@SteveMacenski thanks to you for the time and patience on this PR! I'm more than happy to help. And I'd be eager to support any effort for pushing for
|
Wait, what? This wasn't supposed to introduce black or any of its formatting. Why would CI be failing? |
Sorry Steve 🤦 It's me being unclear again.
|
I still don't understand why anything would be failing with |
It's not part of the default linter set. But since in |
* Use ament_black as linter * Fix standard flake8 errors for `tools - F401 'ament_index_python.packages.get_package_share_directory' imported but unused * Fix flake8 tests for nav2_common - nav2_common/nav2_common/launch/__init__.py:15:1: F401 '.has_node_params.HasNodeParams' imported but unused - nav2_common/nav2_common/launch/__init__.py:16:1: F401 '.rewritten_yaml.RewrittenYaml' imported but unused - nav2_common/nav2_common/launch/__init__.py:17:1: F401 '.replace_string.ReplaceString' imported but unused - nav2_common/nav2_common/launch/__init__.py:18:1: F401 '.parse_multirobot_pose.ParseMultiRobotPose' imported but unused * Fix flake8 nav2_common linterr - nav2_common/nav2_common/launch/replace_string.py:97:100: E501 line too long (108 > 99 characters) * Fix flake8 nav2_common linter - nav2_common/nav2_common/launch/rewritten_yaml.py:142:16: E713 test for membership should be 'not in' * Fix flake8 nav_common linter - nav2_common/nav2_common/launch/has_node_params.py:21:1: F401 'sys' imported but unused * Fix nav2_system_tests flake8 linter This came after using black as formatter. So respecting the previous code * Fix flake8-builtins linter * Fix flake8-comprehensions linter * Fix flake8-import-order linter for nav2_sumple_commander * Fix flake8-import-order linter for nav2_system_tests * Fix flake8-import-order linter for nav2_common * Fix flake8-import-order linter for tools * Fix flake8-docstring linter * Fix flake8-quotes linter for nav2_common * Fix flake8-quotes linter for nav2_system_tests * Fix flake8-quotes linter for nav2_collision_monitor * Fix flake8-quotes linter for nav2_map_server * Fix flake8-quotes linter for nav2_bringup * Fix flake8-quotes linter for tools * Fix flake8-quotes linter for nav2_simple_commander * Fix flake8-quotes linter for nav2_lifecycle * Fix flake8-quotes linter for nav2_costmap2d * Fix flake8-quotes linter for nav2_smac_planner * Fix linter... again Signed-off-by: gg <josho.wallace@gmail.com>
* Use ament_black as linter * Fix standard flake8 errors for `tools - F401 'ament_index_python.packages.get_package_share_directory' imported but unused * Fix flake8 tests for nav2_common - nav2_common/nav2_common/launch/__init__.py:15:1: F401 '.has_node_params.HasNodeParams' imported but unused - nav2_common/nav2_common/launch/__init__.py:16:1: F401 '.rewritten_yaml.RewrittenYaml' imported but unused - nav2_common/nav2_common/launch/__init__.py:17:1: F401 '.replace_string.ReplaceString' imported but unused - nav2_common/nav2_common/launch/__init__.py:18:1: F401 '.parse_multirobot_pose.ParseMultiRobotPose' imported but unused * Fix flake8 nav2_common linterr - nav2_common/nav2_common/launch/replace_string.py:97:100: E501 line too long (108 > 99 characters) * Fix flake8 nav2_common linter - nav2_common/nav2_common/launch/rewritten_yaml.py:142:16: E713 test for membership should be 'not in' * Fix flake8 nav_common linter - nav2_common/nav2_common/launch/has_node_params.py:21:1: F401 'sys' imported but unused * Fix nav2_system_tests flake8 linter This came after using black as formatter. So respecting the previous code * Fix flake8-builtins linter * Fix flake8-comprehensions linter * Fix flake8-import-order linter for nav2_sumple_commander * Fix flake8-import-order linter for nav2_system_tests * Fix flake8-import-order linter for nav2_common * Fix flake8-import-order linter for tools * Fix flake8-docstring linter * Fix flake8-quotes linter for nav2_common * Fix flake8-quotes linter for nav2_system_tests * Fix flake8-quotes linter for nav2_collision_monitor * Fix flake8-quotes linter for nav2_map_server * Fix flake8-quotes linter for nav2_bringup * Fix flake8-quotes linter for tools * Fix flake8-quotes linter for nav2_simple_commander * Fix flake8-quotes linter for nav2_lifecycle * Fix flake8-quotes linter for nav2_costmap2d * Fix flake8-quotes linter for nav2_smac_planner * Fix linter... again Signed-off-by: enricosutera <enricosutera@outlook.com>
* Use ament_black as linter * Fix standard flake8 errors for `tools - F401 'ament_index_python.packages.get_package_share_directory' imported but unused * Fix flake8 tests for nav2_common - nav2_common/nav2_common/launch/__init__.py:15:1: F401 '.has_node_params.HasNodeParams' imported but unused - nav2_common/nav2_common/launch/__init__.py:16:1: F401 '.rewritten_yaml.RewrittenYaml' imported but unused - nav2_common/nav2_common/launch/__init__.py:17:1: F401 '.replace_string.ReplaceString' imported but unused - nav2_common/nav2_common/launch/__init__.py:18:1: F401 '.parse_multirobot_pose.ParseMultiRobotPose' imported but unused * Fix flake8 nav2_common linterr - nav2_common/nav2_common/launch/replace_string.py:97:100: E501 line too long (108 > 99 characters) * Fix flake8 nav2_common linter - nav2_common/nav2_common/launch/rewritten_yaml.py:142:16: E713 test for membership should be 'not in' * Fix flake8 nav_common linter - nav2_common/nav2_common/launch/has_node_params.py:21:1: F401 'sys' imported but unused * Fix nav2_system_tests flake8 linter This came after using black as formatter. So respecting the previous code * Fix flake8-builtins linter * Fix flake8-comprehensions linter * Fix flake8-import-order linter for nav2_sumple_commander * Fix flake8-import-order linter for nav2_system_tests * Fix flake8-import-order linter for nav2_common * Fix flake8-import-order linter for tools * Fix flake8-docstring linter * Fix flake8-quotes linter for nav2_common * Fix flake8-quotes linter for nav2_system_tests * Fix flake8-quotes linter for nav2_collision_monitor * Fix flake8-quotes linter for nav2_map_server * Fix flake8-quotes linter for nav2_bringup * Fix flake8-quotes linter for tools * Fix flake8-quotes linter for nav2_simple_commander * Fix flake8-quotes linter for nav2_lifecycle * Fix flake8-quotes linter for nav2_costmap2d * Fix flake8-quotes linter for nav2_smac_planner * Fix linter... again
* Use ament_black as linter * Fix standard flake8 errors for `tools - F401 'ament_index_python.packages.get_package_share_directory' imported but unused * Fix flake8 tests for nav2_common - nav2_common/nav2_common/launch/__init__.py:15:1: F401 '.has_node_params.HasNodeParams' imported but unused - nav2_common/nav2_common/launch/__init__.py:16:1: F401 '.rewritten_yaml.RewrittenYaml' imported but unused - nav2_common/nav2_common/launch/__init__.py:17:1: F401 '.replace_string.ReplaceString' imported but unused - nav2_common/nav2_common/launch/__init__.py:18:1: F401 '.parse_multirobot_pose.ParseMultiRobotPose' imported but unused * Fix flake8 nav2_common linterr - nav2_common/nav2_common/launch/replace_string.py:97:100: E501 line too long (108 > 99 characters) * Fix flake8 nav2_common linter - nav2_common/nav2_common/launch/rewritten_yaml.py:142:16: E713 test for membership should be 'not in' * Fix flake8 nav_common linter - nav2_common/nav2_common/launch/has_node_params.py:21:1: F401 'sys' imported but unused * Fix nav2_system_tests flake8 linter This came after using black as formatter. So respecting the previous code * Fix flake8-builtins linter * Fix flake8-comprehensions linter * Fix flake8-import-order linter for nav2_sumple_commander * Fix flake8-import-order linter for nav2_system_tests * Fix flake8-import-order linter for nav2_common * Fix flake8-import-order linter for tools * Fix flake8-docstring linter * Fix flake8-quotes linter for nav2_common * Fix flake8-quotes linter for nav2_system_tests * Fix flake8-quotes linter for nav2_collision_monitor * Fix flake8-quotes linter for nav2_map_server * Fix flake8-quotes linter for nav2_bringup * Fix flake8-quotes linter for tools * Fix flake8-quotes linter for nav2_simple_commander * Fix flake8-quotes linter for nav2_lifecycle * Fix flake8-quotes linter for nav2_costmap2d * Fix flake8-quotes linter for nav2_smac_planner * Fix linter... again
* Use ament_black as linter * Fix standard flake8 errors for `tools - F401 'ament_index_python.packages.get_package_share_directory' imported but unused * Fix flake8 tests for nav2_common - nav2_common/nav2_common/launch/__init__.py:15:1: F401 '.has_node_params.HasNodeParams' imported but unused - nav2_common/nav2_common/launch/__init__.py:16:1: F401 '.rewritten_yaml.RewrittenYaml' imported but unused - nav2_common/nav2_common/launch/__init__.py:17:1: F401 '.replace_string.ReplaceString' imported but unused - nav2_common/nav2_common/launch/__init__.py:18:1: F401 '.parse_multirobot_pose.ParseMultiRobotPose' imported but unused * Fix flake8 nav2_common linterr - nav2_common/nav2_common/launch/replace_string.py:97:100: E501 line too long (108 > 99 characters) * Fix flake8 nav2_common linter - nav2_common/nav2_common/launch/rewritten_yaml.py:142:16: E713 test for membership should be 'not in' * Fix flake8 nav_common linter - nav2_common/nav2_common/launch/has_node_params.py:21:1: F401 'sys' imported but unused * Fix nav2_system_tests flake8 linter This came after using black as formatter. So respecting the previous code * Fix flake8-builtins linter * Fix flake8-comprehensions linter * Fix flake8-import-order linter for nav2_sumple_commander * Fix flake8-import-order linter for nav2_system_tests * Fix flake8-import-order linter for nav2_common * Fix flake8-import-order linter for tools * Fix flake8-docstring linter * Fix flake8-quotes linter for nav2_common * Fix flake8-quotes linter for nav2_system_tests * Fix flake8-quotes linter for nav2_collision_monitor * Fix flake8-quotes linter for nav2_map_server * Fix flake8-quotes linter for nav2_bringup * Fix flake8-quotes linter for tools * Fix flake8-quotes linter for nav2_simple_commander * Fix flake8-quotes linter for nav2_lifecycle * Fix flake8-quotes linter for nav2_costmap2d * Fix flake8-quotes linter for nav2_smac_planner * Fix linter... again
Fix flake8 linter
This PR is a follow-up #3893, and assumes #3941 was merged (to reduce the clutter in the diff)
Real diff (after
black
)Assuming #3941 was NOT merged, the diff between this PR and that branch can be seen here: /~https://github.com/nachovizzo/navigation2/pull/1/files
Proposal about atomic PRs
If you guys consider it necessary, after the CI passes and we know that this bloody linter is happy I can split this PR into multiple ones addressing 1-flake8-linter-plugin-check-per-PR. It's up to you
Description of contribution in a few bullet points
About the new additional linters
The new linters were introduced (as I guessed in #3893) in this PR: osrf/docker_images#641. The question is if they make sense or not. I couldn't find a good justification for why we now have
python3-flake8-quotes
which to me, is the most useless linter I've ever used in my life. If it wasn't for this, just havingblack
on the CI will guarantee good code format forever.It took me a few hours of scripting and manual editing to make that thing happy, and I still see no benefit.
If the decision is to keep it for nav2 is out of the scope of this PR. I just wanted to provide the solution for the CI so developers can trust the build again, but I'd strongly advise against flake8-quotes
For Maintainers: