Dropbox的Python的SDK不包括.pyi文件,Dropbox的的Python SDK的一部分,所以你必須構建它們,並設置MYPYPATH
。
爲了從Dropbox的API SPEC這樣做:
# We first need the Dropbox stone and public stone specs:
git clone [email protected]:dropbox/stone.git
git clone [email protected]: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 [email protected]: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
的SDK API已經有一段時間相同的,所以似乎是穩定的。 Dropbox中的某人有沒有任何理由不將這些存根添加到分類回購中?如果這是一個麻煩的問題,我應該添加存根嗎? – blokeley
我不知道是否有什麼特別的原因,但我會要求球隊這樣做。 – Greg
非常感謝。如果您聽到存根被添加到密碼中,請在上面的答案中註明 – blokeley