Skip to content

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

@akx

Description

@akx

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p2Moderately-important priority. Fix may not be included in next release.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions