Coverage for lintro / utils / environment / _protocol.py: 100%

8 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2026-04-03 18:53 +0000

1"""Protocol for renderable environment sections.""" 

2 

3from __future__ import annotations 

4 

5from typing import Protocol, runtime_checkable 

6 

7 

8@runtime_checkable 

9class Renderable(Protocol): 

10 """Protocol for environment sections that can render themselves. 

11 

12 This protocol defines the contract for rendering environment info 

13 to Rich console output. All environment dataclasses implement this. 

14 """ 

15 

16 @property 

17 def section_title(self) -> str: 

18 """Return the section title for display (e.g., 'Python').""" 

19 ... 

20 

21 def to_display_rows(self) -> list[tuple[str, str]]: 

22 """Return label-value pairs for rendering. 

23 

24 Returns: 

25 List of (label, value) tuples. Values can include Rich markup. 

26 """ 

27 ... 

28 

29 def is_available(self) -> bool: 

30 """Return whether this section has data to display. 

31 

32 For optional sections (Node, Rust, Go, Ruby), this returns False 

33 when the runtime is not installed. For required sections, always True. 

34 """ 

35 ...