Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@lars20070
Copy link
Contributor

@lars20070 lars20070 commented Nov 16, 2025

Problem

The codebase previously relied on # type: ignore and # pyright: ignore comments to suppress type errors from third-party libraries lacking type hints (llama_cpp, mlx, mlx_lm, outlines, transformers, and vllm).

  • Reduced code clarity: Type ignore comments obscure the intended types, making it harder to understand the expected interfaces
  • Maintenance burden: Suppressed type errors can hide real issues when APIs change
  • Failed type checking: In the Linux dev container, make typecheck failed due to missing type information from mlx and vllm. Both dependencies are absent in the Linux dev container.

Solution

This PR introduces type stub files .pyi for these libraries. Type stubs provide type information to static type checkers without modifying the runtime behavior.

  • Created stub files mirroring the original library APIs (only type annotations, no functional code)
  • Type information sourced from upstream library implementations. For example, SamplingParams from vllm.
  • Stubbed only the APIs actively used in the codebase to minimize maintenance overhead
    Alternatively, I can add automation with a uv run stubgen target in Makefile.
  • make typecheck now passes successfully in the Linux dev container

Added

  • New stubs/ directory containing type stub files for llama_cpp, mlx, mlx_lm, outlines, transformers and vllm.
  • Updated pyproject.toml to configure stub search paths for pyright and mypy

Changed

  • The Apple Silicon dependency condition for outlines-mlxlm has been updated in both pyproject.toml files.
  • The uv.lock file has been updated to reflect these dependency changes.

Removed

  • # pyright: ignore and # type: ignore comments from outlines.py and test_outlines.py.

@lars20070 lars20070 marked this pull request as draft November 16, 2025 12:01
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