Skip to content

Incorrect error for numpy.iinfo(numpy.int32) #2398

@jakevdp

Description

@jakevdp

Describe the Bug

Pyrefly incorrectly errors for the following, with NumPy v2.4.2:

import numpy as np
np.iinfo(np.int32)
$ pyrefly check test.py
ERROR No matching overload found for function `numpy._core.getlimits.iinfo.__init__` called with arguments: (type[signedinteger[_32Bit]]) [no-matching-overload]
 --> test.py:3:9
  |
3 | np.iinfo(np.int32)
  |         ^^^^^^^^^^
  |
  Possible overloads:
  (int_type: _HasDType[dtype[_IntegerT_co]] | _HasNumPyDType[dtype[_IntegerT_co]] | dtype[_IntegerT_co] | _IntegerT_co | type[_IntegerT_co]) -> None [closest match]
  (int_type: Literal['<n', '=n', '>n', 'int', 'int_', 'intp', 'n', '|n'] | int | type[int]) -> None
  (int_type: _Int8Codes) -> None
  (int_type: _UInt8Codes) -> None
  (int_type: _Int16Codes) -> None
  (int_type: _UInt16Codes) -> None
  (int_type: _Int32Codes) -> None
  (int_type: _UInt32Codes) -> None
  (int_type: _Int64Codes) -> None
  (int_type: _UInt64Codes) -> None
  (int_type: str) -> None
 INFO 1 error

This code passes with mypy, pytype, ty, and pyright; I'm not sure exactly what the issue is with pyrefly, and I have so far been unable to reduce this to a smaller/self-contained reproduction.

Sandbox Link

Sandbox link not possible because of NumPy requirement.

(Only applicable for extension issues) IDE Information

No response

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions