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

2.2.0 breaks typing checks in applications #734

Closed
syphar opened this issue Mar 15, 2022 · 2 comments · Fixed by #735 or #736
Closed

2.2.0 breaks typing checks in applications #734

syphar opened this issue Mar 15, 2022 · 2 comments · Fixed by #735 or #736
Labels
api: storage Issues related to the googleapis/python-storage API.

Comments

@syphar
Copy link

syphar commented Mar 15, 2022

In #716 a py.typed file was added to tell mypy that it should use the provided type annotations (or stub-files) in this package.

Problem with that: there are no type annotations and no stub-file.

In our application this leads to errors like this:
grafik

( only on 2.2.0, not in 2.1.0)

Environment details

  • Mac OS 12.2.1
  • Python version: 3.10.2
  • pip version: 21.2.4
  • google-cloud-storage version: 2.2.0

Steps to reproduce

  1. install 2.2.0 in your application
  2. use a class anywhere ( it broke for Client and Blob for me
  3. use mypy --strict ( I believe the needed settings are disallow_untyped_defs or disallow_untyped_calls, but I'm not 100% certain. I can provide my config if that's needed).

Code example

import json
import os
from functools import cache

from google.cloud import storage
from google.oauth2 import service_account

@cache
def _client() -> storage.Client:
    if storage_key := os.environ.get("GOOGLE_CLOUD_STORAGE_KEY", None):
        data = json.loads(storage_key)
        credentials = service_account.Credentials.from_service_account_info(data)

        return storage.Client(  # typing error here 
            credentials=credentials,
            project=data["project_id"],
        )

possible solution

  • add type annotations to all methods & classes
  • remove the py.typed marker again.
@product-auto-label product-auto-label bot added the api: storage Issues related to the googleapis/python-storage API. label Mar 15, 2022
@unforced
Copy link
Contributor

Thank you for this report @syphar and others following along.
We are looking into this now, and we should have a quick fix new release that temporarily rolls back these mypy changes, while we investigate further.

@unforced
Copy link
Contributor

You should be able to update your library to 2.2.1 and this problem should be addressed.
Thank you again for bringing the issue to our awareness!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the googleapis/python-storage API.
Projects
None yet
2 participants