Skip to content

Commit

Permalink
Only get noun if used
Browse files Browse the repository at this point in the history
  • Loading branch information
aazuspan committed Jan 21, 2025
1 parent de03fe8 commit 1be7082
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions eerepr/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <li> 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
Expand All @@ -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)
Expand Down

0 comments on commit 1be7082

Please sign in to comment.