You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "uranusjr (via GitHub)" <gi...@apache.org> on 2023/08/10 07:12:00 UTC

[GitHub] [airflow] uranusjr commented on a diff in pull request #33268: Refactor: Simplify code in utils

uranusjr commented on code in PR #33268:
URL: https://github.com/apache/airflow/pull/33268#discussion_r1289660793


##########
airflow/utils/log/file_task_handler.py:
##########
@@ -492,11 +492,11 @@ def _init_file(self, ti):
     def _read_from_local(worker_log_path: Path) -> tuple[list[str], list[str]]:
         messages = []
         logs = []
-        files = list(worker_log_path.parent.glob(worker_log_path.name + "*"))
+        files = sorted(worker_log_path.parent.glob(worker_log_path.name + "*"))
         if files:
-            messages.extend(["Found local files:", *[f"  * {x}" for x in sorted(files)]])
-        for file in sorted(files):
-            logs.append(Path(file).read_text())
+            messages.append("Found local files:")
+            messages.extend(f"  * {x}" for x in files)
+        logs = [Path(file).read_text() for file in files]

Review Comment:
   ```suggestion
           logs = [file.read_text() for file in files]
   ```
   
   I believe each entry in `files` (yielded by `Path.glob()`) is already a Path?



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org