Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add --impact-only flag to deps subcommand for test runner integration
Outputs space-separated test names for direct use with python3 -m test:
  python3 -m test $(python3 scripts/update_lib deps sqlite3 --impact-only)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
  • Loading branch information
2 people authored and youknowone committed Jan 22, 2026
commit bf9d2487c366ebdc77439b6abba759ab48299eea
25 changes: 24 additions & 1 deletion scripts/update_lib/show_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,14 @@ def show_deps(
lib_prefix: str = "Lib",
max_depth: int = 10,
show_impact: bool = False,
impact_only: bool = False,
) -> None:
"""Show all dependency information for modules."""
from update_lib.deps import (
consolidate_test_paths,
find_tests_importing_module,
)

# Expand "all" to all module names
expanded_names = []
for name in names:
Expand All @@ -230,6 +236,18 @@ def show_deps(
else:
expanded_names.append(name)

# Handle impact-only mode: output only space-separated test names
if impact_only:
all_tests: set[str] = set()
for name in expanded_names:
impacted = find_tests_importing_module(name, lib_prefix)
test_dir = pathlib.Path(lib_prefix) / "test"
consolidated = consolidate_test_paths(impacted, test_dir)
all_tests.update(consolidated)
if all_tests:
print(" ".join(sorted(all_tests)))
return

# Shared visited set across all modules
visited: set[str] = set()

Expand Down Expand Up @@ -273,11 +291,16 @@ def main(argv: list[str] | None = None) -> int:
action="store_true",
help="Show tests that import this module (reverse dependencies)",
)
parser.add_argument(
"--impact-only",
action="store_true",
help="Output only impact test names, space-separated (for use with python3 -m test)",
)

args = parser.parse_args(argv)

try:
show_deps(args.names, args.cpython, args.lib, args.depth, args.impact)
show_deps(args.names, args.cpython, args.lib, args.depth, args.impact, args.impact_only)
return 0
except Exception as e:
print(f"Error: {e}", file=sys.stderr)
Expand Down