Skip to content

Commit cc79d63

Browse files
committed
Address comments.
1 parent 42328da commit cc79d63

File tree

1 file changed

+5
-22
lines changed

1 file changed

+5
-22
lines changed

metricflow-semantics/metricflow_semantics/mf_logging/pretty_print.py

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -514,28 +514,11 @@ def _as_one_line(description: Optional[str], str_converted_dict: Dict[str, str],
514514
a: 1
515515
b: 2
516516
"""
517-
if description is not None and "\n" in description:
518-
return None
519-
520-
# Keep track of the total length of the keys and values to see if it can be printed on one line.
521-
total_key_length = 0
522-
total_value_length = 0
523-
524-
for key_str, value_str in str_converted_dict.items():
525-
if "\n" in key_str or "\n" in value_str:
526-
return None
527-
total_key_length += len(key_str)
528-
total_value_length += len(value_str)
517+
items = tuple(f"{key_str}={value_str}" for key_str, value_str in str_converted_dict.items())
518+
value_in_parenthesis = ", ".join(items)
519+
result = f"{description}" + (f" ({value_in_parenthesis})" if len(value_in_parenthesis) > 0 else "")
529520

530-
one_line_length = (
531-
len(description or "") + 1 + 2 + 2 * len(str_converted_dict) + total_key_length + total_value_length
532-
)
533-
if one_line_length > max_line_length:
521+
if "\n" in result or len(result) > max_line_length:
534522
return None
535523

536-
items = tuple(f"{key_str}={value_str}" for key_str, value_str in str_converted_dict.items())
537-
if len(items) == 0:
538-
return description
539-
540-
value_in_parenthesis = ", ".join(items)
541-
return f"{description} ({value_in_parenthesis})"
524+
return result

0 commit comments

Comments
 (0)