From 61e04097357ceb61f3df0ae9623b2e7375b5ffdc Mon Sep 17 00:00:00 2001 From: Chris Lalancette Date: Tue, 26 Mar 2024 14:31:37 -0400 Subject: [PATCH] Small fixes for modern flake8. (#1264) It doesn't like to compare types with ==, so switch to isinstance as appropriate. Signed-off-by: Chris Lalancette --- rclpy/rclpy/parameter.py | 4 ++-- rclpy/test/test_logging_rosout.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rclpy/rclpy/parameter.py b/rclpy/rclpy/parameter.py index 7dce99b8b..cd2cc820f 100644 --- a/rclpy/rclpy/parameter.py +++ b/rclpy/rclpy/parameter.py @@ -319,7 +319,7 @@ def parameter_dict_from_yaml_file( for n in param_keys: value = param_file[n] - if type(value) != dict or 'ros__parameters' not in value: + if not isinstance(value, dict) or 'ros__parameters' not in value: raise RuntimeError(f'YAML file is not a valid ROS parameter file for node {n}') param_dict.update(value['ros__parameters']) return _unpack_parameter_dict(namespace, param_dict) @@ -337,7 +337,7 @@ def _unpack_parameter_dict(namespace, parameter_dict): for param_name, param_value in parameter_dict.items(): full_param_name = namespace + param_name # Unroll nested parameters - if type(param_value) == dict: + if isinstance(param_value, dict): parameters.update(_unpack_parameter_dict( namespace=full_param_name + PARAMETER_SEPARATOR_STRING, parameter_dict=param_value)) diff --git a/rclpy/test/test_logging_rosout.py b/rclpy/test/test_logging_rosout.py index 1de1c73a6..1e170a317 100644 --- a/rclpy/test/test_logging_rosout.py +++ b/rclpy/test/test_logging_rosout.py @@ -83,7 +83,7 @@ def test_enable_rosout( if expected_data: assert (rosout_subscription_msg is not None) - assert (type(rosout_subscription_msg) == Log) + assert (isinstance(rosout_subscription_msg, Log)) assert (LoggingSeverity(rosout_subscription_msg.level) == LoggingSeverity.INFO) assert (len(rosout_subscription_msg.msg) != 0) assert (rosout_subscription_msg.msg == message_data)