googleapis / googleapis/google-cloud-python

Type Mismatch DocumentSnapshot of AsyncCollectionReference

Đang mở
#15,367 2 bình luận 0 reaction 1 người được giao Được giao cho @daniel-sanche Xem trên GitHub
api: firestore priority: p3
Ngôn ngữ chính
Python
Star
5.4k
Fork
1.8k
Merge trung bình
3 ngày 4 giờ
Pull request đã merge (30 ngày)
122

Mô tả

#### Environment details

- OS type and version: MacOS Sequoia 15.6
- Python version: 3.13.5
- pip version 25.1.1
- `google-cloud-firestore` version: 2.21.0

#### Description
There's a type inconsistency between the IDE's type hints and the actual returned types when working with Firestore's AsyncClient.

#### Steps to reproduce

1. Initialize async client
2. Make a query on a collection
3. fetch query data using `await query.get()`
4. the IDE suggest the return type of `google.cloud.firestore_v1.query_results.QueryResultsList[DocumentSnapshot]`
5. call `.reference` on any object of the query, the IDE will suggest that the return type would be `google.cloud.firestore_v1.base_document.DocumentSnapshot`
6. in reality the document returned is `google.cloud.firestore_v1.async_document.AsyncDocumentReference`

#### Code example

```python
import firebase_admin
firebase_admin.initialize_app()
aclient = firestore_async.firestore.AsyncClient(database="(default)")
users = await aclient.collection("users").get()
print(type(users[0]))
#
print(type(users[0].reference)) # Mismatch between type hint and actual type. see the references
#
```
##### references
https://github.com/googleapis/python-firestore/blob/49836391dc712bd482781a26ccd3c8a8408c473b/google/cloud/firestore_v1/async_collection.py#L199-L244
https://github.com/googleapis/python-firestore/blob/49836391dc712bd482781a26ccd3c8a8408c473b/google/cloud/firestore_v1/async_collection.py#L72-L78
https://github.com/googleapis/python-firestore/blob/49836391dc712bd482781a26ccd3c8a8408c473b/google/cloud/firestore_v1/async_collection.py#L199-L244
https://github.com/googleapis/python-firestore/blob/49836391dc712bd482781a26ccd3c8a8408c473b/google/cloud/firestore_v1/async_query.py#L189-L263
https://github.com/googleapis/python-firestore/blob/49836391dc712bd482781a26ccd3c8a8408c473b/google/cloud/firestore_v1/base_document.py#L441-L449
https://github.com/googleapis/python-firestore/blob/49836391dc712bd482781a26ccd3c8a8408c473b/google/cloud/firestore_v1/async_collection.py#L246-L254

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.