You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I would expect that after array = cast("FloatArray", array), I should always be able to call foo(array) with def foo(array: FloatArray). However, pyright does not like it:
bug.py:20:9 - error: Argument of type "FloatArray" cannot be assigned to parameter "array" of type "FloatArray" in function "foo"
"ndarray[Any, dtype[floating[Any] | integer[Any]]]" is not assignable to "ndarray[Any, dtype[floating[Any]]]"
Type parameter "_DType_co@ndarray" is covariant, but "dtype[floating[Any] | integer[Any]]" is not a subtype of "dtype[floating[Any]]"
"dtype[floating[Any] | integer[Any]]" is not assignable to "dtype[floating[Any]]"
Type parameter "_DTypeScalar_co@dtype" is covariant, but "floating[Any] | integer[Any]" is not a subtype of "floating[Any]"
Type "floating[Any] | integer[Any]" is not assignable to type "floating[Any]" (reportArgumentType)
1 error, 0 warnings, 0 informations
Code or Screenshots
fromtypingimportAny, castimportnumpyasnpimportnumpy.typingasnpt
type FloatArray=npt.NDArray[np.floating[Any]]
type NumberArray=npt.NDArray[np.floating[Any] |np.integer[Any]]
deffoo(array: FloatArray) ->None: ...
defbar(array: NumberArray) ->None:
# this works:array2=cast("FloatArray", array)
foo(array2)
# this seems to confuse pyrightarray=cast("FloatArray", array)
foo(array)
VS Code extension or command-line
pyright 1.1.394 from PyPI
The text was updated successfully, but these errors were encountered:
Describe the bug
I would expect that after
array = cast("FloatArray", array)
, I should always be able to callfoo(array)
withdef foo(array: FloatArray)
. However,pyright
does not like it:Code or Screenshots
VS Code extension or command-line
pyright 1.1.394 from PyPI
The text was updated successfully, but these errors were encountered: