From 8dfc3470e88c670ebcb5c7ff304bde43445bc00b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel=20Gonz=C3=A1lez=20Santamarta?= Date: Sun, 3 Nov 2024 22:41:42 +0100 Subject: [PATCH] setting black formatter line length to 90 --- .github/workflows/python_formatter.yml | 2 +- yasmin/yasmin/state_machine.py | 4 +--- yasmin_demos/yasmin_demos/action_client_demo.py | 4 +--- yasmin_ros/yasmin_ros/action_state.py | 6 +++--- yasmin_ros/yasmin_ros/monitor_state.py | 2 +- yasmin_ros/yasmin_ros/service_state.py | 12 ++++-------- yasmin_viewer/yasmin_viewer/yasmin_viewer_node.py | 4 +--- 7 files changed, 12 insertions(+), 22 deletions(-) diff --git a/.github/workflows/python_formatter.yml b/.github/workflows/python_formatter.yml index 4cc17cf..f1332df 100644 --- a/.github/workflows/python_formatter.yml +++ b/.github/workflows/python_formatter.yml @@ -12,4 +12,4 @@ jobs: - name: Black Formatter uses: lgeiger/black-action@master with: - args: ". --check --diff" + args: ". --check --diff --line-length 90" diff --git a/yasmin/yasmin/state_machine.py b/yasmin/yasmin/state_machine.py index 8351bca..82f0ce6 100644 --- a/yasmin/yasmin/state_machine.py +++ b/yasmin/yasmin/state_machine.py @@ -393,9 +393,7 @@ def execute(self, blackboard: Blackboard) -> str: f"Outcome '{outcome}' is not a state nor a state machine outcome" ) - raise RuntimeError( - f"Ending canceled state machine '{self}' with bad transition" - ) + raise RuntimeError(f"Ending canceled state machine '{self}' with bad transition") def cancel_state(self) -> None: """ diff --git a/yasmin_demos/yasmin_demos/action_client_demo.py b/yasmin_demos/yasmin_demos/action_client_demo.py index d1dc7b3..c3b38dc 100755 --- a/yasmin_demos/yasmin_demos/action_client_demo.py +++ b/yasmin_demos/yasmin_demos/action_client_demo.py @@ -80,9 +80,7 @@ def create_goal_handler(self, blackboard: Blackboard) -> Fibonacci.Goal: goal.order = blackboard["n"] # Retrieve the input value 'n' from the blackboard return goal - def response_handler( - self, blackboard: Blackboard, response: Fibonacci.Result - ) -> str: + def response_handler(self, blackboard: Blackboard, response: Fibonacci.Result) -> str: """ Handles the response from the Fibonacci action. diff --git a/yasmin_ros/yasmin_ros/action_state.py b/yasmin_ros/yasmin_ros/action_state.py index 57a385d..65fef3a 100644 --- a/yasmin_ros/yasmin_ros/action_state.py +++ b/yasmin_ros/yasmin_ros/action_state.py @@ -70,10 +70,10 @@ def __init__( Parameters: action_type (Type): The type of the action to be executed. action_name (str): The name of the action to be executed. - create_goal_handler (Callable): A function that generates the goal. + create_goal_handler (Callable[[Blackboard], Any])): A function that generates the goal. outcomes (Set[str], optional): Additional outcomes that this state can return. - result_handler (Callable, optional): A function to process the result of the action. - feedback_handler (Callable, optional): A function to process feedback from the action. + result_handler (Callable[[Blackboard, Any], str], optional): A function to process the result of the action. + feedback_handler (Callable[[Blackboard, Any], None], optional): A function to process feedback from the action. node (Node, optional): The ROS 2 node to use. If None, uses the default YasminNode. timeout (float, optional): Timeout duration for waiting for the action server. diff --git a/yasmin_ros/yasmin_ros/monitor_state.py b/yasmin_ros/yasmin_ros/monitor_state.py index 0b72f4a..b8f0422 100644 --- a/yasmin_ros/yasmin_ros/monitor_state.py +++ b/yasmin_ros/yasmin_ros/monitor_state.py @@ -63,7 +63,7 @@ def __init__( msg_type (Type): The type of message to be monitored. topic_name (str): The name of the topic to subscribe to. outcomes (Set[str]): The set of possible outcomes from the state. - monitor_handler (Callable): The function to call with the received messages. + monitor_handler (Callable[[Blackboard, Any], None]): The function to call with the received messages. qos (Union[QoSProfile, int], optional): Quality of Service profile or depth. msg_queue (int, optional): Maximum number of messages to store. Default is 10. node (Node, optional): The ROS node to use. If None, a default node is created. diff --git a/yasmin_ros/yasmin_ros/service_state.py b/yasmin_ros/yasmin_ros/service_state.py index dd34f0a..28e9100 100644 --- a/yasmin_ros/yasmin_ros/service_state.py +++ b/yasmin_ros/yasmin_ros/service_state.py @@ -57,9 +57,9 @@ def __init__( Parameters: srv_type (Type): The type of the service. srv_name (str): The name of the service to be called. - create_request_handler (Callable): A handler to create the request based on the blackboard data. + create_request_handler (Callable[[Blackboard], Any]): A handler to create the request based on the blackboard data. outcomes (Set[str], optional): A set of additional outcomes for this state. - response_handler (Callable, optional): A handler to process the service response. + response_handler (Callable[[Blackboard, Any], str], optional): A handler to process the service response. node (Node, optional): A ROS node instance; if None, a default instance is used. timeout (float, optional): Timeout duration for waiting on the service. @@ -68,9 +68,7 @@ def __init__( """ ## A function that creates the service request. - self._create_request_handler: Callable[[Blackboard], Any] = ( - create_request_handler - ) + self._create_request_handler: Callable[[Blackboard], Any] = create_request_handler ## A function that processes the service response. self._response_handler: Callable[[Blackboard, Any], str] = response_handler @@ -132,9 +130,7 @@ def execute(self, blackboard: Blackboard) -> str: return TIMEOUT try: - self._node.get_logger().info( - f"Sending request to service '{self._srv_name}'" - ) + self._node.get_logger().info(f"Sending request to service '{self._srv_name}'") response = self._service_client.call(request) except Exception as e: diff --git a/yasmin_viewer/yasmin_viewer/yasmin_viewer_node.py b/yasmin_viewer/yasmin_viewer/yasmin_viewer_node.py index e36873e..d2405ea 100644 --- a/yasmin_viewer/yasmin_viewer/yasmin_viewer_node.py +++ b/yasmin_viewer/yasmin_viewer/yasmin_viewer_node.py @@ -95,9 +95,7 @@ def start_backend_server(self) -> None: """ app = Flask( "yasmin_viewer", - static_folder=ament_index_python.get_package_share_directory( - "yasmin_viewer" - ) + static_folder=ament_index_python.get_package_share_directory("yasmin_viewer") + "/yasmin_viewer_web_client", static_url_path="/", )