numpy allclose #4536
-
|
Given this script # pyright: strict
import numpy as np
np.allclose(np.array([1.0, 2.0, 3.0]), np.array([1.0, 2.0, 3.0]))Mypy seems ok But pyright doesn't come to terms with the script above Stubfiles provides the following info. def allclose(
a: ArrayLike,
b: ArrayLike,
rtol: float = ...,
atol: float = ...,
equal_nan: bool = ...,
) -> bool: ...
...
_ArrayLike = Union[
_SupportsArray["dtype[_ScalarType]"],
_NestedSequence[_SupportsArray["dtype[_ScalarType]"]],
]I guess it has to do with I am not sure I understand what is unknown to pyright, is this a bug or I misunderstand something, probably the latter. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
You've enabled pyright's strict mode. In this mode, the In this case, the ArrayLike = _DualArrayLike[
dtype,
Union[bool, int, float, complex, str, bytes],
]The type |
Beta Was this translation helpful? Give feedback.
You've enabled pyright's strict mode. In this mode, the
reportUnknownMemberTypecheck is enabled. This check reports the use of any member (attribute or method) whose type isUnknownor contains anUnknownsomewhere within it.In this case, the
allclosemethod uses the type aliasArrayLikewhich is defined as follows:The type
dtypeis a generic class that accepts a single type argument. Since none is provided, its type isdtype[Unknown]. That's the origin of theUnknowntype that pyright is telling you about here. This isn't a bug in pyright. It's an omission in the numpy code, and it would need to…