Acknowledge Tkinter's GC-reference idiom with a scoped type ignore

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.
This commit is contained in:
Mark Backman
2026-04-22 12:19:16 -04:00
parent ec7c35fe98
commit b0962861c8
2 changed files with 1 additions and 2 deletions

View File

@@ -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",

View File

@@ -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):