LoginSignup
0
0

More than 1 year has passed since last update.

Pythonでfirestore.client()に型をつける

Last updated at Posted at 2023-02-03

ドキュメントだと

db = firestore.client()

のように記載してある。

しかし、firestore.client()は返り値の型を固定していないのでAny型となる。

db. のようにコード上で記載しても「お前Anyだから何出していいかわかんねぇよ」となる。


型をつけるために

  1. importする
from google.cloud.firestore_v1.client import Client
  1. 型をつけてあげる
db: Client = firestore.client()

これでdb. と書けば色々頼れる関数が出てくるはず。


追記

  • エラーハンドリングはご自由に。どんな時も必ずClient型で帰ってくるわけではないので。
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0