Skip to content

Commit 2c6903f

Browse files
committed
Fix: fix linter error
1 parent 56e0f93 commit 2c6903f

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

PWGCF/Femto/Macros/cutculator_gui.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import tkinter as tk
2020
from tkinter import ttk, filedialog, messagebox
2121
import argparse
22+
from typing import Any, Dict, List
2223

2324
try:
2425
import ROOT
@@ -167,8 +168,8 @@ def __init__(self, rootfile=None, tdir="femto-producer"):
167168
self._tdir_path = tdir
168169
self._root_file = None
169170
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
172173
self._is_filter_hist = False
173174
self._vars = {} # (SelectionName, idx) → BooleanVar
174175
self._check_labels = {} # (SelectionName, idx) → Label (custom checkbox glyph)
@@ -407,13 +408,21 @@ def _on_hist_selected(self, _e=None):
407408
self._is_filter_hist = is_filter
408409

409410
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)
410416
self._filter_bins = parsed
411417
self._groups = {}
412418
self._build_legend_filter()
413419
self._build_filter_view()
414420
self._set_bitmask_bar_visible(False)
415421
self._set_summary_visible(False)
416422
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)
417426
self._groups = parsed
418427
self._filter_bins = []
419428
self._build_legend_selection()
@@ -627,7 +636,9 @@ def _build_bin_row(self, parent, sel_name, idx, b, kind):
627636
# the alignment: both row types share one widget recipe for their
628637
# leading column instead of trying to match a native Checkbutton's
629638
# 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+
)
631642
check_lbl.pack(side="left")
632643
self._check_labels[(sel_name, idx)] = check_lbl
633644

0 commit comments

Comments
 (0)