Coverage for custom_components/dev_shell_server/paths.py: 100%

6 statements  

« prev     ^ index     » next       coverage.py v7.15.4, created at 2026-10-03 09:02 +0000

1"""Parsing for the object tree's "/integration/domain/object_id" paths. 

2 

3Deliberately free of Home Assistant imports so it can be tested standalone, 

4same as session.py. 

5""" 

6 

7from __future__ import annotations 

8 

9 

10def parse_path(path: str) -> tuple[str, ...]: 

11 """Split "/integration[/domain[/object_id]]" into 1-3 parts. 

12 

13 A path may name just an integration, an integration and domain, or go all 

14 the way down to an object_id - each is a valid, progressively narrower 

15 position in the object tree. Raises ValueError (with a message fit to show 

16 the user directly) if path has no segments or more than three. 

17 """ 

18 parts = tuple(p for p in path.split("/") if p) 

19 if not parts or len(parts) > 3: 

20 raise ValueError(f"{path!r} - expected /integration/domain/object_id") 

21 return parts