From 42cace9e4d7e81b3edf21b06ae9e78515bd7e412 Mon Sep 17 00:00:00 2001 From: Shinichi Hemmi <50256998+Alnusjaponica@users.noreply.github.com> Date: Thu, 2 Nov 2023 10:37:17 +0900 Subject: [PATCH] Replace "\n" with os.linesep --- optuna/cli.py | 12 ++++++------ tests/test_cli.py | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/optuna/cli.py b/optuna/cli.py index d9bd5b1d24..2d753bdf77 100644 --- a/optuna/cli.py +++ b/optuna/cli.py @@ -193,7 +193,7 @@ def _dump_value(records: List[Dict[str, Any]], header: List[str]) -> str: for column_name in header: row.append(str(record.get(column_name, ""))) values.append(" ".join(row)) - return "\n".join(values) + return os.linesep.join(values) def _dump_table(records: List[Dict[str, Any]], header: List[str]) -> str: @@ -223,11 +223,11 @@ def _dump_table(records: List[Dict[str, Any]], header: List[str]) -> str: rows_string[i] += " " + row[column].get_string(value_type, max_width) + " |" ret = "" - ret += separator + "\n" - ret += header_string + "\n" - ret += separator + "\n" - ret += "\n".join(rows_string) + "\n" - ret += separator + "\n" + ret += separator + os.linesep + ret += header_string + os.linesep + ret += separator + os.linesep + ret += os.linesep.join(rows_string) + os.linesep + ret += separator + os.linesep return ret diff --git a/tests/test_cli.py b/tests/test_cli.py index 4764ce53e8..dec66e166d 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -74,9 +74,9 @@ def _parse_output(output: str, output_format: str) -> Any: if output_format == "value": # Currently, _parse_output with output_format="value" is used only for # `study-names` command. - return [{"name": values} for values in output.split("\n")] + return [{"name": values} for values in output.split(os.linesep)] elif output_format == "table": - rows = output.split("\n") + rows = output.split(os.linesep) assert all(len(rows[0]) == len(row) for row in rows) # Check ruled lines. assert rows[0] == rows[2] == rows[-1]