Skip to content

Type-check optional SDK code in CI and allow missing extras locally - #484

Merged
donovanr merged 3 commits into
mainfrom
roryd/bugfix-ty-hook
Oct 16, 2026
Merged

donovanr merged 3 commits into
mainfrom
roryd/bugfix-ty-hook

Conversation

@donovanr

@donovanr donovanr commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Description

CI ran ty check without the clients, litellm, and agents extras, so ty saw their imports as unresolved and type errors in code that uses them never reached CI. Locally, with those extras installed, the pre-commit hook failed on two kinds of diagnostics:

  • unused-type-ignore-comment on the inline # type: ignore[ty:unresolved-import] comments, which are only needed when the package is missing
  • five real type errors that CI never saw, including the invalid-method-override on LiteLLMProvider.get_openai_client

This PR makes ty pass whether or not the extras are installed, and makes CI check against them.

Changes

  • Add agents.** and litellm.** to allowed-unresolved-imports. openai.** and swerex.** were already listed. ty uses the real types when a package is installed and stays quiet when it isn't.
  • Remove 11 inline type: ignore[ty:unresolved-import] comments on agents, litellm, and swerex imports. The allowlist covers them.
  • Install --extra clients --extra litellm --extra agents in the CI type-check step, so CI is the strictest check. The pre-commit hook, make type-check, and scripts/verify.sh are unchanged.
  • Fix the errors the extras exposed:
    • LiteLLMProvider.get_openai_client raises NotImplementedError without a base_url instead of returning None, matching the base class contract. The test is updated to match.
    • FileSpanExporter subclasses TracingExporter, which BatchTraceProcessor requires.
    • The litellm suppress_debug_info assignment and the vLLM Converter.tool_to_openai monkeypatch go through an Any-typed local. Both write to third-party attributes that ty types too narrowly.

No task specs, suites, or scores are affected.

Type of Change

  • Bug fix
  • New task, variant, or suite
  • New feature
  • Breaking change or change to existing results
  • Dependency or image update
  • Documentation update
  • Refactoring (no functional changes)

Validation

uv run --frozen --no-group vllm --extra clients --extra litellm --extra agents ty check src/   # CI configuration
uv run --frozen --no-group vllm ty check src/                                                  # without extras
uv run --frozen ruff check src/ tests/
uv run --frozen ruff format --check src/ tests/
uv run --frozen --no-group vllm pytest tests/ --ignore=tests/integration -q   # 3638 passed, 32 skipped

All run on macOS.

  • uv run ruff check src/ tests/ and uv run ruff format --check src/ tests/
  • uv run ty check src/
  • uv run pytest tests/ --ignore=tests/integration -v
  • Integration tests, if storage, providers, or sandboxes changed
  • New tests added for new behavior

@donovanr
donovanr marked this pull request as ready for review October 15, 2026 22:47
@donovanr
donovanr requested a review from a team as a code owner October 15, 2026 22:47
@donovanr donovanr changed the title Type-check against the same extras locally and in CI Type-check optional SDK code in CI and allow missing extras locally Oct 15, 2026
@donovanr
donovanr merged commit 17a6966 into main Oct 16, 2026
8 checks passed
@donovanr
donovanr deleted the roryd/bugfix-ty-hook branch October 16, 2026 20:46
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.

2 participants