Skip to content

Commit

Permalink
Small fixes for modern flake8. (ros2#1264)
Browse files Browse the repository at this point in the history
It doesn't like to compare types with ==, so switch to
isinstance as appropriate.

Signed-off-by: Chris Lalancette <clalancette@gmail.com>
Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>
  • Loading branch information
clalancette authored and InvincibleRMC committed Apr 5, 2024
1 parent bac0ce3 commit 1ef6614
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions rclpy/rclpy/parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion rclpy/test/test_logging_rosout.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1ef6614

Please sign in to comment.