Skip to content

fix: add missing entries to span __slots__#3483

Merged
seratch merged 1 commit into
openai:mainfrom
rmotgi1227:fix/span-data-missing-slots
May 21, 2026
Merged

fix: add missing entries to span __slots__#3483
seratch merged 1 commit into
openai:mainfrom
rmotgi1227:fix/span-data-missing-slots

Conversation

@rmotgi1227
Copy link
Copy Markdown
Contributor

Problem

TranscriptionSpanData and SpeechSpanData both set and read instance attributes that are absent from their __slots__ declarations:

  • TranscriptionSpanData: sets self.input_format (line 338), reads it in export() (line 352) — not in __slots__ (line 322–327)
  • SpeechSpanData: sets self.output_format (line 379), reads it in export() (line 394) — not in __slots__ (line 366)

Because SpanData (the base class) doesn't define __slots__, instances have a __dict__ fallback, so the code works today — but:

  1. The __slots__ declarations are incomplete and misleading
  2. If SpanData ever gains __slots__ = (), both attributes become un-settable and __init__ raises AttributeError immediately
  3. Any reflection-based code (e.g. vars(span), serializers walking __slots__) sees an inconsistent picture

Fix

Add the two missing entries — one line each:

# TranscriptionSpanData
__slots__ = ("input", "input_format", "output", "model", "model_config")

# SpeechSpanData  
__slots__ = ("input", "output", "output_format", "model", "model_config", "first_content_at")

…nd SpeechSpanData __slots__

Both fields are set in __init__ and read in export() but were absent
from __slots__. They silently fell into __dict__ because SpanData has
no __slots__ of its own. If SpanData ever gains __slots__ = (), the
missing entries would become un-settable and __init__ would raise
AttributeError at first use.
@seratch seratch added this to the 0.17.x milestone May 21, 2026
@seratch seratch changed the title add missing input_format and output_format to span __slots__ fix: add missing entries to span __slots__ May 21, 2026
@seratch seratch enabled auto-merge (squash) May 21, 2026 22:03
@seratch seratch merged commit eda7b51 into openai:main May 21, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants