This signature isn't very precise:
class Matrix:
def __init__(self, arrays: list[list]) -> None:
list[list] means list[list[Any]], but clearly you want a matrix of floats/ints.
Remember, explicit is better than implicit. Always use parametrized generics, even when all type arguments are Any.
class Matrix:
def __init__(self, arrays: list[list[float]]) -> None:
Also, be sure to specify Matrix as the return type for fromdim():
def fromdim(width: int, height: int) -> Matrix:
...
Without this, Mypy would think fromdim() returns Any. Pyright, on the other hand, can infer the correct type. Rely on neither.