Dropbox Python SDK 不包含 .pyi 文件作为 Dropbox Python SDK 的一部分,因此您必须构建它们,并设置MYPYPATH
.
根据 Dropbox API 规范执行此操作:
# We first need the Dropbox stone and public stone specs:
git clone git@github.com:dropbox/stone.git
git clone git@github.com:dropbox/dropbox-api-spec.git
# Next we need to install ply (used for running stone)
pip install ply
# Use stone to build the type stubs
PYTHONPATH=stone python -m stone.cli python_type_stubs mypy_stubs/dropbox dropbox-api-spec/*.stone
# include __init__.py files
touch mypy_stubs/__init__.py mypy_stubs/dropbox/__init__.py
# now mypy succeeds when using MYPYPATH to reference new .pyi files
MYPYPATH=mypy_stubs mypy project.py
或者,您可以从 Dropbox Python SDK 构建存根:
# This assumes the following python modules are already installed: six, ply
git clone git@github.com:dropbox/dropbox-sdk-python.git
cd dropbox-sdk-python/
git submodule init
git submodule update
PYTHONPATH=./stone python -m stone.cli python_type_stubs mypy_stubs/dropbox spec/*.stone