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

mypy disallow-untyped-calls check fails for google-auth 2.30 #1543

Open
n0jam opened this issue Jun 24, 2024 · 5 comments
Open

mypy disallow-untyped-calls check fails for google-auth 2.30 #1543

n0jam opened this issue Jun 24, 2024 · 5 comments
Assignees

Comments

@n0jam
Copy link

n0jam commented Jun 24, 2024

Environment details

  • OS: Ubuntu 22.04
  • Python version: 3.10.11
  • pip version: 24.1
  • google-auth version: 2.30

Steps to reproduce

  1. Install mypy and google-auth in a virtualenv
  2. Create a sample script only containing:
import google.auth
source_credentials, project = google.auth.default()
  1. Run mypy --ignore-missing-imports --disallow-untyped-calls ./

With google-auth==2.29 this works fine.
With google-auth==2.30 this fails with
error: Call to untyped function "default" in typed context [no-untyped-call]

Did something change from google-auth 2.29 -> 2.30 regarding the typing?
Thanks in advance!

@clundin25 clundin25 self-assigned this Jun 26, 2024
@clundin25
Copy link
Contributor

I can reproduce this.

I do not see any commit that seems suspicious.

When I try to reproduce by pip installing from my filesystem this always fails for me, which makes it difficult to pinpoint any specific regression.

How important is this to you?

@n0jam
Copy link
Author

n0jam commented Jun 27, 2024

It is not that important. We can ignore this mypy check for now, and test if it is resolved in the next google-auth version. It was more out of interest to understand why this error is raised.

@antoni-szych-rtbhouse
Copy link

antoni-szych-rtbhouse commented Jun 27, 2024

This commit caused issues: c993504

You can reproduce this with:

(previous commit)
>pip install git+https://github.com/googleapis/google-auth-library-python@dc6a4c15f259d6cff03dccfef2ae6958636c9d8e
...

> mypy sample_script.py
Success: no issues found in 1 source file

> pip uninstall google-auth
...

> pip install git+https://github.com/googleapis/google-auth-library-python@c99350455d0f7fd3aab950ac47b43000c73dd312
...

> mypy my_example.py
...
error: Call to untyped function "default" in typed context  [no-untyped-call]
error: Call to untyped function "Credentials" in typed context  [no-untyped-call]

I guess that something changed in the process of releasing of wheels after 2.29? In 2.29 install from git vs install from pypi gives different results (additional py.typed files on github, missing in pypi wheels):

# install from git
pip install git+https://github.com/googleapis/google-auth-library-python@v2.29.0

$ ls /home/.../lib/python3.11/site-packages/google/auth/*py.t*
/home/.../lib/python3.11/site-packages/google/auth/py.typed

$ ls /home/.../lib/python3.11/site-packages/google/oauth2/*py.t*
/home/.../lib/python3.11/site-packages/google/oauth2/py.typed

$ pip uninstall google-auth
Found existing installation: google-auth 2.29.0
Uninstalling google-auth-2.29.0:
  Would remove:
.../lib/python3.11/site-packages/google/auth/*
.../lib/python3.11/site-packages/google/oauth2/*
.../lib/python3.11/site-packages/google_auth-2.29.0.dist-info/*

Proceed (Y/n)? y
  Successfully uninstalled google-auth-2.29.0


# install from pypi

$ pip install google-auth==2.29.0
Collecting google-auth==2.29.0
  Using cached google_auth-2.29.0-py2.py3-none-any.whl (189 kB)
Installing collected packages: google-auth
Successfully installed google-auth-2.29.0

$ ls /home/.../lib/python3.11/site-packages/google/auth/py.typed
ls: cannot access /home/.../lib/python3.11/site-packages/google/auth/py.typed: No such file or directory

$ ls /home/.../lib/python3.11/site-packages/google/oauth2/py.typed
ls: cannot access /home/.../lib/python3.11/site-packages/google/oauth2/py.typed: No such file or directory

seems like there was an update:

- gcp-releasetool==1.16.0 \
+ gcp-releasetool==2.0.0 \

in f01a690

I would guess that's the reason for github vs pypi installs being different for 2.29 and older (mypy error only for github versions, but no errors for pypi releases), while being the same (mypy error for both pypy and github releases) for 2.30.

@n0jam
Copy link
Author

n0jam commented Jul 3, 2024

thanks for debugging this further!
I tried version 2.31 but the behavior is the same as for 2.30.

@akx
Copy link
Contributor

akx commented Aug 1, 2024

This is probably related to #1526.

Now that py.typed files are actually shipped, Mypy expects this package to be well typed, which it isn't, everywhere.

Related: #1567

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants