-
Notifications
You must be signed in to change notification settings - Fork 161
Open
Labels
api: storageIssues related to the googleapis/python-storage API.Issues related to the googleapis/python-storage API.
Description
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
-
Create a virtual environment and install dependencies:
python -m venv venv source venv/bin/activate pip install google-cloud-storage pyright
-
Create a simple script:
from google.cloud.storage import Blob blob = Blob(name="test", bucket="my-bucket") print(blob.name)
-
Enable strict type checking:
[tool.pyright] reportMissingTypeStubs = true typeCheckingMode = "strict"
-
Run Pyright or let Pylance analyze:
pyright example.py
-
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 ingoogle.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).
Proposal
-
Add a minimal
py.typed
togoogle-cloud-storage
to signal typedness. -
Provide a corresponding
.pyi
stub (e.g., in typeshed or library package) covering common methods like: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
Metadata
Metadata
Assignees
Labels
api: storageIssues related to the googleapis/python-storage API.Issues related to the googleapis/python-storage API.