Skip to content

Commit 626ae19

Browse files
committed
Fix: fix linter error
1 parent 2c6903f commit 626ae19

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

PWGCF/Femto/Macros/cutculator_gui.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -409,10 +409,12 @@ def _on_hist_selected(self, _e=None):
409409

410410
if is_filter:
411411
# 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)
412+
# is True. This check narrows `parsed` from the dict|list union the
413+
# type checker infers from the function's two return shapes (same
414+
# purpose an assert would serve, but unlike assert this is never
415+
# stripped out under python -O, so it stays a real runtime guard).
416+
if not isinstance(parsed, list):
417+
raise TypeError("load_bins_from_hist() must return a list of bin dicts when is_filter is True")
416418
self._filter_bins = parsed
417419
self._groups = {}
418420
self._build_legend_filter()
@@ -422,7 +424,8 @@ def _on_hist_selected(self, _e=None):
422424
else:
423425
# load_bins_from_hist returns a dict of SelectionName -> bins when
424426
# is_filter is False; same narrowing purpose as above.
425-
assert isinstance(parsed, dict)
427+
if not isinstance(parsed, dict):
428+
raise TypeError("load_bins_from_hist() must return a dict of bins when is_filter is False")
426429
self._groups = parsed
427430
self._filter_bins = []
428431
self._build_legend_selection()

0 commit comments

Comments
 (0)