Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

With 2.2.1 mypy complains that 'google.cloud' is missing 'storage' attribute #166

Closed
asfaltboy opened this issue Jan 4, 2022 · 2 comments
Assignees
Labels
type: question Request for information or clarification. Not an issue.

Comments

@asfaltboy
Copy link

asfaltboy commented Jan 4, 2022

This may be related to recent changes in core and this issue:

Environment details

  • OS type and version: MacOS 11.6
  • Python version: cpython 3.10
  • pip version: 21.3.1
  • google-cloud-core version: 2.2.1

Steps to reproduce

  1. pip install google-cloud-core google-cloud-storage mypy
  2. create python file as below
  3. mypy . gets Module 'google.cloud' has no attribute 'storage'
  4. To work around, try pip install google-cloud-core<2
  5. mypy . returns no errors

Code example

from google.cloud import storage
@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Jan 5, 2022
@busunkim96
Copy link
Contributor

Hi @asfaltboy,

google-cloud-storage does not currently have any type hints as they are in the process of removing 2.7 support.

If the only error you are seeing is on that line, the best course of action is to skip type checking for google-cloud-storage. I believe you will still be able to type check code in other google-cloud libraries that do ship types.

from google.cloud import storage  # type: ignore
from google.cloud import ...

@busunkim96 busunkim96 added the type: question Request for information or clarification. Not an issue. label Jan 6, 2022
@busunkim96 busunkim96 self-assigned this Jan 6, 2022
@yoshi-automation yoshi-automation removed the triage me I really want to be triaged. label Jan 6, 2022
@kojiromike
Copy link

If you don't want to use type: ignore and want to take advantage of types as they emerge, mypy will not complain about

import google.cloud.storage as storage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

4 participants