|
19 | 19 | import tkinter as tk |
20 | 20 | from tkinter import ttk, filedialog, messagebox |
21 | 21 | import argparse |
| 22 | +from typing import Any, Dict, List |
22 | 23 |
|
23 | 24 | try: |
24 | 25 | import ROOT |
@@ -167,8 +168,8 @@ def __init__(self, rootfile=None, tdir="femto-producer"): |
167 | 168 | self._tdir_path = tdir |
168 | 169 | self._root_file = None |
169 | 170 | self._hist = None |
170 | | - self._groups = {} # SelectionName → list[bin_dict] |
171 | | - self._filter_bins = [] # list[bin_dict], used when the histogram is a filter histogram |
| 171 | + self._groups: Dict[str, List[Dict[str, Any]]] = {} # SelectionName → list[bin_dict] |
| 172 | + self._filter_bins: List[Dict[str, Any]] = [] # list[bin_dict], used when the histogram is a filter histogram |
172 | 173 | self._is_filter_hist = False |
173 | 174 | self._vars = {} # (SelectionName, idx) → BooleanVar |
174 | 175 | self._check_labels = {} # (SelectionName, idx) → Label (custom checkbox glyph) |
@@ -407,13 +408,21 @@ def _on_hist_selected(self, _e=None): |
407 | 408 | self._is_filter_hist = is_filter |
408 | 409 |
|
409 | 410 | if is_filter: |
| 411 | + # load_bins_from_hist returns a flat list of bin dicts when is_filter |
| 412 | + # is True; the assert lets the type checker narrow `parsed` from the |
| 413 | + # dict|list union it infers from the function's two return shapes, |
| 414 | + # instead of leaving self._groups statically ambiguous. |
| 415 | + assert isinstance(parsed, list) |
410 | 416 | self._filter_bins = parsed |
411 | 417 | self._groups = {} |
412 | 418 | self._build_legend_filter() |
413 | 419 | self._build_filter_view() |
414 | 420 | self._set_bitmask_bar_visible(False) |
415 | 421 | self._set_summary_visible(False) |
416 | 422 | else: |
| 423 | + # load_bins_from_hist returns a dict of SelectionName -> bins when |
| 424 | + # is_filter is False; same narrowing purpose as above. |
| 425 | + assert isinstance(parsed, dict) |
417 | 426 | self._groups = parsed |
418 | 427 | self._filter_bins = [] |
419 | 428 | self._build_legend_selection() |
@@ -627,7 +636,9 @@ def _build_bin_row(self, parent, sel_name, idx, b, kind): |
627 | 636 | # the alignment: both row types share one widget recipe for their |
628 | 637 | # leading column instead of trying to match a native Checkbutton's |
629 | 638 | # unmeasurable indicator box. |
630 | | - check_lbl = tk.Label(row, text="[ ]", font=FONT_BODY, bg=BG_CARD, fg=FG_DIM, width=CHECK_COL_WIDTH, anchor="w") |
| 639 | + check_lbl = tk.Label( |
| 640 | + row, text="[ ]", font=FONT_BODY, bg=BG_CARD, fg=FG_DIM, width=CHECK_COL_WIDTH, anchor="w" |
| 641 | + ) |
631 | 642 | check_lbl.pack(side="left") |
632 | 643 | self._check_labels[(sel_name, idx)] = check_lbl |
633 | 644 |
|
|
0 commit comments