Skip to content
New issue

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

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

Already on GitHub? # to your account

Mypy strict mode issues: "Call to untyped function in typed context" #1567

Open
akx opened this issue Aug 1, 2024 · 0 comments
Open

Mypy strict mode issues: "Call to untyped function in typed context" #1567

akx opened this issue Aug 1, 2024 · 0 comments
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release.

Comments

@akx
Copy link
Contributor

akx commented Aug 1, 2024

Environment details

  • OS: any (but using macOS)
  • Python version: 3.12
  • pip version: using uv instead
  • google-auth version: google-auth==2.32.0

Reproduction

x.py

from google.auth import default
from google.auth.credentials import Credentials


def get_credentials() -> Credentials:
    return default()

Repro steps

$ uv pip install google-auth==2.32.0 mypy==1.11.1
$ mypy --strict x.py
x.py:6: error: Returning Any from function declared to return "Credentials"  [no-any-return]
x.py:6: error: Call to untyped function "default" in typed context  [no-untyped-call]

Downgrading google-auth to 2.29.0 fixes this (in a way), since that version doesn't ship py.typed.

$ uv pip install 'google-auth<2.30.0'
 - google-auth==2.32.0
 + google-auth==2.29.0
$ mypy --strict x.py
x.py:1: error: Skipping analyzing "google.auth": module is installed, but missing library stubs or py.typed marker  [import-untyped]
x.py:2: error: Skipping analyzing "google.auth.credentials": module is installed, but missing library stubs or py.typed marker  [import-untyped]
x.py:2: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports

The "missing library stubs" errors can be ignored (by ignoring google.auth related typing things altogether using the instructions Mypy links there), but the no-any-return and no-untyped-call errors are harder to ignore.


In short, if the package ships py.typed, it should indeed be well typed.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release.
Projects
None yet
Development

No branches or pull requests

2 participants