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

Update pre-commit hooks to latest versions #1172

Merged
merged 3 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,36 @@ ci:

repos:
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.33.0
rev: v1.35.1
hooks:
- id: yamllint
- repo: https://github.com/psf/black
rev: 24.1.1
rev: 24.3.0
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v17.0.6
rev: v18.1.2
hooks:
- id: clang-format
- repo: https://github.com/PyCQA/autoflake
rev: v2.2.1
rev: v2.3.1
hooks:
- id: autoflake
args: [--remove-all-unused-imports, --ignore-init-module-imports]
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.9.0.6
rev: v0.10.0.1
hooks:
- id: shellcheck
exclude: ^docker|deprecated|NaviGator/simulation/VRX
args: [--severity=warning, --exclude=SC1090]
- repo: https://github.com/scop/pre-commit-shfmt
rev: v3.7.0-4
rev: v3.8.0-1
hooks:
- id: shfmt
exclude: ^docker|deprecated|NaviGator/simulation/VRX
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: 'v0.2.0'
rev: 'v0.3.4'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
12 changes: 3 additions & 9 deletions NaviGator/gnc/navigator_path_planner/nodes/path_planner.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,9 +454,7 @@ def move_cb(self, msg: MoveAction) -> Optional[bool]:
print(f"\nMove {self.move_count}\n----")
print(f"Behavior: {self.enroute_behavior.__name__[10:]}")
print(
"Reached goal region: {}".format(
self.enroute_behavior.planner.plan_reached_goal,
),
f"Reached goal region: {self.enroute_behavior.planner.plan_reached_goal}",
)
print(f"Goal bias: {np.round(self.goal_bias, 2)}")
print(f"Tree size: {self.tree.size}")
Expand Down Expand Up @@ -1027,9 +1025,7 @@ def reevaluate_plan(self) -> None:
self.failure_reason = "collided"
else:
print(
"\nFound collision on current path!\nTime till collision: {}".format(
time_till_collision,
),
f"\nFound collision on current path!\nTime till collision: {time_till_collision}",
)
self.time_till_issue = time_till_collision
for behavior in self.behaviors_list:
Expand Down Expand Up @@ -1495,9 +1491,7 @@ def ogrid_cb(self, msg: OccupancyGrid) -> None:
elapsed = abs(self.rostime() - start)
if elapsed > 1:
print(
"\n(WARNING: ogrid callback is taking {} seconds)\n".format(
np.round(elapsed, 2),
),
f"\n(WARNING: ogrid callback is taking {np.round(elapsed, 2)} seconds)\n",
)

def odom_cb(self, msg: Odometry) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,7 @@ def from_urdf(

if t_ratio < 0:
raise Exception(
"Thruster mapper does not allow mechanical reduction of {} for {}.".format(
t_ratio,
transmission.name,
),
f"Thruster mapper does not allow mechanical reduction of {t_ratio} for {transmission.name}.",
)

ratio[i] = t_ratio
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ def __init__(self):
def _client_cb(self, terminal_state, result):
if terminal_state != 3:
rospy.logwarn(
"Station hold goal failed (Status={}, Result={})".format(
TerminalState.to_string(terminal_state),
result.result,
),
f"Station hold goal failed (Status={TerminalState.to_string(terminal_state)}, Result={result.result})",
)
return
rospy.loginfo("Station holding!")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,7 @@ async def get_target_bays(self):
self.bay_1 = (bay_1_shape, bay_1_color)
self.bay_2 = (bay_2_shape, bay_2_color)
print_good(
"Docking in Bay (Shape={}, Color={}) then (Shape={}, Color={})".format(
bay_1_shape,
bay_1_color,
bay_2_shape,
bay_2_color,
),
f"Docking in Bay (Shape={bay_1_shape}, Color={bay_1_color}) then (Shape={bay_2_shape}, Color={bay_2_color})",
)

async def get_waypoint(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,7 @@ def is_done(objects, positions):
filter_and_sort,
)
self.send_feedback(
"Going through gate of objects {} and {}".format(
left_obj.labeled_classification,
right_obj.labeled_classification,
),
f"Going through gate of objects {left_obj.labeled_classification} and {right_obj.labeled_classification}",
)
gate = self.get_gate(left, right, p)
await self.go_thru_gate(gate)
Expand Down Expand Up @@ -393,10 +390,7 @@ def is_done(objects, positions):
self.objects_passed.add(red.id)
gate = self.get_gate(white_position, red_position, robot_position)
self.send_feedback(
"Going through start gate formed by {} and {}".format(
white.labeled_classification,
red.labeled_classification,
),
f"Going through start gate formed by {white.labeled_classification} and {red.labeled_classification}",
)
await self.go_thru_gate(gate, AFTER=-2)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -800,12 +800,7 @@ async def get(self, raise_exception: bool = True):
value = await self.nh.get_param(self.param)
if not self._valid(value):
raise Exception(
"Value {} is invalid for param {}\nValid values: {}\nDescription: {}".format(
value,
self.param,
self.options,
self.description,
),
f"Value {value} is invalid for param {self.param}\nValid values: {self.options}\nDescription: {self.description}",
)
else:
return value
Expand All @@ -816,12 +811,7 @@ async def exists(self) -> bool:
async def set(self, value):
if not self._valid(value):
raise Exception(
"Value {} is invalid for param {}\nValid values: {}\nDescription: {}".format(
value,
self.param,
self.options,
self.description,
),
f"Value {value} is invalid for param {self.param}\nValid values: {self.options}\nDescription: {self.description}",
)
await self.nh.set_param(self.param, value)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,7 @@ def is_done(objects, positions):
filter_and_sort,
)
self.send_feedback(
"Going through gate of objects {} and {}".format(
left_obj.labeled_classification,
right_obj.labeled_classification,
),
f"Going through gate of objects {left_obj.labeled_classification} and {right_obj.labeled_classification}",
)
gate = self.get_gate(left, right, p)
await self.go_thru_gate(gate)
Expand Down Expand Up @@ -336,10 +333,7 @@ def is_done(objects, positions):
self.objects_passed.add(red.id)
gate = self.get_gate(white_position, red_position, robot_position)
self.send_feedback(
"Going through start gate formed by {} and {}".format(
white.labeled_classification,
red.labeled_classification,
),
f"Going through start gate formed by {white.labeled_classification} and {red.labeled_classification}",
)
await self.go_thru_gate(gate, AFTER=-2)

