MCPcopy Index your code
hub / github.com/DeepLabCut/DeepLabCut / explain_changed_files

Function explain_changed_files

tools/test_selector.py:519–584  ·  view source on GitHub ↗

Build an explanation structure for reporting: - per-file: full_trigger_matches, category_matches - grouped: full_triggers, by_category, uncategorized

(files: list[str])

Source from the content-addressed store, hash-verified

517# Outputs
518# -----------------------------
519def explain_changed_files(files: list[str]) -> dict[str, Any]:
520 """
521 Build an explanation structure for reporting:
522 - per-file: full_trigger_matches, category_matches
523 - grouped: full_triggers, by_category, uncategorized
524 """
525 per_file: dict[str, dict[str, Any]] = {}
526 by_category: dict[str, list[str]] = defaultdict(list)
527 full_trigger_files: dict[str, list[str]] = defaultdict(list)
528 lint_only_files: list[str] = []
529 uncategorized: list[str] = []
530
531 # Prep category predicates
532 categories = [(r.name, r.match_any) for r in CATEGORY_RULES]
533
534 for f in files:
535 # Which full-suite triggers does this file match?
536 ft = []
537 for trig_name, pred in FULL_SUITE_TRIGGERS:
538 try:
539 if pred(f):
540 ft.append(trig_name)
541 except Exception:
542 continue
543
544 # Which categories does it match?
545 cats = []
546 for cat_name, preds in categories:
547 if _matches_any(f, preds):
548 cats.append(cat_name)
549 is_lint_only = f in LINT_ONLY_FILES
550
551 per_file[f] = {
552 "full_triggers": ft,
553 "categories": cats,
554 "lint_only": is_lint_only,
555 }
556
557 if ft:
558 for t in ft:
559 full_trigger_files[t].append(f)
560
561 if cats:
562 for c in cats:
563 by_category[c].append(f)
564
565 if is_lint_only:
566 lint_only_files.append(f)
567 else:
568 # Only uncategorized if it matched no categories AND no full-suite triggers
569 if not ft and not cats:
570 uncategorized.append(f)
571
572 # Deterministic ordering
573 for t in full_trigger_files:
574 full_trigger_files[t] = sorted(set(full_trigger_files[t]))
575 for c in by_category:
576 by_category[c] = sorted(set(by_category[c]))

Callers 1

Calls 1

_matches_anyFunction · 0.85

Tested by

no test coverage detected