Taragolis commented on code in PR #39464:
URL: https://github.com/apache/airflow/pull/39464#discussion_r1592797003


##########
airflow/providers/docker/operators/docker_swarm.py:
##########
@@ -225,6 +231,24 @@ def stream_new_logs(last_line_logged, since=0):
             sleep(2)
             last_line_logged, last_timestamp = 
stream_new_logs(last_line_logged, since=last_timestamp)
 
+    @staticmethod
+    def format_args(args: list[str] | str | None) -> list[str] | None:
+        """Retrieve args.
+
+        The args string is parsed to a list. If it starts with ``[``,
+        the string is treated as a Python literal and parsed into a list.
+
+        :param args: args to the docker service
+
+        :return: the args as list
+        """
+        if isinstance(args, str):
+            if args.strip().startswith("["):
+                return ast.literal_eval(args)
+            else:
+                return shlex.split(args)
+        return args

Review Comment:
   Just wondering why it might required to parse it via `ast.literal_eval `, 
and not via `json.loads`. And why it is required to parse it? Maybe you could 
provide some real use cases?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to