daf.typing fake¶
The pandas package doesn’t provide type annotations. This means anywhere we use pandas.DataFrame or
pandas.Series it becomes Any, which poisons any Union using them to become Any as well, making mypy
type checking useless. As a workaround we define fake DataFrame and Series and use them instead. To shut mypy
up when using this fake types, we need to populate it with all the public interface of the real pandas classes, with
a liberal use of the Any type. Sigh.
Todo
If/when pandas will provide some form of type annotations, get rid of the fake_pandas module.
The scypy.sparse package doesn’t provide type annotations. This means anywhere we use sparse.scipy.spmatrix,
sparse.scipy.csr_matrix or sparse.scipy.csc_matrix, they becomes Any, which poisons any Union using the
type to become Any as well, making mypy type checking useless. As a workaround we define fake spmatrix and
cs_matrix and use them instead. To shut mypy up we need to populate it with all the public interface of the real
scipy.sparse classes with a liberal use of the Any type. Sigh.
Todo
If/when scipy.sparse will provide some form of type annotations, get rid of the fake_sparse module.