Get files that exist in cpython/Lib but not in our Lib. Excludes files that belong to tracked modules (shown in library todo) and hard_deps of those modules. Includes all file types (.py, .txt, .pem, .json, etc.) Returns: Sorted list of relative paths (e.g., ["foo.py", "dat
(
cpython_prefix: str,
lib_prefix: str,
)
| 162 | |
| 163 | |
| 164 | def get_untracked_files( |
| 165 | cpython_prefix: str, |
| 166 | lib_prefix: str, |
| 167 | ) -> list[str]: |
| 168 | """Get files that exist in cpython/Lib but not in our Lib. |
| 169 | |
| 170 | Excludes files that belong to tracked modules (shown in library todo) |
| 171 | and hard_deps of those modules. |
| 172 | Includes all file types (.py, .txt, .pem, .json, etc.) |
| 173 | |
| 174 | Returns: |
| 175 | Sorted list of relative paths (e.g., ["foo.py", "data/file.txt"]) |
| 176 | """ |
| 177 | from update_lib.cmd_deps import get_all_modules |
| 178 | from update_lib.deps import resolve_hard_dep_parent |
| 179 | |
| 180 | cpython_lib = pathlib.Path(cpython_prefix) / "Lib" |
| 181 | local_lib = pathlib.Path(lib_prefix) |
| 182 | |
| 183 | if not cpython_lib.exists(): |
| 184 | return [] |
| 185 | |
| 186 | # Get tracked modules (shown in library todo) |
| 187 | tracked_modules = set(get_all_modules(cpython_prefix)) |
| 188 | |
| 189 | untracked = [] |
| 190 | |
| 191 | for cpython_file in cpython_lib.rglob("*"): |
| 192 | # Skip directories |
| 193 | if cpython_file.is_dir(): |
| 194 | continue |
| 195 | |
| 196 | # Get relative path from Lib/ |
| 197 | rel_path = cpython_file.relative_to(cpython_lib) |
| 198 | |
| 199 | # Skip test/ directory (handled separately by test todo) |
| 200 | if rel_path.parts and rel_path.parts[0] == "test": |
| 201 | continue |
| 202 | |
| 203 | # Check if file belongs to a tracked module |
| 204 | # e.g., idlelib/Icons/idle.gif -> module "idlelib" |
| 205 | # e.g., foo.py -> module "foo" |
| 206 | first_part = rel_path.parts[0] |
| 207 | if first_part.endswith(".py"): |
| 208 | module_name = first_part[:-3] # Remove .py |
| 209 | else: |
| 210 | module_name = first_part |
| 211 | |
| 212 | if module_name in tracked_modules: |
| 213 | continue |
| 214 | |
| 215 | # Check if this is a hard_dep of a tracked module |
| 216 | if resolve_hard_dep_parent(module_name, cpython_prefix) is not None: |
| 217 | continue |
| 218 | |
| 219 | # Check if exists in local lib |
| 220 | local_file = local_lib / rel_path |
| 221 | if not local_file.exists(): |
no test coverage detected