Skip to content

Commit 9262fdd

Browse files
committed
Resolve MyPy issues and add pre-commit
Signed-off-by: SuperJappie08 <36795178+SuperJappie08@users.noreply.github.com>
1 parent 17368a9 commit 9262fdd

3 files changed

Lines changed: 92 additions & 4 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on: [push, pull_request]
55
jobs:
66
ament_lint:
77
runs-on: ubuntu-latest
8-
container:
8+
container:
99
image: rostooling/setup-ros-docker:ubuntu-${{ matrix.ubuntu }}-ros-${{ matrix.ros_distro }}-ros-base-latest
1010

1111
strategy:

.pre-commit-config.yaml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
2+
# To use:
3+
#
4+
# pre-commit run -a
5+
#
6+
# Or:
7+
#
8+
# pre-commit install # (runs every time you commit in git)
9+
#
10+
# To update this file:
11+
#
12+
# pre-commit autoupdate
13+
#
14+
# See https://github.com/pre-commit/pre-commit
15+
16+
repos:
17+
# Standard hooks
18+
- repo: https://github.com/pre-commit/pre-commit-hooks
19+
rev: v6.0.0
20+
hooks:
21+
- id: check-added-large-files
22+
- id: check-ast
23+
- id: check-case-conflict
24+
- id: check-docstring-first
25+
- id: check-merge-conflict
26+
- id: check-symlinks
27+
- id: check-xml
28+
- id: check-yaml
29+
args: ["--allow-multiple-documents"]
30+
- id: debug-statements
31+
- id: end-of-file-fixer
32+
- id: mixed-line-ending
33+
- id: trailing-whitespace
34+
exclude_types: [rst]
35+
- id: fix-byte-order-marker
36+
37+
38+
# Python hooks
39+
- repo: https://github.com/asottile/pyupgrade
40+
rev: v3.20.0
41+
hooks:
42+
- id: pyupgrade
43+
args: [--py36-plus]
44+
45+
# flake8
46+
- repo: local
47+
hooks:
48+
- id: ament_flake8
49+
name: ament_flake8
50+
description: Check if all files adhere to ament_flake8.
51+
entry: ament_flake8
52+
files: \.(py|pyi)$
53+
language: system
54+
55+
# mypy
56+
- repo: local
57+
hooks:
58+
- id: ament_mypy
59+
name: ament_mypy
60+
description: Check if all files adhere to ament_mypy.
61+
entry: ament_mypy
62+
args: ["--exclude", "diffbot.launch.py"]
63+
pass_filenames: False
64+
require_serial: True
65+
files: \.(py|pyi)$
66+
exclude: (^|\.launch\.py)$
67+
language: system
68+
69+
# Copyright
70+
- repo: local
71+
hooks:
72+
- id: ament_copyright
73+
name: ament_copyright
74+
description: Check if copyright notice is available in all files.
75+
entry: ament_copyright
76+
files: \.(c|cc|cpp|cxx|h|hh|hpp|hxx|cmake|py)$
77+
exclude: ^(\.|_|(setup\.py|package\.xml)$)
78+
language: system
79+
80+
- repo: https://github.com/python-jsonschema/check-jsonschema
81+
rev: 0.33.2
82+
hooks:
83+
- id: check-github-workflows
84+
args: ["--verbose"]
85+
- id: check-github-actions
86+
args: ["--verbose"]
87+
- id: check-dependabot
88+
args: ["--verbose"]

launch_ros2_control/actions/spawn_controllers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from launch.frontend import Entity, expose_action, Parser
2525
from launch.launch_context import LaunchContext
2626
from launch.some_substitutions_type import SomeSubstitutionsType
27+
from launch.substitution import Substitution
2728
from launch.utilities import normalize_to_list_of_substitutions
2829
from launch.utilities import perform_substitutions
2930
from launch.utilities.type_utils import normalize_typed_substitution
@@ -34,7 +35,6 @@
3435
from launch_ros.utilities.normalize_parameters import normalize_parameter_dict
3536

3637
if TYPE_CHECKING:
37-
from launch.substitution import Substitution
3838
from launch_ros.parameters_type import Parameters
3939

4040
from ..descriptions import Controller
@@ -288,11 +288,11 @@ def convert_param(param):
288288
context, {name: value})
289289
assert os.path.isfile(params_argument)
290290
else:
291-
raise RuntimeError('invalid normalized parameters {}'.format(repr(params)))
291+
raise RuntimeError(f'invalid normalized parameters {repr(params)}')
292292

293293
if not os.path.isfile(params_argument):
294294
self.__logger.warning(
295-
'Parameter file path is not a file: {}'.format(params_argument))
295+
f'Parameter file path is not a file: {params_argument}')
296296
continue
297297
other_arguments += ['-p', params_argument]
298298

0 commit comments

Comments
 (0)