Skip to content

Commit 6c4328e

Browse files
FBumannclaude
andcommitted
fix(types): narrow legendgroup set type for mypy
CI mypy 1.x flagged the set comprehension as Set[Any | None] (the truthy filter wasn't narrowing). Rewrite as an explicit loop that adds only truthy strings, dropping the now-stale type: ignore. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 939664f commit 6c4328e

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

xarray_plotly/figures.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,12 @@ def _ensure_legend_visibility(
113113
# keeps its own legend entries instead of being deduped away.
114114
slice_groups: list[set[str]] = []
115115
for sl in trace_slices:
116-
slice_groups.append(
117-
{
118-
getattr(t, "legendgroup", None)
119-
for t in combined.data[sl]
120-
if getattr(t, "legendgroup", None)
121-
} # type: ignore[misc]
122-
)
116+
groups: set[str] = set()
117+
for t in combined.data[sl]:
118+
lg = getattr(t, "legendgroup", None)
119+
if lg:
120+
groups.add(lg)
121+
slice_groups.append(groups)
123122
group_counts: dict[str, int] = defaultdict(int)
124123
for sg in slice_groups:
125124
for g in sg:

0 commit comments

Comments
 (0)