Skip to content

Suggests incorrect library stubs for google.cloud imports #15869

Closed as not planned
@OscarVanL

Description

@OscarVanL

Bug Report

I use a Google Cloud import:

google-cloud-pubsub==2.3.0

and import it like so:

from google.cloud import pubsub_v1

When running mypy it says:

src/foo.py:6: error: Library stubs not installed for "google.cloud"  [import]
src/foo.py:6: note: Hint: "python3 -m pip install types-google-cloud-ndb"
src/foo.py:6: note: (or run "mypy --install-types" to install all missing stub packages)

However installing types-google-cloud-ndb does not fix this.

To Reproduce

Import from google.cloud import pubsub_v1 from google-cloud-pubsub and run mypy.

Expected Behavior

In this case, no stubs/types package exists for this import, so it should suggest nothing.

You can see here that adding type hints/stubs for google.cloud has not been completed.

Actual Behavior

Because types-google-cloud-ndb is specifically for a different Google library installed via from google.cloud import ndb, see its README, this suggestion is incorrect.

This is a PEP 561 type stub package for the google-cloud-ndb package.

Your Environment

  • Mypy version used: 1.5.0
  • Mypy command-line flags: None
  • Python version used: 3.9.17

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions