MCPcopy Index your code
hub / github.com/RustPython/RustPython / compute_todo_list

Function compute_todo_list

scripts/update_lib/cmd_todo.py:26–133  ·  view source on GitHub ↗

Compute prioritized list of modules to update. Scoring: - Modules with no pylib dependencies: score = -1 - Modules with pylib dependencies: score = count of NOT up-to-date deps Sorting (ascending by score): 1. More reverse dependencies (modules depending on this) =

(
    cpython_prefix: str,
    lib_prefix: str,
    include_done: bool = False,
)

Source from the content-addressed store, hash-verified

24
25
26def compute_todo_list(
27 cpython_prefix: str,
28 lib_prefix: str,
29 include_done: bool = False,
30) -> list[dict]:
31 """Compute prioritized list of modules to update.
32
33 Scoring:
34 - Modules with no pylib dependencies: score = -1
35 - Modules with pylib dependencies: score = count of NOT up-to-date deps
36
37 Sorting (ascending by score):
38 1. More reverse dependencies (modules depending on this) = higher priority
39 2. Fewer native dependencies = higher priority
40
41 Returns:
42 List of dicts with module info, sorted by priority
43 """
44 from update_lib.cmd_deps import get_all_modules
45 from update_lib.deps import (
46 get_all_hard_deps,
47 get_rust_deps,
48 get_soft_deps,
49 is_up_to_date,
50 )
51
52 all_modules = get_all_modules(cpython_prefix)
53
54 # Build dependency data for all modules
55 module_data = {}
56 for name in all_modules:
57 soft_deps = get_soft_deps(name, cpython_prefix)
58 native_deps = get_rust_deps(name, cpython_prefix)
59 up_to_date = is_up_to_date(name, cpython_prefix, lib_prefix)
60
61 # Get hard_deps and check their status
62 hard_deps = get_all_hard_deps(name, cpython_prefix)
63 hard_deps_status = {
64 hd: is_up_to_date(hd, cpython_prefix, lib_prefix) for hd in hard_deps
65 }
66
67 module_data[name] = {
68 "name": name,
69 "soft_deps": soft_deps,
70 "native_deps": native_deps,
71 "up_to_date": up_to_date,
72 "hard_deps_status": hard_deps_status,
73 }
74
75 # Build reverse dependency map: who depends on this module
76 reverse_deps: dict[str, set[str]] = {name: set() for name in all_modules}
77 for name, data in module_data.items():
78 for dep in data["soft_deps"]:
79 if dep in reverse_deps:
80 reverse_deps[dep].add(name)
81
82 # Compute scores and filter
83 result = []

Callers 1

format_all_todoFunction · 0.85

Calls 14

get_all_modulesFunction · 0.90
get_soft_depsFunction · 0.90
get_rust_depsFunction · 0.90
is_up_to_dateFunction · 0.90
get_all_hard_depsFunction · 0.90
setFunction · 0.85
lenFunction · 0.85
anyFunction · 0.50
sumFunction · 0.50
itemsMethod · 0.45
addMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected