Skip to content

fix(stream): EventSource ignores use_file_output=False#463

Open
devteamaegis wants to merge 1 commit into
replicate:mainfrom
devteamaegis:fix/event-source-use-file-output-false-ignored
Open

fix(stream): EventSource ignores use_file_output=False#463
devteamaegis wants to merge 1 commit into
replicate:mainfrom
devteamaegis:fix/event-source-use-file-output-false-ignored

Conversation

@devteamaegis
Copy link
Copy Markdown

What's broken

EventSource silently ignores use_file_output=False. The constructor assigns the flag with use_file_output or True, but False or True evaluates to True in Python, so the caller's intent is lost:

source = EventSource(client, response, use_file_output=False)
print(source.use_file_output)  # True — should be False

Output tokens are still run through transform_output even when the caller explicitly opted out.

Why it happens

The line self.use_file_output = use_file_output or True is meant to default to True when None is passed, but it clobbers a deliberate False as well since Python's or operator returns the right-hand side for any falsy left-hand side.

Fix

Replace the boolean-or default with an explicit None check:

self.use_file_output = use_file_output if use_file_output is not None else True

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant