-
Notifications
You must be signed in to change notification settings - Fork 493
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 black formatter #392
Add black formatter #392
Conversation
Codecov Report
@@ Coverage Diff @@
## main #392 +/- ##
==========================================
+ Coverage 53.33% 53.33% +0.01%
==========================================
Files 210 210
Lines 18814 18814
==========================================
+ Hits 10032 10033 +1
+ Misses 8782 8781 -1
Continue to review full report at Codecov.
|
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 just had a quick scan through this. Looks good overall though.
Could you check if there's a setting to delete the trailing comma in a list of arguments? I think that's just atrocious.
action="store_true", | ||
dest="interactive", | ||
default=True, | ||
help="Run the command processing script in interactive mode (default)", |
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 didn't know ending a list of arguments with an open comma like this wasn't a syntax error. I guess it's just hideous. The more you know.
There's no setting for this in black, right?
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.
there is a good reason for this: it avoids syntax errors when (named) arguments get shuffled around -- and the person doing that forgets to add the comma and then spends I-don't-know-how-long figuring out where the syntax error is.
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.
self.assertTrue(len(retimed_plan.joint_trajectory.points) > 0, "Retimed plan is invalid") | ||
retimed_plan = self.time_parameterization(plan, "time_optimal_trajectory_generation") | ||
self.assertTrue(len(retimed_plan.joint_trajectory.points) > 0, "Retimed plan is invalid") | ||
retimed_plan = self.time_parameterization( |
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.
Kind of a lot of lines, but it's not critical.
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.
Really nice! Comments are mostly nits, maybe the config could be tweaked a little
@@ -33,7 +37,9 @@ def test(self): | |||
error_code1, plan, time = self.plan(target) | |||
error_code = MoveItErrorCodes() | |||
error_code.deserialize(error_code1) | |||
if (error_code.val == MoveItErrorCodes.SUCCESS) and self.group.execute(plan): | |||
if (error_code.val == MoveItErrorCodes.SUCCESS) and self.group.execute( |
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 seems a bit out of place
line += ' | ' | ||
print(' {}: {} {}'.format(ros, response, params['url']), file=sys.stderr) | ||
line += " | " | ||
print( |
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.
also a bit odd
@@ -119,7 +129,9 @@ def add_plane(self, name, pose, normal=(0, 0, 1), offset=0): | |||
co.plane_poses = [pose.pose] | |||
self.__submit(co, attach=False) | |||
|
|||
def attach_mesh(self, link, name, pose=None, filename='', size=(1, 1, 1), touch_links=[]): | |||
def attach_mesh( |
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.
should we change the max time length?
@@ -6,7 +6,9 @@ | |||
import rostest | |||
import os | |||
|
|||
from moveit_ros_planning_interface._moveit_move_group_interface import MoveGroupInterface | |||
from moveit_ros_planning_interface._moveit_move_group_interface import ( |
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.
not sure, this also seems like a weird rule for a single import.
black - by design - "is not configurable". I think the only option is - repo: https://github.com/psf/black
rev: 20.8b1
hooks:
- id: black
args: ["--line-length", "100"] |
@henningkayser imo we should just take black the way it is. The line length setting included. One thing that's great about black is if you install pre-commit locally you can just stop trying to edit the formatting of your python code and it'll do it for you and we'll all have a nice consistent style. I honestly wish clang-format only had --style options and not a config file. |
5b0a690
to
c10e52a
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.
LGTM even with the idiosyncrasies.
Description
This adds the
black
python formatter to CI. This formatter is likeclang-format
in that it will automatically reformat all code to match a pre-defined style. This makes reading the code much nicer. It will also enforce that all the python code is python3.I know this is a large reformatting PR. I will make the same PR against the ros1 moveit repo to add the same functionality there for this and the other pre-commit tests. That way this will not impact being able to sync between the two repos.