-
Notifications
You must be signed in to change notification settings - Fork 1.4k
type stubs for some third-party libraries #3443
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
base: main
Are you sure you want to change the base?
Conversation
DouweM
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lars20070 Thanks Lars, this is great.
| "stubs/**/*.pyi" = ["F401", "PYI044", "PYI035", "ANN401"] | ||
|
|
||
| [tool.pyright] | ||
| stubPath = "stubs" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we call it type_stubs or something like that to make it more clear what it's about?
| local_dir: str | PathLike[str] | None = None, | ||
| local_dir_use_symlinks: bool | Literal['auto'] = 'auto', | ||
| cache_dir: str | PathLike[str] | None = None, | ||
| **kwargs: Any, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These will inevitably get outdated -- could you add some docs (can just be a readme in this dir) on how you generated them, how we can validate they're still valid, and how to regenerate/update them?
Problem
The codebase previously relied on
# type: ignoreand# pyright: ignorecomments to suppress type errors from third-party libraries lacking type hints (llama_cpp,mlx,mlx_lm,outlines,transformers, andvllm).make typecheckfailed due to missing type information frommlxandvllm. Both dependencies are absent in the Linux dev container.Solution
This PR introduces type stub files
.pyifor these libraries. Type stubs provide type information to static type checkers without modifying the runtime behavior.SamplingParamsfromvllm.uv run stubgentarget inMakefile. But this generates all stubs and not merely the ones used in the codebase. More thoughts here.make typechecknow passes successfully in the Linux dev containerAdded
stubs/directory containing type stub files forllama_cpp,mlx,mlx_lm,outlines,transformersandvllm.pyproject.tomlto configure stub search paths forpyrightandmypyChanged
outlines-mlxlmhas been updated in bothpyproject.tomlfiles.uv.lockfile has been updated to reflect these dependency changes.Removed
# pyright: ignoreand# type: ignorecomments fromoutlines.pyandtest_outlines.py.