Coverage for lintro / formatters / styles / plain.py: 100%
14 statements
« prev ^ index » next coverage.py v7.13.0, created at 2026-04-03 18:53 +0000
« prev ^ index » next coverage.py v7.13.0, created at 2026-04-03 18:53 +0000
1"""Plain text output style implementation."""
3from typing import Any
5from lintro.formatters.core.format_registry import OutputStyle
8class PlainStyle(OutputStyle):
9 """Output format that renders data as plain text."""
11 def format(
12 self,
13 columns: list[str],
14 rows: list[list[Any]],
15 tool_name: str | None = None,
16 **kwargs: Any,
17 ) -> str:
18 """Format a table given columns and rows as plain text.
20 Args:
21 columns: List of column header names.
22 rows: List of row values (each row is a list of cell values).
23 tool_name: Optional tool name to include in context.
24 **kwargs: Extra options ignored by this formatter.
26 Returns:
27 Formatted data as plain text string.
28 """
29 if not rows:
30 return "No issues found."
32 # Build the header
33 header = " | ".join(columns)
34 separator = "-" * len(header)
36 # Build the rows
37 formatted_rows = []
38 for row in rows:
39 # Ensure row has same number of elements as columns
40 padded_row = row + [""] * (len(columns) - len(row))
41 formatted_rows.append(" | ".join(str(cell) for cell in padded_row))
43 # Combine all parts
44 result = [header, separator] + formatted_rows
45 return "\n".join(result)