Skip to content

no-implicit-reexport ignores issues after calling numpy.cross in a function #12350

@ThunderKey

Description

@ThunderKey

Bug Report

When passing the --no-implicit-reexport flag to mypy the following code does not generate any errors and does not reveal a type:

import numpy
from numpy.typing import ArrayLike


def test_method() -> None:
    value: ArrayLike = numpy.cross(numpy.array([1, 2, 3]), numpy.array([4, 5, 6]))
    reveal_type(value)
    broken: int = 'test'

The issue remains if the method is called directly as numpy.core.numeric.cross.

If the flag --no-implicit-reexport is not supplied the errors are generated correctly.

Interestingly if the code is not in a method the error is reported. This made me think that the issue might not be with numpy but mypy.

To Reproduce

  1. Install dependencies pip install mypy==0.940 numpy==1.22.3
  2. Create a file test.py as mentioned above
  3. mypy test.py -> errors are shown
  4. mypy --no-implicit-reexport test.py -> no errors are shown

Expected Behavior

Both calls should raise the same errors.

Actual Behavior

The call with the --no-implicit-reexport flag does not show any errors.

Your Environment

  • Mypy version used: 0.940 and 0.931
  • Mypy configuration options from mypy.ini (and other config files): No configuration file
  • Python version used: 3.10.2
  • Operating system and version: Linux-5.10.102-1-MANJARO-x86_64-with-glibc2.35(as returned by platform.platform()) but it also fails with the docker image python:3.10.2-slim

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-implicit-reexportThe --no-implicit-reexport option

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions