inconsistent type annotations for Document.on_snapshot #26
Labels
api: firestore
Issues related to the googleapis/python-firestore API.
type: docs
Improvement to the documentation for an API.
Looking here (which mirrors the API docs):
python-firestore/google/cloud/firestore_v1/document.py
Lines 503 to 504 in de3aca0
The claim is that the callback invoked by
on_snapshot
should have type signatureCallable[[:class:
~google.cloud.firestore.document.DocumentSnapshot], NoneType]
. however, just a few lines lower, in the example, it looks like the callback receives three arguments:python-firestore/google/cloud/firestore_v1/document.py
Line 515 in de3aca0
i tried to understand what's going on by reading the code, and didn't make too much progress. we invoke the callback here:
python-firestore/google/cloud/firestore_v1/watch.py
Lines 569 to 573 in de3aca0
it looks like there are indeed three arguments passed.
appliedChanges
appears to be aList[DocumentChange]
, and the final argument seems to be adatetime.datetime
instance. but the first argument... is the result of callingkeys()
on adocument_tree
(here:python-firestore/google/cloud/firestore_v1/watch.py
Line 567 in de3aca0
List[str]
? theself.doc_tree
is an instance ofWatchDocTree
and it'skeys()
method returns the underlying dict's keys. are those keys actuallyDocumentSnapshot
instances? it maybe sort of seems like it, after tracing through the code a bunch. i'm guessing that the correct type signature for the callback is:but it would be nice if this was confirmed, and the documentation updated to reflect reality.
The text was updated successfully, but these errors were encountered: