Closed
1 / 11 of 1 issue completed
Copy link
Description
Describe the issue:
While upgrading CMasher's CI to numpy 2.2.0, I got a new typechecking error that seems spurious to me. No error is raised with numpy 2.1.3
Reproduce the code example:
import numpy as np
def to_rgb(in_) -> tuple[float, float, float]:
# minimal mock for matplotlib.colors.to_rgb
return (1. ,2., 3.)
def foo(name: str, data: list[tuple[float, float, float]]) -> None:
data_arr = np.array(data)
if data_arr.dtype.kind == "S":
cm_data = [str(x) for x in data_arr]
colorlist = [to_rgb(_) for _ in cm_data]
else:
data_arr = np.atleast_2d(data_arr)
colorlist = data_arr.tolist()
Error message:
cmasher.py:15: error: Incompatible types in assignment (expression has type "str | list[str] | list[list[str]] | list[list[list[Any]]]", variable has type "list[tuple[float, float, float]]") [assignment]
Found 1 error in 1 file (checked 1 source file)
Python and NumPy Versions:
2.2.0
3.13.1 (main, Dec 4 2024, 16:25:14) [Clang 16.0.0 (clang-1600.0.26.4)]
Type-checker version and settings:
mypy==1.13.0
no custom settings
Additional typing packages.
Included with mypy, but not used here (as far as I'm aware)
typing-extensions==4.12.2