googleapis / googleapis/google-cloud-python

Missing type annotations (py.typed/stubs) for google.cloud.storage causing Pylance/Pyright complaints

オープン
#15,969 コメント 3 件 リアクション 8 件 担当者 1 名 @chandra-siri が担当を希望しています GitHub で見る
api: storage
主要言語
Python
スター
5.4k
フォーク
1.8k
平均マージ
3日 4時間
マージ済み PR(30日)
122

説明

#### Summary

Using `google-cloud-storage` in Python results in incomplete or missing type information, which triggers `reportMissingTypeStubs` and `reportUnknownMemberType` errors in Pylance and Pyright. This degrades editor support (e.g., autocompletion, type safety) and creates noise during development.

#### Steps to Reproduce

1. Create a virtual environment and install dependencies:

```bash
python -m venv venv
source venv/bin/activate
pip install google-cloud-storage pyright
```
2. Create a simple script:

```python
from google.cloud.storage import Blob

blob = Blob(name="test", bucket="my-bucket")
print(blob.name)
```
3. Enable strict type checking:

```toml
[tool.pyright]
reportMissingTypeStubs = true
typeCheckingMode = "strict"
```
4. Run Pyright or let Pylance analyze:

```bash
pyright example.py
```
5. Errors:

```
error: Stub file not found for "google.cloud.storage" (reportMissingTypeStubs)
error: Type of "name" is partially unknown (reportUnknownMemberType)
```

#### Expected Behavior

* A `py.typed` file in `google.cloud.storage` or
* An official type stub file (`google.cloud.storage.pyi`) with correct annotations
* This would resolve type-checking errors and support proper IntelliSense.

#### Workarounds Tryed

* There's no embedded type information or `py.typed` marker in the installed library.
* Community type stubs don’t currently exist for this package.
* Pyright/Pylance treat this as “as-designed” and suggest suppressing diagnostics rather than improving type support ([GitHub][1]).

#### Proposal

* **Add a minimal `py.typed`** to `google-cloud-storage` to signal typedness.
* **Provide a corresponding `.pyi` stub** (e.g., in typeshed or library package) covering common methods like:

```python
class Blob:
def __init__(
self,
name: str,
bucket: 'Bucket',
chunk_size: Optional[int] = None,
encryption_key: Optional[bytes] = None,
kms_key_name: Optional[str] = None,
generation: Optional[int] = None,
) -> None: ...
name: str
# etc.
```
* Alternatively, **publish stubs in typeshed**, or coordinate with that project.

#### Benefits

* Enable better developer experience (autocomplete, inline docs, accurate type errors).
* Reduce friction during code editing and static analysis.
* Attract contributions from type-aware users.

#### Additional Context

* Pyright correctly labels this as a missing type stubs issue and marks it “as‑designed.” ([GitHub][1])
* This has also affected other `google.cloud` submodules. ([GitHub][2])

[1]: https://github.com/microsoft/pyright/issues/9393?utm_source=chatgpt.com "google.cloud.storage reports Stub file not found for \"google.cloud.storage\" (reportMissingTypeStubs) · Issue #9393 · microsoft/pyright · GitHub"
[2]: https://github.com/microsoft/pylance-release/issues/1687?utm_source=chatgpt.com "Missing imports for many `google.cloud` libraries · Issue googleapis/python-storage#1687 · microsoft/pylance-release · GitHub"

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。