-
-
Notifications
You must be signed in to change notification settings - Fork 398
Closed
Labels
Description
attrs.cmp_using
is not included in attrs/__init__.pyi
, and as a result, attempting to use Mypy to type check any code that uses attrs.cmp_using
will result in Mypy complaining that cmp_using
does not exist:
problem.py:8: error: Module has no attribute "cmp_using"
To reproduce, install Mypy, NumPy, pytest, and attrs, download the attached problem.py
, and run mypy problem.py
. In contrast, when you run pytest problem.py
, the code runs without issue – the problem is solely with the type annotations (or lack thereof).
problem.py
:
import attrs
import numpy as np
import numpy.typing as npt
@attrs.define
class Example:
array: npt.NDArray[np.int64] = attrs.field(eq=attrs.cmp_using(np.array_equal))
def test_attrs() -> None:
a = Example(array=np.array([1, 2, 3]))
assert a == a