(paths: t.Iterable[str])
| 141 | |
| 142 | |
| 143 | def _find_common_roots(paths: t.Iterable[str]) -> t.Iterable[str]: |
| 144 | root: dict[str, dict[str, t.Any]] = {} |
| 145 | |
| 146 | for chunks in sorted((PurePath(x).parts for x in paths), key=len, reverse=True): |
| 147 | node = root |
| 148 | |
| 149 | for chunk in chunks: |
| 150 | node = node.setdefault(chunk, {}) |
| 151 | |
| 152 | node.clear() |
| 153 | |
| 154 | rv = set() |
| 155 | |
| 156 | def _walk(node: t.Mapping[str, dict[str, t.Any]], path: tuple[str, ...]) -> None: |
| 157 | for prefix, child in node.items(): |
| 158 | _walk(child, path + (prefix,)) |
| 159 | |
| 160 | # If there are no more nodes, and a path has been accumulated, add it. |
| 161 | # Path may be empty if the "" entry is in sys.path. |
| 162 | if not node and path: |
| 163 | rv.add(os.path.join(*path)) |
| 164 | |
| 165 | _walk(root, ()) |
| 166 | return rv |
| 167 | |
| 168 | |
| 169 | def _get_args_for_reloading() -> list[str]: |
no test coverage detected