Open rowoflo opened 1 year ago
@rowoflo, which type checker are you using?
I am using mypy
.
I don't think the project is meant to be installed. But if you want to install it, you can add your own setup.py
to it.
If you only want the scipy stubs, it would be something like:
"""Package setup"""
from setuptools import setup
with open("README.md", "r") as fh:
long_description = fh.read()
setup(
name="python-type-stubs",
version="0.1.0",
url="https://github.com/microsoft/python-type-stubs",
author="microsoft",
description="A set of type stubs for popular Python packages.",
license="MIT License",
long_description=long_description,
long_description_content_type="text/markdown",
package_data={
"scipy-stubs": ["*.pyi", "**/*.pyi", "**/**/*.pyi", "**/**/**/*.pyi"],
},
packages=[
"scipy-stubs",
],
python_requires=">=3.8",
zip_safe=False,
)
If you fork the repository, add this setup.py
and then install it with pip install git+https://github.com...
then it should work.
These stubs are shipped with Pylance and we use this repo as a way to collaborate with users on them.
@tmke8 is right that these stubs aren't pip
installable at the moment, though we have toyed with the idea, especially as a way for Pyright users to more easily consume them. If any Pyright users happen upon this issue, see the recently added instructions here.
Anyone coming here looking for instructions to use these stubs with mypy:
~/.config/mypy/python-type-stubs
:
mkdir -p ~/.config/mypy/python-type-stubs && git clone https://github.com/microsoft/python-type-stubs.git ~/.config/mypy/python-type-stubs
.bashrc
, or anywhere else as per to preference:
export MYPYPATH=~/.config/mypy/python-type-stubs/
To confirm that things should work run ls $MYPYPATH
and you should see the different project folders:
cv2 networkx pygame skimage sympy-stubs transformers-stubs CODE_OF_CONDUCT.md pyproject.toml SECURITY.md
lightgbm openpyxl scipy-stubs sklearn tenacity utils CONTRIBUTING.md pyrighttestconfig.json
matplotlib pendulum seaborn-stubs sqlalchemy tests vispy LICENSE README.md
Please how does this setup change in the case of a virtual environment ?
I am using VScode with this config for mypy.
"python.linting.mypyPath": ".venv/bin/mypy"
I don't know how I can change this value without breaking everything.
I am getting the common
mypy
error for my project.I see that the
scipy.spatial.transform
library stubs are provided with this project. But I don't know how to install them.I tried installing with pip in my 3.8.13 virtual environment
but I get this error
What is the recommended way to install
python-type-stubs
and are there any pointers for using it?It would be great if this information could be added to the README.