Expand Down
5 changes: 1 addition & 4 deletions NaviGator/perception/navigator_vision/nodes/classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,7 @@ def process_boxes(self, msg):
# self.CLASSES[a.results[0].id],
# )
# )
cmd = "{}={}".format(
self.last_objects.objects[closest_to_box].id,
self.CLASSES[a.results[0].id],
)
cmd = f"{self.last_objects.objects[closest_to_box].id}={self.CLASSES[a.results[0].id]}"
self.database_client(ObjectDBQueryRequest(cmd=cmd))

if not self.is_perception_task:
Expand Down
11 changes: 2 additions & 9 deletions NaviGator/perception/navigator_vision/nodes/database_color.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,10 +377,7 @@ def _get_closest_color(self, hue_angle):
likely_color = color

fprint(
"Likely color: {} with an hue error of {} rads.".format(
likely_color,
np.round(error, 3),
),
f"Likely color: {likely_color} with an hue error of {np.round(error, 3)} rads.",
)
return [likely_color, error]

Expand Down Expand Up @@ -468,11 +465,7 @@ def do_observe(self, *args):
return

fprint(
"No valid image found for t={} ({}) dt: {}".format(
time_of_marker.to_sec(),
t.to_sec(),
(rospy.Time.now() - t).to_sec(),
),
f"No valid image found for t={time_of_marker.to_sec()} ({t.to_sec()}) dt: {(rospy.Time.now() - t).to_sec()}",
msg_color="red",
)
return
Expand Down
10 changes: 2 additions & 8 deletions NaviGator/perception/navigator_vision/nodes/vrx_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,9 @@ def process_boxes(self, msg):

classified.add(self.last_objects.objects[closest_to_box].id)
print(
"Object {} classified as {}".format(
self.last_objects.objects[closest_to_box].id,
self.CLASSES[a.results[0].id],
),
)
cmd = "{}={}".format(
self.last_objects.objects[closest_to_box].id,
self.CLASSES[a.results[0].id],
f"Object {self.last_objects.objects[closest_to_box].id} classified as {self.CLASSES[a.results[0].id]}",
)
cmd = f"{self.last_objects.objects[closest_to_box].id}={self.CLASSES[a.results[0].id]}"
self.database_client(ObjectDBQueryRequest(cmd=cmd))

if not self.is_perception_task:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ def myassert(self, my_res):
if len(my_res) != len(self.results):
passed = False
fprint(
"EXPECTED RESULT {} DOES NOT MATCH ACTUAL RESULT {}. TEST FAILED".format(
my_res,
self.results,
),
f"EXPECTED RESULT {my_res} DOES NOT MATCH ACTUAL RESULT {self.results}. TEST FAILED",
msg_color="red",
)
fprint("-----------\n\n\n\n", msg_color="red")
Expand All @@ -37,10 +34,7 @@ def myassert(self, my_res):
passed = False
if not passed:
fprint(
"EXPECTED RESULT {} DOES NOT MATCH ACTUAL RESULT {}. TEST FAILED".format(
my_res,
self.results,
),
f"EXPECTED RESULT {my_res} DOES NOT MATCH ACTUAL RESULT {self.results}. TEST FAILED",
msg_color="red",
)
fprint("-----------\n\n\n\n", msg_color="red")
Expand Down
4 changes: 1 addition & 3 deletions NaviGator/test/navigator_test/nodes/circle_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,7 @@ def reseed(self, req: Optional[TriggerRequest]) -> None:
self.buoy_positions = np.array(_buoy_positions)
print(len(self.buoy_positions))
fprint(
"Removed {} buoys that were too close to totems".format(
len(self.buoy_positions) - len(_buoy_positions),
),
f"Removed {len(self.buoy_positions) - len(_buoy_positions)} buoys that were too close to totems",
)
# assert len(self.buoy_positions) > .5 * self.num_of_buoys, "Not enough buoys remain, try rerunning."
if len(self.buoy_positions) < 0.5 * self.num_of_buoys:
Expand Down
Loading
Loading