Skip to content

Unintuitive behaviour when only subpackage provides py.typed #16149

@Ranfir

Description

@Ranfir

Bug Report

from numba import typed causes mypy to generate spurious attr-defined errors for everything else imported from numba.

To Reproduce

from numba import njit, typed  # error: Module has no attribute "njit"  [attr-defined]

Expected Behavior

scratch.py:1: error: Skipping analyzing "numba": module is installed, but missing library stubs or py.typed marker  [import]
scratch.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports

Actual Behavior

scratch.py:1: error: Module "numba" has no attribute "njit"  [attr-defined]

Your Environment

  • Mypy version used: 1.5.1
  • Mypy command-line flags: none
  • Mypy configuration options from mypy.ini (and other config files): none
  • Python version used: 3.8.8, 3.10.9, 3.11.5
$ .venv/bin/pip freeze
importlib-metadata==6.8.0
llvmlite==0.40.1
mypy==1.5.1
mypy-extensions==1.0.0
numba==0.57.1
numpy==1.24.4
tomli==2.0.1
typing_extensions==4.8.0
zipp==3.17.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions