From b0962861c8f4b544ed39d4b73c841fa74a1ede65 Mon Sep 17 00:00:00 2001 From: Mark Backman Date: Wed, 22 Apr 2026 12:19:16 -0400 Subject: [PATCH] Acknowledge Tkinter's GC-reference idiom with a scoped type ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tkinter's `Label` only stores `PhotoImage` references at the C level, so Python GC eats them unless something on the Python side keeps a reference. The canonical fix is to stash the reference on the widget itself: `label.image = photo`. Tkinter widgets are plain Python objects, so the assignment works at runtime, but the stub declares no `image` attribute (correctly — there isn't one; we're adding it). Narrow the suppression to `# type: ignore[attr-defined]` on the one line. The existing comment above the assignment already documents why. --- pyrightconfig.json | 1 - src/pipecat/transports/local/tk.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/pyrightconfig.json b/pyrightconfig.json index 6dafdcd85..1130ba338 100644 --- a/pyrightconfig.json +++ b/pyrightconfig.json @@ -114,7 +114,6 @@ "src/pipecat/transports/heygen/transport.py", "src/pipecat/transports/lemonslice/transport.py", "src/pipecat/transports/livekit/transport.py", - "src/pipecat/transports/local/tk.py", "src/pipecat/transports/smallwebrtc/connection.py", "src/pipecat/transports/smallwebrtc/request_handler.py", "src/pipecat/transports/smallwebrtc/transport.py", diff --git a/src/pipecat/transports/local/tk.py b/src/pipecat/transports/local/tk.py index a11f4f277..be9d6db1c 100644 --- a/src/pipecat/transports/local/tk.py +++ b/src/pipecat/transports/local/tk.py @@ -228,7 +228,7 @@ class TkOutputTransport(BaseOutputTransport): # This holds a reference to the photo, preventing it from being garbage # collected. - self._image_label.image = photo + self._image_label.image = photo # type: ignore[attr-defined] class TkLocalTransport(BaseTransport):