Skip to content

fix: resolve CI test-build import NameError for SyncStreamResponse#31

Merged
DarshanHarihar1 merged 1 commit into
mainfrom
cursor/fix-ci-import-nameerror-159e
May 26, 2026
Merged

fix: resolve CI test-build import NameError for SyncStreamResponse#31
DarshanHarihar1 merged 1 commit into
mainfrom
cursor/fix-ci-import-nameerror-159e

Conversation

@DarshanHarihar1
Copy link
Copy Markdown
Contributor

Summary

The Test Build CI job installs the built wheel and runs python -c "import justllms". That step failed on all Python versions because SyncStreamResponse was only imported under TYPE_CHECKING, while BaseProvider.stream() and a Completion.create() overload still used it as a runtime return annotation. Python evaluates those annotations when defining the class, which raised NameError: name 'SyncStreamResponse' is not defined.

Changes

  • justllms/core/base.py: use a string forward reference for the stream() return type ("SyncStreamResponse").
  • justllms/core/completion.py: same for the @overload branch that returns a stream.

Verification

Locally: ruff check justllms/, black --check justllms/, mypy justllms/ --ignore-missing-imports, then python -m build, install dist/*.whl into a clean PYTHONPATH, and import justllms succeeds.

Open in Web Open in Cursor 

TYPE_CHECKING-only imports are not defined at runtime; unquoted return
annotations on BaseProvider.stream and Completion.create overload caused
NameError when loading the installed wheel. CI test-build failed on import.

Use string forward references so annotations are not evaluated eagerly.

Co-authored-by: Darshan Harihar <DarshanHarihar1@users.noreply.github.com>
@DarshanHarihar1 DarshanHarihar1 merged commit f3b770d into main May 26, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants