Open wangkuiyi opened 4 months ago
I want to use mypy --strict to check my code that depends on MLX. However, the stub generated by pybind11-stubgen at https://github.com/ml-explore/mlx/blob/3b661b73943c8b91d45bdf55da670e8cb308c2a8/setup.py#L137C26-L137C42 does not include accurate type annotation.
mypy --strict
pybind11-stubgen
In the file ~/miniforge3/envs/mlx-medusa-plus/lib/python3.10/site-packages/mlx/core/__init__.pyi, I have the following signature of mx.repeat:
~/miniforge3/envs/mlx-medusa-plus/lib/python3.10/site-packages/mlx/core/__init__.pyi
mx.repeat
def repeat(*args, **kwargs):
However, mypy --strict would expect something like the following:
repeat(array: array, repeats: int, axis: Optional[int] = None, *, stream: Union[None, Stream, Device] = None) -> array
I noticed that the help function could reveal accurate type annotations. The run of help(mx.repeat) gave me the following:
help
help(mx.repeat)
repeat(...) method of builtins.PyCapsule instance repeat(array: array, repeats: int, axis: Optional[int] = None, *, stream: Union[None, Stream, Device] = None) -> array
Where does help get the information from? Could pybind11-stubgen make use of such information to output accurately annotated functions? Thanks!
Hmm. Should I post this proposal to https://github.com/sizmailov/pybind11-stubgen instead?
I want to use
mypy --strict
to check my code that depends on MLX. However, the stub generated bypybind11-stubgen
at https://github.com/ml-explore/mlx/blob/3b661b73943c8b91d45bdf55da670e8cb308c2a8/setup.py#L137C26-L137C42 does not include accurate type annotation.In the file
~/miniforge3/envs/mlx-medusa-plus/lib/python3.10/site-packages/mlx/core/__init__.pyi
, I have the following signature ofmx.repeat
:However,
mypy --strict
would expect something like the following:I noticed that the
help
function could reveal accurate type annotations. The run ofhelp(mx.repeat)
gave me the following:Where does
help
get the information from? Couldpybind11-stubgen
make use of such information to output accurately annotated functions? Thanks!