diff --git a/.github/workflows/industrial_ci_action.yml b/.github/workflows/industrial_ci_action.yml index 9410ec45..fab9a633 100644 --- a/.github/workflows/industrial_ci_action.yml +++ b/.github/workflows/industrial_ci_action.yml @@ -47,4 +47,4 @@ jobs: DOCKER_IMAGE: ghcr.io/cwrurobotics/rov-24:main ROS_REPO: ${{ matrix.ROS_REPO }} # Crazy one liner for install python dependencies - AFTER_INSTALL_TARGET_DEPENDENCIES_EMBED: 'for d in /root/target_ws/src/rov-24/src/pi/*/ /root/target_ws/src/rov-24/src/surface/*/; do pip install -e "$d"; done' + AFTER_INSTALL_TARGET_DEPENDENCIES_EMBED: 'for d in /root/target_ws/src/rov-24/src/pi/*/ /root/target_ws/src/rov-24/src/surface/*/; do pip install -e "$d"; done' \ No newline at end of file diff --git a/.pylintrc b/.pylintrc new file mode 100644 index 00000000..a5208fdc --- /dev/null +++ b/.pylintrc @@ -0,0 +1,3 @@ +[main] +disable=duplicate-code,fixme +extension-pkg-whitelist=PyQt6,cv2 \ No newline at end of file diff --git a/README.md b/README.md index 8e6e1bc1..475afc8a 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ git clone --recurse-submodules git@github.com:cwruRobotics/rov-24.git If you've never contributed to a git repository before, you might receive an error message saying you don't have access. In that case visit [this tutorial](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/about-ssh) to set up SSH for local GitHub access. -After cloning the code, we need to set up our IDE: VSCode. If you already have it, great. Otherwise follow [this](https://code.visualstudio.com/download) tutorial. +After cloning the code, we need to set up our IDE: VSCode. If you already have it, great. Otherwise follow [this](https://code.visualstudio.com/download) tutorial. We recommend installing the mypy, flake8 and autoDocstring VSCode extensions. Our setting for autoDocstring are set to Numpy and auto docstring on new line. ### Linux @@ -134,6 +134,8 @@ If you're working on package's `setup.py` or rov_msgs, you'll need to run `🏃 If you want to run our unit tests use this command `colcon test --event-handlers=console_direct+`. +In VSCode, press `F1` or `ctrl+shift+p` and enter `Tasks: Run Test Task` as another method to run the above command. + It runs the tests and pipes the output to the terminal. To test pi_main make sure to type your password into the terminal after running the above command. If you install the flake8 and mypy extension they should help enforce the linters. @@ -173,5 +175,26 @@ Any topics or services communicating across will be renamed first into the tethe Documentation will take place at 3 levels: - High Level - Overarching Design Document outlining our general structure and what goes where. -- Device Level - ROS Docs as set out in the ROS2 standards. -- Inline Level - Inline Documentation to the level that someone who has some basic code knowledge can understand what the code does. +- Device Level - Following the markdown tempate in `doc` directory. +- Inline Level - Using reST / Numpy Standard. To autogenerate in VSCode we use autoDocstring extension with the setting set to Numpy and auto docstring on new line. Below is an example of an inline function docstring. + +```python +def __init__(self, srv_type: SrvType, topic: str, signal: pyqtBoundSignal, + timeout: float = 1.0, expected_namespace: str = '/surface/gui'): + """ + _summary_ + + Parameters + ---------- + srv_type : SrvType + _description_ + topic : str + _description_ + signal : pyqtBoundSignal + _description_ + timeout : float, optional + _description_, by default 1.0 + expected_namespace : str, optional + _description_, by default '/surface/gui' + """ +``` diff --git a/src/pi/camera_streamer/launch/camera_launch.py b/src/pi/camera_streamer/launch/camera_launch.py index 6bdafa40..be904c14 100644 --- a/src/pi/camera_streamer/launch/camera_launch.py +++ b/src/pi/camera_streamer/launch/camera_launch.py @@ -1,9 +1,18 @@ +"""camera_streamer launch file.""" from launch.launch_description import LaunchDescription from launch_ros.actions import Node def generate_launch_description() -> LaunchDescription: + """ + Generate LaunchDescription for camera_streamer. + Returns + ------- + LaunchDescription + Launches Front and Bottom Cameras nodes + + """ # Symlinks are auto-generated by V4L2 # ls /dev/v4l/by-id to see all the available symlinks # ls /dev/v4l/by-path for usb slot based symlinks diff --git a/src/pi/camera_streamer/setup.py b/src/pi/camera_streamer/setup.py index 4de5f730..1dcab2c8 100644 --- a/src/pi/camera_streamer/setup.py +++ b/src/pi/camera_streamer/setup.py @@ -1,20 +1,21 @@ +"""setup.py for camera_streamer module.""" import os from glob import glob from setuptools import setup -package_name = 'camera_streamer' +PACKAGE_NAME = 'camera_streamer' setup( - name=package_name, + name=PACKAGE_NAME, version='1.0.0', - packages=[package_name], + packages=[PACKAGE_NAME], data_files=[ ('share/ament_index/resource_index/packages', - ['resource/' + package_name]), - ('share/' + package_name, ['package.xml']), + ['resource/' + PACKAGE_NAME]), + ('share/' + PACKAGE_NAME, ['package.xml']), # Include all launch files. - (os.path.join('share', package_name, 'launch'), + (os.path.join('share', PACKAGE_NAME, 'launch'), glob('launch/*launch.[pxy][yma]*')) ], install_requires=['setuptools', 'flake8==4.0.1', 'mypy >= 1.7'], diff --git a/src/pi/camera_streamer/test/test_flake8.py b/src/pi/camera_streamer/test/test_flake8.py index eac16eef..8ae474ef 100644 --- a/src/pi/camera_streamer/test/test_flake8.py +++ b/src/pi/camera_streamer/test/test_flake8.py @@ -1,3 +1,4 @@ +"""Test flake8 on this module.""" # Copyright 2017 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,7 +20,8 @@ @pytest.mark.flake8 @pytest.mark.linter def test_flake8() -> None: - rc, errors = main_with_errors(argv=[]) - assert rc == 0, \ - 'Found %d code style errors / warnings:\n' % len(errors) + \ + """Tests flake8 on this module.""" + error_code, errors = main_with_errors(argv=[]) + assert error_code == 0, \ + f'Found {len(errors)} code style errors / warnings:\n' + \ '\n'.join(errors) diff --git a/src/pi/camera_streamer/test/test_mypy.py b/src/pi/camera_streamer/test/test_mypy.py index fbd775a9..79fc51ad 100644 --- a/src/pi/camera_streamer/test/test_mypy.py +++ b/src/pi/camera_streamer/test/test_mypy.py @@ -1,3 +1,4 @@ +"""Test mypy on this module.""" import os import pytest @@ -7,7 +8,8 @@ @pytest.mark.mypy @pytest.mark.linter def test_mypy() -> None: + """Tests mypy on this module.""" file_path = __file__.replace(f'{__name__}.py', '') config_file = os.path.join(file_path, '..', '..', '..', '..', 'mypy.ini') - rc = main(argv=['--config', config_file]) - assert rc == 0, 'Found code style errors / warnings' + error_code = main(argv=['--config', config_file]) + assert error_code == 0, 'Found code style errors / warnings' diff --git a/src/pi/camera_streamer/test/test_pep257.py b/src/pi/camera_streamer/test/test_pep257.py index b6808e1d..b95ea531 100644 --- a/src/pi/camera_streamer/test/test_pep257.py +++ b/src/pi/camera_streamer/test/test_pep257.py @@ -1,3 +1,4 @@ +"""Test pep257 on this module.""" # Copyright 2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,5 +20,6 @@ @pytest.mark.linter @pytest.mark.pep257 def test_pep257() -> None: - rc = main(argv=['.', 'test']) - assert rc == 0, 'Found code style errors / warnings' + """Tests pep257 on this module.""" + error_code = main(argv=['.', 'test']) + assert error_code == 0, 'Found code style errors / warnings' diff --git a/src/pi/manipulators/setup.py b/src/pi/manipulators/setup.py index b6122ceb..6c45869d 100644 --- a/src/pi/manipulators/setup.py +++ b/src/pi/manipulators/setup.py @@ -1,24 +1,21 @@ +"""setup.py for manipulators module.""" import os -import sys from glob import glob from setuptools import setup -major_num = sys.version_info[0] -minor_num = sys.version_info[1] - -package_name = 'manipulators' +PACKAGE_NAME = 'manipulators' setup( - name=package_name, + name=PACKAGE_NAME, version='1.0.0', - packages=[package_name], + packages=[PACKAGE_NAME], data_files=[ ('share/ament_index/resource_index/packages', - ['resource/' + package_name]), - ('share/' + package_name, ['package.xml']), + ['resource/' + PACKAGE_NAME]), + ('share/' + PACKAGE_NAME, ['package.xml']), # Include all launch files. - (os.path.join('share', package_name, 'launch'), + (os.path.join('share', PACKAGE_NAME, 'launch'), glob('launch/*launch.[pxy][yma]*')) ], install_requires=['setuptools', 'flake8==4.0.1', 'mypy >= 1.7'], diff --git a/src/pi/manipulators/test/test_flake8.py b/src/pi/manipulators/test/test_flake8.py index eac16eef..8ae474ef 100644 --- a/src/pi/manipulators/test/test_flake8.py +++ b/src/pi/manipulators/test/test_flake8.py @@ -1,3 +1,4 @@ +"""Test flake8 on this module.""" # Copyright 2017 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,7 +20,8 @@ @pytest.mark.flake8 @pytest.mark.linter def test_flake8() -> None: - rc, errors = main_with_errors(argv=[]) - assert rc == 0, \ - 'Found %d code style errors / warnings:\n' % len(errors) + \ + """Tests flake8 on this module.""" + error_code, errors = main_with_errors(argv=[]) + assert error_code == 0, \ + f'Found {len(errors)} code style errors / warnings:\n' + \ '\n'.join(errors) diff --git a/src/pi/manipulators/test/test_mypy.py b/src/pi/manipulators/test/test_mypy.py index fbd775a9..79fc51ad 100644 --- a/src/pi/manipulators/test/test_mypy.py +++ b/src/pi/manipulators/test/test_mypy.py @@ -1,3 +1,4 @@ +"""Test mypy on this module.""" import os import pytest @@ -7,7 +8,8 @@ @pytest.mark.mypy @pytest.mark.linter def test_mypy() -> None: + """Tests mypy on this module.""" file_path = __file__.replace(f'{__name__}.py', '') config_file = os.path.join(file_path, '..', '..', '..', '..', 'mypy.ini') - rc = main(argv=['--config', config_file]) - assert rc == 0, 'Found code style errors / warnings' + error_code = main(argv=['--config', config_file]) + assert error_code == 0, 'Found code style errors / warnings' diff --git a/src/pi/manipulators/test/test_pep257.py b/src/pi/manipulators/test/test_pep257.py index b6808e1d..b95ea531 100644 --- a/src/pi/manipulators/test/test_pep257.py +++ b/src/pi/manipulators/test/test_pep257.py @@ -1,3 +1,4 @@ +"""Test pep257 on this module.""" # Copyright 2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,5 +20,6 @@ @pytest.mark.linter @pytest.mark.pep257 def test_pep257() -> None: - rc = main(argv=['.', 'test']) - assert rc == 0, 'Found code style errors / warnings' + """Tests pep257 on this module.""" + error_code = main(argv=['.', 'test']) + assert error_code == 0, 'Found code style errors / warnings' diff --git a/src/pi/pi_main/launch/pi_launch.py b/src/pi/pi_main/launch/pi_launch.py index a1e5ce48..f5283446 100644 --- a/src/pi/pi_main/launch/pi_launch.py +++ b/src/pi/pi_main/launch/pi_launch.py @@ -1,3 +1,4 @@ +"""pi_launch launch file.""" import os from ament_index_python.packages import get_package_share_directory @@ -8,7 +9,16 @@ def generate_launch_description() -> LaunchDescription: - NS = 'pi' + """ + Generate LaunchDescription for pi_main. + + Returns + ------- + LaunchDescription + Launches camera_streamer package and pixhawk_communication package. + + """ + NAMESPACE = 'pi' # Manipulator Controller # manip_path: str = get_package_share_directory('manipulators') # @@ -56,7 +66,7 @@ def generate_launch_description() -> LaunchDescription: namespace_launch = GroupAction( actions=[ - PushRosNamespace(NS), + PushRosNamespace(NAMESPACE), # manip_launch, pixhawk_launch, cam_launch, diff --git a/src/pi/pi_main/pi_main/install_on_boot.py b/src/pi/pi_main/pi_main/run_on_boot.py similarity index 73% rename from src/pi/pi_main/pi_main/install_on_boot.py rename to src/pi/pi_main/pi_main/run_on_boot.py index 48808544..ea7f29ad 100644 --- a/src/pi/pi_main/pi_main/install_on_boot.py +++ b/src/pi/pi_main/pi_main/run_on_boot.py @@ -1,3 +1,4 @@ +"""When run sets up environment for the robot to run on boot.""" import os import sys import subprocess @@ -8,6 +9,13 @@ def main() -> None: + """ + Set up Pi file environment. + + Copies udev rules from this package into udev folder. + Also uses robot_upstart to allow robot to automatically start on power on. + + """ pi_main_share = get_package_share_directory('pi_main') launch_dir = os.path.join(pi_main_share, 'launch') @@ -27,14 +35,14 @@ def main() -> None: cmd = ['/usr/bin/sudo', '/usr/bin/python3', udev_script, pi_main_share] try: - p = subprocess.run(cmd, capture_output=True, check=True) + process = subprocess.run(cmd, capture_output=True, check=True) # Logs Error - except subprocess.CalledProcessError as e: - print(e.stderr) + except subprocess.CalledProcessError as error: + print(error.stderr) sys.exit(1) # Success Message - print(p.stdout.decode()) + print(process.stdout.decode()) install_path = os.path.join(pi_main_share, "..", "..") workspace_path = os.path.join(install_path, "setup.bash") diff --git a/src/pi/pi_main/pi_main/udev_copy.py b/src/pi/pi_main/pi_main/udev_copy.py index 539eaac4..1ee98548 100644 --- a/src/pi/pi_main/pi_main/udev_copy.py +++ b/src/pi/pi_main/pi_main/udev_copy.py @@ -1,3 +1,4 @@ +"""Copies udev rules from separate process to ensure ideal protections of sudo.""" import os import shutil import sys diff --git a/src/pi/pi_main/setup.py b/src/pi/pi_main/setup.py index 1cbc9564..6e345e61 100644 --- a/src/pi/pi_main/setup.py +++ b/src/pi/pi_main/setup.py @@ -1,23 +1,24 @@ +"""setup.py for pi_main module.""" import os from glob import glob from setuptools import setup -package_name = 'pi_main' +PACKAGE_NAME = 'pi_main' setup( - name=package_name, + name=PACKAGE_NAME, version='1.0.0', - packages=[package_name], + packages=[PACKAGE_NAME], data_files=[ ('share/ament_index/resource_index/packages', - ['resource/' + package_name]), - ('share/' + package_name, ['package.xml']), + ['resource/' + PACKAGE_NAME]), + ('share/' + PACKAGE_NAME, ['package.xml']), # Include all launch files. - (os.path.join('share', package_name, 'launch'), + (os.path.join('share', PACKAGE_NAME, 'launch'), glob('launch/*launch.[pxy][yma]*')), - (os.path.join('share', package_name, 'udev_rules'), + (os.path.join('share', PACKAGE_NAME, 'udev_rules'), glob('udev_rules/*')) ], install_requires=['setuptools', 'flake8==4.0.1', 'mypy >= 1.7'], @@ -29,7 +30,7 @@ tests_require=['pytest'], entry_points={ 'console_scripts': [ - 'install = pi_main.install_on_boot:main', + 'install = pi_main.run_on_boot:main', ], }, ) diff --git a/src/pi/pi_main/test/test_flake8.py b/src/pi/pi_main/test/test_flake8.py index eac16eef..8ae474ef 100644 --- a/src/pi/pi_main/test/test_flake8.py +++ b/src/pi/pi_main/test/test_flake8.py @@ -1,3 +1,4 @@ +"""Test flake8 on this module.""" # Copyright 2017 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,7 +20,8 @@ @pytest.mark.flake8 @pytest.mark.linter def test_flake8() -> None: - rc, errors = main_with_errors(argv=[]) - assert rc == 0, \ - 'Found %d code style errors / warnings:\n' % len(errors) + \ + """Tests flake8 on this module.""" + error_code, errors = main_with_errors(argv=[]) + assert error_code == 0, \ + f'Found {len(errors)} code style errors / warnings:\n' + \ '\n'.join(errors) diff --git a/src/pi/pi_main/test/test_mypy.py b/src/pi/pi_main/test/test_mypy.py index fbd775a9..79fc51ad 100644 --- a/src/pi/pi_main/test/test_mypy.py +++ b/src/pi/pi_main/test/test_mypy.py @@ -1,3 +1,4 @@ +"""Test mypy on this module.""" import os import pytest @@ -7,7 +8,8 @@ @pytest.mark.mypy @pytest.mark.linter def test_mypy() -> None: + """Tests mypy on this module.""" file_path = __file__.replace(f'{__name__}.py', '') config_file = os.path.join(file_path, '..', '..', '..', '..', 'mypy.ini') - rc = main(argv=['--config', config_file]) - assert rc == 0, 'Found code style errors / warnings' + error_code = main(argv=['--config', config_file]) + assert error_code == 0, 'Found code style errors / warnings' diff --git a/src/pi/pi_main/test/test_pep257.py b/src/pi/pi_main/test/test_pep257.py index b6808e1d..b95ea531 100644 --- a/src/pi/pi_main/test/test_pep257.py +++ b/src/pi/pi_main/test/test_pep257.py @@ -1,3 +1,4 @@ +"""Test pep257 on this module.""" # Copyright 2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,5 +20,6 @@ @pytest.mark.linter @pytest.mark.pep257 def test_pep257() -> None: - rc = main(argv=['.', 'test']) - assert rc == 0, 'Found code style errors / warnings' + """Tests pep257 on this module.""" + error_code = main(argv=['.', 'test']) + assert error_code == 0, 'Found code style errors / warnings' diff --git a/src/pi/pi_main/test/test_install_on_boot.py b/src/pi/pi_main/test/test_run_on_boot.py similarity index 95% rename from src/pi/pi_main/test/test_install_on_boot.py rename to src/pi/pi_main/test/test_run_on_boot.py index c37ffa54..478314dd 100644 --- a/src/pi/pi_main/test/test_install_on_boot.py +++ b/src/pi/pi_main/test/test_run_on_boot.py @@ -1,6 +1,6 @@ import os -from pi_main.install_on_boot import main +from pi_main.run_on_boot import main ROS_DISTRO = os.getenv("ROS_DISTRO") diff --git a/src/pi/pixhawk_communication/launch/mavros_launch.py b/src/pi/pixhawk_communication/launch/mavros_launch.py index 796cf701..049654cc 100644 --- a/src/pi/pixhawk_communication/launch/mavros_launch.py +++ b/src/pi/pixhawk_communication/launch/mavros_launch.py @@ -1,9 +1,18 @@ +"""mavros_launch launch file.""" from launch.launch_description import LaunchDescription from launch_ros.actions import Node def generate_launch_description() -> LaunchDescription: + """ + Generate LaunchDescription for pixhawk_communication package. + Returns + ------- + LaunchDescription + Launches mavros Node. + + """ mavros_node = Node( package="mavros", executable="mavros_node", diff --git a/src/pi/pixhawk_communication/setup.py b/src/pi/pixhawk_communication/setup.py index d38c15a0..f55542a6 100644 --- a/src/pi/pixhawk_communication/setup.py +++ b/src/pi/pixhawk_communication/setup.py @@ -1,20 +1,21 @@ +"""setup.py for pixhawk_communication module.""" import os from glob import glob from setuptools import setup -package_name = 'pixhawk_communication' +PACKAGE_NAME = 'pixhawk_communication' setup( - name=package_name, + name=PACKAGE_NAME, version='1.0.0', - packages=[package_name], + packages=[PACKAGE_NAME], data_files=[ ('share/ament_index/resource_index/packages', - ['resource/' + package_name]), - ('share/' + package_name, ['package.xml']), + ['resource/' + PACKAGE_NAME]), + ('share/' + PACKAGE_NAME, ['package.xml']), # Include all launch files. - (os.path.join('share', package_name, 'launch'), + (os.path.join('share', PACKAGE_NAME, 'launch'), glob('launch/*launch.[pxy][yma]*')) ], install_requires=['setuptools', 'flake8==4.0.1', 'mypy >= 1.7'], diff --git a/src/pi/pixhawk_communication/test/test_flake8.py b/src/pi/pixhawk_communication/test/test_flake8.py index eac16eef..8ae474ef 100644 --- a/src/pi/pixhawk_communication/test/test_flake8.py +++ b/src/pi/pixhawk_communication/test/test_flake8.py @@ -1,3 +1,4 @@ +"""Test flake8 on this module.""" # Copyright 2017 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,7 +20,8 @@ @pytest.mark.flake8 @pytest.mark.linter def test_flake8() -> None: - rc, errors = main_with_errors(argv=[]) - assert rc == 0, \ - 'Found %d code style errors / warnings:\n' % len(errors) + \ + """Tests flake8 on this module.""" + error_code, errors = main_with_errors(argv=[]) + assert error_code == 0, \ + f'Found {len(errors)} code style errors / warnings:\n' + \ '\n'.join(errors) diff --git a/src/pi/pixhawk_communication/test/test_mypy.py b/src/pi/pixhawk_communication/test/test_mypy.py index fbd775a9..79fc51ad 100644 --- a/src/pi/pixhawk_communication/test/test_mypy.py +++ b/src/pi/pixhawk_communication/test/test_mypy.py @@ -1,3 +1,4 @@ +"""Test mypy on this module.""" import os import pytest @@ -7,7 +8,8 @@ @pytest.mark.mypy @pytest.mark.linter def test_mypy() -> None: + """Tests mypy on this module.""" file_path = __file__.replace(f'{__name__}.py', '') config_file = os.path.join(file_path, '..', '..', '..', '..', 'mypy.ini') - rc = main(argv=['--config', config_file]) - assert rc == 0, 'Found code style errors / warnings' + error_code = main(argv=['--config', config_file]) + assert error_code == 0, 'Found code style errors / warnings' diff --git a/src/pi/pixhawk_communication/test/test_pep257.py b/src/pi/pixhawk_communication/test/test_pep257.py index b6808e1d..b95ea531 100644 --- a/src/pi/pixhawk_communication/test/test_pep257.py +++ b/src/pi/pixhawk_communication/test/test_pep257.py @@ -1,3 +1,4 @@ +"""Test pep257 on this module.""" # Copyright 2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,5 +20,6 @@ @pytest.mark.linter @pytest.mark.pep257 def test_pep257() -> None: - rc = main(argv=['.', 'test']) - assert rc == 0, 'Found code style errors / warnings' + """Tests pep257 on this module.""" + error_code = main(argv=['.', 'test']) + assert error_code == 0, 'Found code style errors / warnings' diff --git a/src/pi/realsense/launch/realsense_launch.py b/src/pi/realsense/launch/realsense_launch.py index 299b320f..b998f2a0 100644 --- a/src/pi/realsense/launch/realsense_launch.py +++ b/src/pi/realsense/launch/realsense_launch.py @@ -1,3 +1,4 @@ +"""realsense_launch launch file.""" import os from ament_index_python.packages import get_package_share_directory @@ -8,7 +9,15 @@ def generate_launch_description() -> LaunchDescription: + """ + Generate LaunchDescription for the realsense package. + Returns + ------- + LaunchDescription + Launches realsense launch file. + + """ realsense_path: str = get_package_share_directory('realsense2_camera') # Launches Realsense diff --git a/src/pi/realsense/setup.py b/src/pi/realsense/setup.py index beaf63ef..05114fa5 100644 --- a/src/pi/realsense/setup.py +++ b/src/pi/realsense/setup.py @@ -1,21 +1,22 @@ +"""setup.py for the realsense module.""" import os from glob import glob from setuptools import setup -package_name = 'realsense' +PACKAGE_NAME = 'realsense' setup( - name=package_name, + name=PACKAGE_NAME, version='1.0.0', - packages=[package_name], + packages=[PACKAGE_NAME], data_files=[ ('share/ament_index/resource_index/packages', - ['resource/' + package_name]), - ('share/' + package_name, ['package.xml']), + ['resource/' + PACKAGE_NAME]), + ('share/' + PACKAGE_NAME, ['package.xml']), # Include all launch files. - (os.path.join('share', package_name, 'launch'), + (os.path.join('share', PACKAGE_NAME, 'launch'), glob('launch/*launch.[pxy][yma]*')) ], install_requires=['setuptools', 'flake8==4.0.1', 'mypy >= 1.7'], diff --git a/src/pi/realsense/test/test_flake8.py b/src/pi/realsense/test/test_flake8.py index eac16eef..8ae474ef 100644 --- a/src/pi/realsense/test/test_flake8.py +++ b/src/pi/realsense/test/test_flake8.py @@ -1,3 +1,4 @@ +"""Test flake8 on this module.""" # Copyright 2017 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,7 +20,8 @@ @pytest.mark.flake8 @pytest.mark.linter def test_flake8() -> None: - rc, errors = main_with_errors(argv=[]) - assert rc == 0, \ - 'Found %d code style errors / warnings:\n' % len(errors) + \ + """Tests flake8 on this module.""" + error_code, errors = main_with_errors(argv=[]) + assert error_code == 0, \ + f'Found {len(errors)} code style errors / warnings:\n' + \ '\n'.join(errors) diff --git a/src/pi/realsense/test/test_mypy.py b/src/pi/realsense/test/test_mypy.py index fbd775a9..79fc51ad 100644 --- a/src/pi/realsense/test/test_mypy.py +++ b/src/pi/realsense/test/test_mypy.py @@ -1,3 +1,4 @@ +"""Test mypy on this module.""" import os import pytest @@ -7,7 +8,8 @@ @pytest.mark.mypy @pytest.mark.linter def test_mypy() -> None: + """Tests mypy on this module.""" file_path = __file__.replace(f'{__name__}.py', '') config_file = os.path.join(file_path, '..', '..', '..', '..', 'mypy.ini') - rc = main(argv=['--config', config_file]) - assert rc == 0, 'Found code style errors / warnings' + error_code = main(argv=['--config', config_file]) + assert error_code == 0, 'Found code style errors / warnings' diff --git a/src/pi/realsense/test/test_pep257.py b/src/pi/realsense/test/test_pep257.py index b6808e1d..b95ea531 100644 --- a/src/pi/realsense/test/test_pep257.py +++ b/src/pi/realsense/test/test_pep257.py @@ -1,3 +1,4 @@ +"""Test pep257 on this module.""" # Copyright 2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,5 +20,6 @@ @pytest.mark.linter @pytest.mark.pep257 def test_pep257() -> None: - rc = main(argv=['.', 'test']) - assert rc == 0, 'Found code style errors / warnings' + """Tests pep257 on this module.""" + error_code = main(argv=['.', 'test']) + assert error_code == 0, 'Found code style errors / warnings' diff --git a/src/surface/flight_control/test/test_flake8.py b/src/surface/flight_control/test/test_flake8.py index eac16eef..8ae474ef 100644 --- a/src/surface/flight_control/test/test_flake8.py +++ b/src/surface/flight_control/test/test_flake8.py @@ -1,3 +1,4 @@ +"""Test flake8 on this module.""" # Copyright 2017 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,7 +20,8 @@ @pytest.mark.flake8 @pytest.mark.linter def test_flake8() -> None: - rc, errors = main_with_errors(argv=[]) - assert rc == 0, \ - 'Found %d code style errors / warnings:\n' % len(errors) + \ + """Tests flake8 on this module.""" + error_code, errors = main_with_errors(argv=[]) + assert error_code == 0, \ + f'Found {len(errors)} code style errors / warnings:\n' + \ '\n'.join(errors) diff --git a/src/surface/flight_control/test/test_mypy.py b/src/surface/flight_control/test/test_mypy.py index fbd775a9..79fc51ad 100644 --- a/src/surface/flight_control/test/test_mypy.py +++ b/src/surface/flight_control/test/test_mypy.py @@ -1,3 +1,4 @@ +"""Test mypy on this module.""" import os import pytest @@ -7,7 +8,8 @@ @pytest.mark.mypy @pytest.mark.linter def test_mypy() -> None: + """Tests mypy on this module.""" file_path = __file__.replace(f'{__name__}.py', '') config_file = os.path.join(file_path, '..', '..', '..', '..', 'mypy.ini') - rc = main(argv=['--config', config_file]) - assert rc == 0, 'Found code style errors / warnings' + error_code = main(argv=['--config', config_file]) + assert error_code == 0, 'Found code style errors / warnings' diff --git a/src/surface/flight_control/test/test_pep257.py b/src/surface/flight_control/test/test_pep257.py index b6808e1d..b95ea531 100644 --- a/src/surface/flight_control/test/test_pep257.py +++ b/src/surface/flight_control/test/test_pep257.py @@ -1,3 +1,4 @@ +"""Test pep257 on this module.""" # Copyright 2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,5 +20,6 @@ @pytest.mark.linter @pytest.mark.pep257 def test_pep257() -> None: - rc = main(argv=['.', 'test']) - assert rc == 0, 'Found code style errors / warnings' + """Tests pep257 on this module.""" + error_code = main(argv=['.', 'test']) + assert error_code == 0, 'Found code style errors / warnings' diff --git a/src/surface/gui/gui/app.py b/src/surface/gui/gui/app.py index 82a80f14..afcd2aed 100644 --- a/src/surface/gui/gui/app.py +++ b/src/surface/gui/gui/app.py @@ -21,11 +21,7 @@ def __init__(self, node_name: str) -> None: self.node.declare_parameter('theme', '') self.resize(1850, 720) - atexit.register(self.clean_shutdown) - - def clean_shutdown(self) -> None: - if rclpy.utilities.ok(): - rclpy.shutdown() + atexit.register(clean_shutdown) def run_gui(self) -> None: # Kills with Control + C @@ -45,3 +41,8 @@ def run_gui(self) -> None: # TODO: when the app closes it causes an error. Make not cause error? self.app.exec() + + +def clean_shutdown() -> None: + if rclpy.utilities.ok(): + rclpy.shutdown() diff --git a/src/surface/gui/gui/event_nodes/client.py b/src/surface/gui/gui/event_nodes/client.py index 7136b7d5..4fb555e4 100644 --- a/src/surface/gui/gui/event_nodes/client.py +++ b/src/surface/gui/gui/event_nodes/client.py @@ -34,7 +34,6 @@ def __init__(self, srv_type: SrvType, topic: str, signal: pyqtBoundSignal, def __connect_to_service(self) -> None: """Connect this client to a server in a separate thread.""" while not self.cli.wait_for_service(timeout_sec=self.timeout): - # TODO: include namespaces wherever we echo the topic self.get_logger().info( 'Service for GUI event client node on topic' f' {self.expected_namespace}/{self.topic} unavailable, waiting again...') diff --git a/src/surface/gui/setup.py b/src/surface/gui/setup.py index ec560711..8796a58c 100644 --- a/src/surface/gui/setup.py +++ b/src/surface/gui/setup.py @@ -1,21 +1,22 @@ +"""setup.py for the gui module.""" import os from glob import glob from setuptools import setup -package_name = 'gui' +PACKAGE_NAME = 'gui' setup( - name=package_name, + name=PACKAGE_NAME, version='1.0.0', - packages=[package_name, os.path.join(package_name, 'widgets'), - os.path.join(package_name, 'event_nodes')], + packages=[PACKAGE_NAME, os.path.join(PACKAGE_NAME, 'widgets'), + os.path.join(PACKAGE_NAME, 'event_nodes')], data_files=[ ('share/ament_index/resource_index/packages', - ['resource/' + package_name]), - ('share/' + package_name, ['package.xml']), + ['resource/' + PACKAGE_NAME]), + ('share/' + PACKAGE_NAME, ['package.xml']), # Include all launch files. - (os.path.join('share', package_name, 'launch'), + (os.path.join('share', PACKAGE_NAME, 'launch'), glob('launch/*launch.[pxy][yma]*')) ], install_requires=['setuptools', 'pyqt6', 'pyqtdarktheme', 'opencv-python>=4.8.1', diff --git a/src/surface/gui/test/test_flake8.py b/src/surface/gui/test/test_flake8.py index eac16eef..8ae474ef 100644 --- a/src/surface/gui/test/test_flake8.py +++ b/src/surface/gui/test/test_flake8.py @@ -1,3 +1,4 @@ +"""Test flake8 on this module.""" # Copyright 2017 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,7 +20,8 @@ @pytest.mark.flake8 @pytest.mark.linter def test_flake8() -> None: - rc, errors = main_with_errors(argv=[]) - assert rc == 0, \ - 'Found %d code style errors / warnings:\n' % len(errors) + \ + """Tests flake8 on this module.""" + error_code, errors = main_with_errors(argv=[]) + assert error_code == 0, \ + f'Found {len(errors)} code style errors / warnings:\n' + \ '\n'.join(errors) diff --git a/src/surface/gui/test/test_mypy.py b/src/surface/gui/test/test_mypy.py index fbd775a9..79fc51ad 100644 --- a/src/surface/gui/test/test_mypy.py +++ b/src/surface/gui/test/test_mypy.py @@ -1,3 +1,4 @@ +"""Test mypy on this module.""" import os import pytest @@ -7,7 +8,8 @@ @pytest.mark.mypy @pytest.mark.linter def test_mypy() -> None: + """Tests mypy on this module.""" file_path = __file__.replace(f'{__name__}.py', '') config_file = os.path.join(file_path, '..', '..', '..', '..', 'mypy.ini') - rc = main(argv=['--config', config_file]) - assert rc == 0, 'Found code style errors / warnings' + error_code = main(argv=['--config', config_file]) + assert error_code == 0, 'Found code style errors / warnings' diff --git a/src/surface/gui/test/test_pep257.py b/src/surface/gui/test/test_pep257.py index b6808e1d..b95ea531 100644 --- a/src/surface/gui/test/test_pep257.py +++ b/src/surface/gui/test/test_pep257.py @@ -1,3 +1,4 @@ +"""Test pep257 on this module.""" # Copyright 2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,5 +20,6 @@ @pytest.mark.linter @pytest.mark.pep257 def test_pep257() -> None: - rc = main(argv=['.', 'test']) - assert rc == 0, 'Found code style errors / warnings' + """Tests pep257 on this module.""" + error_code = main(argv=['.', 'test']) + assert error_code == 0, 'Found code style errors / warnings' diff --git a/src/surface/ps5_controller/setup.py b/src/surface/ps5_controller/setup.py index 85fe33ac..d844a8c7 100644 --- a/src/surface/ps5_controller/setup.py +++ b/src/surface/ps5_controller/setup.py @@ -1,20 +1,21 @@ +"""setup.py for the ps5_controller module.""" import os from glob import glob from setuptools import setup -package_name = 'ps5_controller' +PACKAGE_NAME = 'ps5_controller' setup( - name=package_name, + name=PACKAGE_NAME, version='1.0.0', - packages=[package_name], + packages=[PACKAGE_NAME], data_files=[ ('share/ament_index/resource_index/packages', - ['resource/' + package_name]), - ('share/' + package_name, ['package.xml']), + ['resource/' + PACKAGE_NAME]), + ('share/' + PACKAGE_NAME, ['package.xml']), # Include all launch files. - (os.path.join('share', package_name, 'launch'), + (os.path.join('share', PACKAGE_NAME, 'launch'), glob('launch/*launch.[pxy][yma]*')) ], install_requires=['setuptools', 'flake8==4.0.1', 'mypy >= 1.7'], diff --git a/src/surface/ps5_controller/test/test_flake8.py b/src/surface/ps5_controller/test/test_flake8.py index eac16eef..8ae474ef 100644 --- a/src/surface/ps5_controller/test/test_flake8.py +++ b/src/surface/ps5_controller/test/test_flake8.py @@ -1,3 +1,4 @@ +"""Test flake8 on this module.""" # Copyright 2017 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,7 +20,8 @@ @pytest.mark.flake8 @pytest.mark.linter def test_flake8() -> None: - rc, errors = main_with_errors(argv=[]) - assert rc == 0, \ - 'Found %d code style errors / warnings:\n' % len(errors) + \ + """Tests flake8 on this module.""" + error_code, errors = main_with_errors(argv=[]) + assert error_code == 0, \ + f'Found {len(errors)} code style errors / warnings:\n' + \ '\n'.join(errors) diff --git a/src/surface/ps5_controller/test/test_mypy.py b/src/surface/ps5_controller/test/test_mypy.py index fbd775a9..79fc51ad 100644 --- a/src/surface/ps5_controller/test/test_mypy.py +++ b/src/surface/ps5_controller/test/test_mypy.py @@ -1,3 +1,4 @@ +"""Test mypy on this module.""" import os import pytest @@ -7,7 +8,8 @@ @pytest.mark.mypy @pytest.mark.linter def test_mypy() -> None: + """Tests mypy on this module.""" file_path = __file__.replace(f'{__name__}.py', '') config_file = os.path.join(file_path, '..', '..', '..', '..', 'mypy.ini') - rc = main(argv=['--config', config_file]) - assert rc == 0, 'Found code style errors / warnings' + error_code = main(argv=['--config', config_file]) + assert error_code == 0, 'Found code style errors / warnings' diff --git a/src/surface/ps5_controller/test/test_pep257.py b/src/surface/ps5_controller/test/test_pep257.py index b6808e1d..b95ea531 100644 --- a/src/surface/ps5_controller/test/test_pep257.py +++ b/src/surface/ps5_controller/test/test_pep257.py @@ -1,3 +1,4 @@ +"""Test pep257 on this module.""" # Copyright 2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,5 +20,6 @@ @pytest.mark.linter @pytest.mark.pep257 def test_pep257() -> None: - rc = main(argv=['.', 'test']) - assert rc == 0, 'Found code style errors / warnings' + """Tests pep257 on this module.""" + error_code = main(argv=['.', 'test']) + assert error_code == 0, 'Found code style errors / warnings' diff --git a/src/surface/rov_gazebo/launch/sim_launch.py b/src/surface/rov_gazebo/launch/sim_launch.py index 62c2a5a6..9e109abd 100644 --- a/src/surface/rov_gazebo/launch/sim_launch.py +++ b/src/surface/rov_gazebo/launch/sim_launch.py @@ -7,7 +7,7 @@ from launch.substitutions import Command from launch_ros.actions import Node -NS = "simulation" +NAMESPACE = "simulation" def generate_launch_description() -> LaunchDescription: @@ -32,7 +32,7 @@ def generate_launch_description() -> LaunchDescription: executable="robot_state_publisher", output="screen", parameters=[params], - namespace=NS, + namespace=NAMESPACE, emulate_tty=True ) @@ -41,8 +41,8 @@ def generate_launch_description() -> LaunchDescription: executable="robot_state_publisher", output="screen", parameters=[pool_params], - namespace=NS, - remappings=[(f"/{NS}/robot_description", f"/{NS}/pool_description")], + namespace=NAMESPACE, + remappings=[(f"/{NAMESPACE}/robot_description", f"/{NAMESPACE}/pool_description")], emulate_tty=True ) @@ -67,7 +67,7 @@ def generate_launch_description() -> LaunchDescription: "-allow_renaming", "true", ], - namespace=NS, + namespace=NAMESPACE, emulate_tty=True ) @@ -83,7 +83,7 @@ def generate_launch_description() -> LaunchDescription: "-allow_renaming", "true", ], - namespace=NS, + namespace=NAMESPACE, emulate_tty=True ) @@ -96,15 +96,15 @@ def generate_launch_description() -> LaunchDescription: executable="keyboard_driver_node", output="screen", name="keyboard_driver_node", - namespace=NS, - remappings=[(f"/{NS}/manual_control", "/manual_control")], + namespace=NAMESPACE, + remappings=[(f"/{NAMESPACE}/manual_control", "/manual_control")], emulate_tty=True ) # cam_bridge = Node( # package="ros_gz_bridge", # executable="parameter_bridge", - # namespace=NS, + # namespace=NAMESPACE, # name="cam_bridge", # arguments=[ # "/bottom_cam/image_raw@sensor_msgs/msg/Image@gz.msgs.Image", @@ -116,13 +116,13 @@ def generate_launch_description() -> LaunchDescription: # "/depth_cam/points@sensor_msgs/msg/PointCloud2@gz.msgs.PointCloudPacked", # ], # remappings=[ - # (f"/{NS}/bottom_cam/image_raw", "/bottom_cam/image_raw"), - # (f"/{NS}/bottom_cam/camera_info", "/bottom_cam/camera_info"), - # (f"/{NS}/front_cam/image_raw", "/front_cam/image_raw"), - # (f"/{NS}/front_cam/camera_info", "/front_cam/camera_info"), - # (f"/{NS}/manip_cam/image_raw", "/manip_cam/image_raw"), - # (f"/{NS}/depth_cam", "/depth_cam/image_raw"), - # (f"/{NS}/depth_cam/points", "/depth_cam/points"), + # (f"/{NAMESPACE}/bottom_cam/image_raw", "/bottom_cam/image_raw"), + # (f"/{NAMESPACE}/bottom_cam/camera_info", "/bottom_cam/camera_info"), + # (f"/{NAMESPACE}/front_cam/image_raw", "/front_cam/image_raw"), + # (f"/{NAMESPACE}/front_cam/camera_info", "/front_cam/camera_info"), + # (f"/{NAMESPACE}/manip_cam/image_raw", "/manip_cam/image_raw"), + # (f"/{NAMESPACE}/depth_cam", "/depth_cam/image_raw"), + # (f"/{NAMESPACE}/depth_cam/points", "/depth_cam/points"), # ], # output="screen", # emulate_tty=True diff --git a/src/surface/rov_gazebo/setup.py b/src/surface/rov_gazebo/setup.py index 550e659f..33f49162 100644 --- a/src/surface/rov_gazebo/setup.py +++ b/src/surface/rov_gazebo/setup.py @@ -1,22 +1,23 @@ +"""setup.py for the rov_gazebo module.""" import os from glob import glob from setuptools import setup -package_name = "rov_gazebo" +PACKAGE_NAME = "rov_gazebo" setup( - name=package_name, + name=PACKAGE_NAME, version="1.0.0", - packages=[package_name], + packages=[PACKAGE_NAME], data_files=[ - ("share/ament_index/resource_index/packages", ["resource/" + package_name]), - ("share/" + package_name, ["package.xml"]), - (os.path.join("share", package_name, "launch"), glob("launch/*.py")), - (os.path.join("share", package_name, "description"), glob("description/*")), - (os.path.join("share", package_name, "config"), glob("config/*")), - (os.path.join("share", package_name, "worlds"), glob("worlds/*")), - (os.path.join("share", package_name, "meshes"), glob("meshes/*")), + ("share/ament_index/resource_index/packages", ["resource/" + PACKAGE_NAME]), + ("share/" + PACKAGE_NAME, ["package.xml"]), + (os.path.join("share", PACKAGE_NAME, "launch"), glob("launch/*.py")), + (os.path.join("share", PACKAGE_NAME, "description"), glob("description/*")), + (os.path.join("share", PACKAGE_NAME, "config"), glob("config/*")), + (os.path.join("share", PACKAGE_NAME, "worlds"), glob("worlds/*")), + (os.path.join("share", PACKAGE_NAME, "meshes"), glob("meshes/*")), ], install_requires=["setuptools"], zip_safe=True, diff --git a/src/surface/rov_gazebo/test/test_flake8.py b/src/surface/rov_gazebo/test/test_flake8.py index eac16eef..8ae474ef 100644 --- a/src/surface/rov_gazebo/test/test_flake8.py +++ b/src/surface/rov_gazebo/test/test_flake8.py @@ -1,3 +1,4 @@ +"""Test flake8 on this module.""" # Copyright 2017 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,7 +20,8 @@ @pytest.mark.flake8 @pytest.mark.linter def test_flake8() -> None: - rc, errors = main_with_errors(argv=[]) - assert rc == 0, \ - 'Found %d code style errors / warnings:\n' % len(errors) + \ + """Tests flake8 on this module.""" + error_code, errors = main_with_errors(argv=[]) + assert error_code == 0, \ + f'Found {len(errors)} code style errors / warnings:\n' + \ '\n'.join(errors) diff --git a/src/surface/rov_gazebo/test/test_mypy.py b/src/surface/rov_gazebo/test/test_mypy.py index fbd775a9..79fc51ad 100644 --- a/src/surface/rov_gazebo/test/test_mypy.py +++ b/src/surface/rov_gazebo/test/test_mypy.py @@ -1,3 +1,4 @@ +"""Test mypy on this module.""" import os import pytest @@ -7,7 +8,8 @@ @pytest.mark.mypy @pytest.mark.linter def test_mypy() -> None: + """Tests mypy on this module.""" file_path = __file__.replace(f'{__name__}.py', '') config_file = os.path.join(file_path, '..', '..', '..', '..', 'mypy.ini') - rc = main(argv=['--config', config_file]) - assert rc == 0, 'Found code style errors / warnings' + error_code = main(argv=['--config', config_file]) + assert error_code == 0, 'Found code style errors / warnings' diff --git a/src/surface/rov_gazebo/test/test_pep257.py b/src/surface/rov_gazebo/test/test_pep257.py index b6808e1d..b95ea531 100644 --- a/src/surface/rov_gazebo/test/test_pep257.py +++ b/src/surface/rov_gazebo/test/test_pep257.py @@ -1,3 +1,4 @@ +"""Test pep257 on this module.""" # Copyright 2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,5 +20,6 @@ @pytest.mark.linter @pytest.mark.pep257 def test_pep257() -> None: - rc = main(argv=['.', 'test']) - assert rc == 0, 'Found code style errors / warnings' + """Tests pep257 on this module.""" + error_code = main(argv=['.', 'test']) + assert error_code == 0, 'Found code style errors / warnings' diff --git a/src/surface/surface_main/setup.py b/src/surface/surface_main/setup.py index 027b8146..83574567 100644 --- a/src/surface/surface_main/setup.py +++ b/src/surface/surface_main/setup.py @@ -1,20 +1,21 @@ +"""setup.py for the surface_main module.""" import os from glob import glob from setuptools import setup -package_name = 'surface_main' +PACKAGE_NAME = 'surface_main' setup( - name=package_name, + name=PACKAGE_NAME, version='1.0.0', - packages=[package_name], + packages=[PACKAGE_NAME], data_files=[ ('share/ament_index/resource_index/packages', - ['resource/' + package_name]), - ('share/' + package_name, ['package.xml']), + ['resource/' + PACKAGE_NAME]), + ('share/' + PACKAGE_NAME, ['package.xml']), # Include all launch files. - (os.path.join('share', package_name, 'launch'), + (os.path.join('share', PACKAGE_NAME, 'launch'), glob('launch/*launch.[pxy][yma]*')) ], install_requires=['setuptools', 'flake8==4.0.1', 'mypy >= 1.7'], diff --git a/src/surface/surface_main/test/test_flake8.py b/src/surface/surface_main/test/test_flake8.py index eac16eef..8ae474ef 100644 --- a/src/surface/surface_main/test/test_flake8.py +++ b/src/surface/surface_main/test/test_flake8.py @@ -1,3 +1,4 @@ +"""Test flake8 on this module.""" # Copyright 2017 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,7 +20,8 @@ @pytest.mark.flake8 @pytest.mark.linter def test_flake8() -> None: - rc, errors = main_with_errors(argv=[]) - assert rc == 0, \ - 'Found %d code style errors / warnings:\n' % len(errors) + \ + """Tests flake8 on this module.""" + error_code, errors = main_with_errors(argv=[]) + assert error_code == 0, \ + f'Found {len(errors)} code style errors / warnings:\n' + \ '\n'.join(errors) diff --git a/src/surface/surface_main/test/test_mypy.py b/src/surface/surface_main/test/test_mypy.py index fbd775a9..79fc51ad 100644 --- a/src/surface/surface_main/test/test_mypy.py +++ b/src/surface/surface_main/test/test_mypy.py @@ -1,3 +1,4 @@ +"""Test mypy on this module.""" import os import pytest @@ -7,7 +8,8 @@ @pytest.mark.mypy @pytest.mark.linter def test_mypy() -> None: + """Tests mypy on this module.""" file_path = __file__.replace(f'{__name__}.py', '') config_file = os.path.join(file_path, '..', '..', '..', '..', 'mypy.ini') - rc = main(argv=['--config', config_file]) - assert rc == 0, 'Found code style errors / warnings' + error_code = main(argv=['--config', config_file]) + assert error_code == 0, 'Found code style errors / warnings' diff --git a/src/surface/surface_main/test/test_pep257.py b/src/surface/surface_main/test/test_pep257.py index b6808e1d..b95ea531 100644 --- a/src/surface/surface_main/test/test_pep257.py +++ b/src/surface/surface_main/test/test_pep257.py @@ -1,3 +1,4 @@ +"""Test pep257 on this module.""" # Copyright 2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,5 +20,6 @@ @pytest.mark.linter @pytest.mark.pep257 def test_pep257() -> None: - rc = main(argv=['.', 'test']) - assert rc == 0, 'Found code style errors / warnings' + """Tests pep257 on this module.""" + error_code = main(argv=['.', 'test']) + assert error_code == 0, 'Found code style errors / warnings'