Skip to content

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

@al-chris

Description

@al-chris

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:

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

    from google.cloud.storage import Blob
    
    blob = Blob(name="test", bucket="my-bucket")
    print(blob.name)
  3. Enable strict type checking:

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

    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).

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:

    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)
  • This has also affected other google.cloud submodules. (GitHub)

Metadata

Metadata

Assignees

Labels

api: storageIssues related to the googleapis/python-storage API.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions