Skip to content

fix: handle bare iterator output annotations - #5684

Open
nightcityblade wants to merge 1 commit into
bentoml:mainfrom
nightcityblade:fix/issue-5625
Open

fix: handle bare iterator output annotations#5684
nightcityblade wants to merge 1 commit into
bentoml:mainfrom
nightcityblade:fix/issue-5625

Conversation

@nightcityblade

Copy link
Copy Markdown

What does this PR address?

Bare iterator and generator return annotations have no type arguments, so indexing get_args() raised IndexError during output-spec inference. This change falls back to Any, matching the existing behavior for an omitted return annotation, and adds regression coverage for all sync and async iterator/generator variants from both typing and collections.abc.

Tests:

  • .venv/bin/pytest tests/unit/_bentoml_sdk/test_io_models.py -q (8 passed)
  • .venv/bin/pytest tests/unit/bentoml_io/test_decorators.py -q (8 passed)
  • .venv/bin/pre-commit run --all-files (passed; Buf hooks skipped because no matching files changed)

Fixes #5625

Before submitting:

  • Does the Pull Request follow Conventional Commits specification naming?
  • Does the code follow BentoML's code style, pre-commit run -a script has passed?
  • Did you read through contribution guidelines and follow development guidelines?
  • Did your changes require updates to the documentation? N/A; this only prevents an inference crash and does not change the public API.
  • Did you write tests to cover your changes?

@nightcityblade
nightcityblade requested a review from a team as a code owner August 5, 2026 15:27
@nightcityblade
nightcityblade requested review from bojiang and removed request for a team August 5, 2026 15:27
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.

BUG: IndexError in IODescriptor.from_output() with bare (unparameterized) iterator return annotations

1 participant