class_docstr: Creates string representations of objects useful for logging / snapshots.
class_docstr_tok: ["Creates","string","representations","of","objects","useful","for","logging","\/","snapshots","."]
docstr: Pretty prints a sequence object i.e. list or tuple.
  
  Args:
      list_like_obj: A list or a tuple.
      remaining_line_width: If specified, try to make the string representation <= this many columns wide.
  
  Returns:
      A string representation of the sequence like (1,) or [1, 2].
docstr_tok: ["Pretty","prints","a","sequence","object","i.e",".","list","or","tuple",".","Args",":","list_like_obj",":","A","list","or","a","tuple",".","remaining_line_width",":","If","specified",",","try","to","make","the","string","representation","<","=","this","many","columns","wide",".","Returns",":","A","string","representation","of","the","sequence","like","(","1",",",")","or","[","1",",","2","]","."]
code: def _handle_sequence_obj(
      self,
      list_like_obj: Union[list, tuple],
      remaining_line_width: Optional[int],
  ) -> str:
      """Pretty prints a sequence object i.e. list or tuple.
  
      Args:
          list_like_obj: A list or a tuple.
          remaining_line_width: If specified, try to make the string representation <= this many columns wide.
  
      Returns:
          A string representation of the sequence like (1,) or [1, 2].
      """
      if isinstance(list_like_obj, list):
          left_enclose_str = "["
          right_enclose_str = "]"
      elif isinstance(list_like_obj, tuple):
          left_enclose_str = "("
          right_enclose_str = ")"
      else:
          raise RuntimeError(f"Unhandled type: {type(list_like_obj)}")
  
      if len(list_like_obj) == 0:
          return f"{left_enclose_str}{right_enclose_str}"
  
      # See if this object can be printed in one line.
      items_as_str = tuple(
          self._handle_any_obj(list_item, remaining_line_width=None)
          for list_item in list_like_obj
      )
      line_items = [left_enclose_str]
      if len(items_as_str) > 0:
          line_items.extend([", ".join(items_as_str)])
          if len(items_as_str) == 1:
              line_items.append(",")
      line_items.append(right_enclose_str)
      result_without_width_limit = "".join(line_items)
  
      if (
          remaining_line_width is None
          or len(result_without_width_limit) <= remaining_line_width
      ):
          return result_without_width_limit
  
      # The item can't be printed on one line, so do an indented style like:
      """
          [
              1,
              2,
              ...
          ]
          """
  
      # Convert each item to a pretty string.
      items_as_str = tuple(
          self._handle_any_obj(
              list_item,
              remaining_line_width=max(
                  0, remaining_line_width - len(self._indent_prefix)
              ),
          )
          for list_item in list_like_obj
      )
      lines = [left_enclose_str]
  
      # item_block is similar to
      """
          1,
          2,
          3,
          """
  
      item_block = ",\n".join(items_as_str) + ","
      # Indent the item_block
      if len(item_block) > 0:
          lines.append(
              indent(item_block, indent_prefix=self._indent_prefix)
          )
      lines.append(right_enclose_str)
      return "\n".join(lines)
  
file_path: metricflow/metricflow/mf_logging/pretty_print.py
imports: from __future__ import annotations
  import logging
  import pprint
  from collections.abc import Mapping
  from dataclasses import fields, is_dataclass
  from enum import Enum
  from typing import Any, Dict, List, Optional, Sized, Union
  from pydantic import BaseModel
  from metricflow.mf_logging.formatting import indent
label_desc: Use image node_id 3 for calling the MetricFlowPrettyFormatter obj's underlying member method code with example usage: obj._handle_sequence_obj(list_like_obj, remaining_line_width) and returns: str, left_enclose_str, right_enclose_str, result_without_width_limit