Return the lone module directory under a ``src/`` layout directory. Args: src: The ``src`` directory of a package. Returns: The single child directory (the importable package). Raises: ValueError: If ``src`` does not contain exactly one child directory.
(src: Path)
| 163 | |
| 164 | |
| 165 | def _single_source_dir(src: Path) -> Path: |
| 166 | """Return the lone module directory under a ``src/`` layout directory. |
| 167 | |
| 168 | Args: |
| 169 | src: The ``src`` directory of a package. |
| 170 | |
| 171 | Returns: |
| 172 | The single child directory (the importable package). |
| 173 | |
| 174 | Raises: |
| 175 | ValueError: If ``src`` does not contain exactly one child directory. |
| 176 | """ |
| 177 | children = [child for child in src.iterdir() if child.is_dir()] |
| 178 | if len(children) != 1: |
| 179 | msg = f"expected exactly one module directory under {src}, found {children}" |
| 180 | raise ValueError(msg) |
| 181 | return children[0] |
| 182 | |
| 183 | |
| 184 | def _workspace_pyprojects() -> Iterator[tuple[str, Path]]: |