Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pylint complains when using Stream[ChatCompletionChunk]: E1133 not-an-iterable #870

Closed
1 task done
mroedder-d7 opened this issue Nov 23, 2023 · 1 comment
Closed
1 task done
Labels
question Further information is requested

Comments

@mroedder-d7
Copy link

Confirm this is an issue with the Python library and not an underlying OpenAI API

  • This is an issue with the Python library

Describe the bug

I´m constructing a chat completion response:

query_response: Stream[ChatCompletionChunk] = client.chat.completions.create(
            ...
            stream=True,
        )

Then, when iterating over the chunks, it works but Pylint raises an error:

        for chunk in query_response:
            choice = chunk.choices[0]

Error:
Non-iterable value query_response is used in an iterating context

To Reproduce

  1. Create a chat completion with streaming enabled
  2. Read chunks by iterating over the Stream
  3. Run pylint

Code snippets

No response

OS

macOS

Python version

3.11.5

Library version

1.3.5

@mroedder-d7 mroedder-d7 added the bug Something isn't working label Nov 23, 2023
@mroedder-d7 mroedder-d7 changed the title Pylint complains when using Stream[ChatCompletionChunk]: not-an-iterable Pylint complains when using Stream[ChatCompletionChunk]: E1133 not-an-iterable Nov 23, 2023
@RobertCraigie
Copy link
Collaborator

RobertCraigie commented Nov 23, 2023

Please report an issue with pylint, this class is iterable so there's a bug in their logic.

Personally I'd also recommend just disabling lint rules like this and instead use a type checker, e.g. Pyright, as those pylint rules are essentially just a much more limited version of type checker.

@RobertCraigie RobertCraigie added question Further information is requested and removed bug Something isn't working labels Nov 23, 2023
@RobertCraigie RobertCraigie closed this as not planned Won't fix, can't repro, duplicate, stale Nov 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants