From 1be7082230bd67aee6d2f1a8442f26fe112a6286 Mon Sep 17 00:00:00 2001 From: Aaron Zuspan Date: Tue, 21 Jan 2025 10:16:30 -0800 Subject: [PATCH] Only get noun if used --- eerepr/html.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/eerepr/html.py b/eerepr/html.py index 95c5f2c..a6700d6 100644 --- a/eerepr/html.py +++ b/eerepr/html.py @@ -55,7 +55,6 @@ def convert_to_html(obj: Any, key: Hashable | None = None) -> str: def list_to_html(obj: list, key: Hashable | None = None) -> str: """Convert a Python list to an HTML
  • element.""" n = len(obj) - noun = "element" if n == 1 else "elements" header = f"{key}: " if key is not None else "" # Skip the expensive stringification for lists that are definitely too long to @@ -65,7 +64,7 @@ def list_to_html(obj: list, key: Hashable | None = None) -> str: if min_length < MAX_INLINE_LENGTH and len(contents := str(obj)) < MAX_INLINE_LENGTH: header += contents else: - header += f"List ({n} {noun})" + header += f"List ({n} {'element' if n == 1 else 'elements'})" children = [convert_to_html(item, key=i) for i, item in enumerate(obj)] return _make_collapsible_li(header, children)