Coverage for lintro / utils / environment / system_info.py: 68%
22 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"""Operating system and shell information."""
3from __future__ import annotations
5from dataclasses import dataclass
8@dataclass
9class SystemInfo:
10 """Operating system and shell information."""
12 os_name: str
13 os_version: str
14 platform_name: str
15 architecture: str
16 shell: str | None
17 terminal: str | None
18 locale: str | None
20 @property
21 def section_title(self) -> str:
22 """Return the section title for display."""
23 return "System"
25 def to_display_rows(self) -> list[tuple[str, str]]:
26 """Return label-value pairs for rendering."""
27 rows: list[tuple[str, str]] = [
28 ("OS", f"{self.platform_name} ({self.os_version})"),
29 ]
30 # Include os_name if it differs from platform_name (provides additional detail)
31 if self.os_name and self.os_name != self.platform_name:
32 rows.append(("OS Name", self.os_name))
33 rows.extend(
34 [
35 ("Architecture", self.architecture),
36 ("Shell", self.shell or "(unknown)"),
37 ("Terminal", self.terminal or "(unknown)"),
38 ("Locale", self.locale or "(not set)"),
39 ],
40 )
41 return rows
43 def is_available(self) -> bool:
44 """Return whether this section has data to display."""
45 return True