Skip to content

Commit

Permalink
Migrate remaining linters to pre-commit (RobotWebTools#657)
Browse files Browse the repository at this point in the history
Follow up from RobotWebTools#648:

- Remove separate `pre-commit.yaml` Github workflow in favor of existing `ci.yml` workflow
- Removed unused json and toml linters from `.pre-commit-config.yaml`
- `isort` is updated to v5.9.3
- `bandit`, `codespell`, and `flake8` are migrated to `.pre-commit-config.yaml` so all linters are in one place
- Fixed wildcard and invalid imports in `rosapi_node` which were missed by RobotWebTools#609 (due to not having a .py extension)
  • Loading branch information
amacneil authored Sep 28, 2021
1 parent ef0e417 commit 516c6a6
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 53 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2
with:
python-version: '3.8'
- run: pip install bandit codespell flake8
- run: bandit --recursive --skip B101,B110,B311 .
- run: codespell
- run: flake8

- uses: pre-commit/[email protected]

test:
strategy:
Expand Down
19 changes: 0 additions & 19 deletions .github/workflows/pre-commit.yaml

This file was deleted.

44 changes: 20 additions & 24 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,47 +1,43 @@
# Modified from https://github.com/ros-planning/moveit2/blob/d184714751b347a2389cf1e8742b1be94eed63b8/.pre-commit-config.yaml
#
# To use:
#
# pre-commit run -a
#
# Or:
#
# pre-commit install # (runs every time you commit in git)
#
# To update this file:
#
# pre-commit autoupdate
#
# See https://github.com/pre-commit/pre-commit

# See https://pre-commit.com for more information
repos:
# Standard hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-json
- id: check-merge-conflict
- id: check-symlinks
- id: check-toml
- id: check-yaml
- id: debug-statements
- id: destroyed-symlinks
- id: detect-private-key
- id: end-of-file-fixer
- id: mixed-line-ending
- id: pretty-format-json
- id: trailing-whitespace

- repo: https://github.com/pycqa/isort
rev: 5.9.3
hooks:
- id: isort

- repo: https://github.com/psf/black
rev: 21.9b0
hooks:
- id: black
args: ["--line-length=100"]

- repo: https://github.com/pycqa/isort
rev: 5.8.0
- repo: https://github.com/PyCQA/flake8
rev: 3.9.2
hooks:
- id: isort
name: isort (python)
- id: flake8

- repo: https://github.com/PyCQA/bandit
rev: 1.7.0
hooks:
- id: bandit
args: ["--skip", "B101,B110,B311"]

- repo: https://github.com/codespell-project/codespell
rev: v2.1.0
hooks:
- id: codespell
38 changes: 32 additions & 6 deletions rosapi/scripts/rosapi_node
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,34 @@ from rclpy.clock import Clock, ClockType
from rclpy.node import Node

from rosapi import glob_helper, objectutils, params, proxy
from rosapi.msg import *
from rosapi.srv import *
from rosapi.msg import TypeDef
from rosapi.srv import (
DeleteParam,
GetActionServers,
GetParam,
GetParamNames,
GetTime,
HasParam,
MessageDetails,
NodeDetails,
Nodes,
Publishers,
SearchParam,
ServiceHost,
ServiceNode,
ServiceProviders,
ServiceRequestDetails,
ServiceResponseDetails,
Services,
ServicesForType,
ServiceType,
SetParam,
Subscribers,
Topics,
TopicsAndRawTypes,
TopicsForType,
TopicType,
)


class Rosapi(Node):
Expand Down Expand Up @@ -277,12 +303,12 @@ class Rosapi(Node):
def get_service_host(request):
"""Called by the rosapi/ServiceNode service. Given the name of a service, returns the name of the machine
that is hosting that service."""
return ServiceHostResponse(proxy.get_service_host(request.service))
return ServiceHost(proxy.get_service_host(request.service))


# Note(@jubeira): rclpy does not have an equivalent for this. To be checked if this service is necessary or not.
def search_param(request):
return SearchParamResponse(rosapi.params.search_param(request.name, rosapi.glob_helper.params))
return SearchParam(params.search_param(request.name, glob_helper.params))


def dict_to_typedef(typedefdict):
Expand All @@ -302,8 +328,8 @@ def main(args=None):
args = sys.argv

rclpy.init(args=args)
rosapi_node = Rosapi()
rclpy.spin(rosapi_node)
node = Rosapi()
rclpy.spin(node)

node.destroy_node()
rclpy.shutdown()
Expand Down

0 comments on commit 516c6a6

Please sign in to comment.