From 59f594d03aa351db4d2291bdcc92ee7f6b55b253 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steven!=20Ragnar=C3=B6k?= Date: Fri, 10 Apr 2020 10:10:36 -0400 Subject: [PATCH 1/2] Use named keyword args in format. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolves a flake8 error which would manifest as a KeyError at runtime when this exception is created. Signed-off-by: Steven! Ragnarök --- rclpy/rclpy/exceptions.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rclpy/rclpy/exceptions.py b/rclpy/rclpy/exceptions.py index c4b1baca8..0ecdc6235 100644 --- a/rclpy/rclpy/exceptions.py +++ b/rclpy/rclpy/exceptions.py @@ -71,7 +71,8 @@ class ParameterException(Exception): """Base exception for parameter-related errors.""" def __init__(self, error_msg, parameters, *args): - Exception.__init__(self, '{error_msg}: {parameters}'.format(error_msg, parameters), *args) + Exception.__init__(self, '{error_msg}: {parameters}'.format( + error_msg=error_msg, parameters=parameters), *args) class ParameterNotDeclaredException(ParameterException): From d21672764af4ed4521ff441ec2a0aa4b19e046ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steven!=20Ragnar=C3=B6k?= Date: Fri, 10 Apr 2020 16:10:05 -0400 Subject: [PATCH 2/2] Convert to f-strings per feedback. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Steven! Ragnarök --- rclpy/rclpy/exceptions.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rclpy/rclpy/exceptions.py b/rclpy/rclpy/exceptions.py index 0ecdc6235..3a3bb6a18 100644 --- a/rclpy/rclpy/exceptions.py +++ b/rclpy/rclpy/exceptions.py @@ -71,8 +71,7 @@ class ParameterException(Exception): """Base exception for parameter-related errors.""" def __init__(self, error_msg, parameters, *args): - Exception.__init__(self, '{error_msg}: {parameters}'.format( - error_msg=error_msg, parameters=parameters), *args) + Exception.__init__(self, f'{error_msg}: {parameters}') class ParameterNotDeclaredException(ParameterException):