繁体   English   中英

为什么 VSCode Python 代码完成不适用于我的 firestore 客户端变量?

[英]Why does VSCode Python code completion not work for my firestore client variable?

我有以下 python 片段...

import firebase_admin
from firebase_admin import credentials
from firebase_admin import firestore

cred = credentials.Certificate("./cert.json")
firebase_admin.initialize_app(cred)

client = firestore.client()
client.

当我在最后一行键入点时,没有代码完成选项出现。 在“firestore”变量上,出现了代码完成选项。

我在 VSCode 中安装了 Python 和 Pylance 扩展。 这是配置问题,还是 client() 方法返回的内容无法推断其类型?

事实证明,在 github 存储库上已经有一个未解决的问题,其中还包括一个临时的(糟糕的)解决方法。

from firebase_admin import firestore
from google.cloud.firestore import Client as FirestoreClient # importing the return type of firestore.client()
db: FirestoreClient = firestore.client() # Adding an annotation to my db variable, to enable completion and syntax checking

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM