Skip to content

Missing type annotations for attrs.cmp_using #948

@akirchhoff-modular

Description

@akirchhoff-modular

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugTypingTyping/stub/Mypy/PyRight related bugs.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions