xarray-contrib/xarray-schema

Mypy type checking

jhamman opened this issue · 2 comments

As I've been working on this project, I've been trying to keep typing front of mind. Most things are working but there are currently a few errors that should be addressed:

xarray_schema/components.py:150: error: Argument 2 to "zip" has incompatible type "Optional[Tuple[Tuple[int, ...], ...]]"; expected "Iterable[Tuple[int, ...]]"
xarray_schema/components.py:164: error: Incompatible types in assignment (expression has type "Tuple[int, ...]", variable has type "int")
xarray_schema/dataarray.py:62: error: Incompatible types in assignment (expression has type "Union[dtype[Any], type, _SupportsDType[dtype[Any]], str, Tuple[Any, int], Tuple[Any, Union[SupportsIndex, Sequence[SupportsIndex]]], List[Any], _DTypeDict, Tuple[Any, Any], DTypeSchema, None]", variable has type "Optional[DTypeSchema]")
xarray_schema/dataarray.py:63: error: Incompatible types in assignment (expression has type "Union[Tuple[Optional[int]], ShapeSchema, None]", variable has type "ShapeSchema")
xarray_schema/dataarray.py:64: error: Incompatible types in assignment (expression has type "Union[Tuple[Optional[str]], DimsSchema, None]", variable has type "Optional[DimsSchema]")
xarray_schema/dataarray.py:65: error: Incompatible types in assignment (expression has type "Union[str, NameSchema, None]", variable has type "NameSchema")
xarray_schema/dataarray.py:67: error: Incompatible types in assignment (expression has type "Union[bool, Dict[str, Optional[int]], ChunksSchema, None]", variable has type "ChunksSchema")
xarray_schema/dataarray.py:69: error: Incompatible types in assignment (expression has type "Optional[Any]", variable has type "ArrayTypeSchema")
xarray_schema/dataarray.py:70: error: Incompatible types in assignment (expression has type "Optional[List[Callable[..., Any]]]", variable has type "List[Callable[..., Any]]")
xarray_schema/dataarray.py:96: error: Incompatible return value type (got "Optional[ShapeSchema]", expected "ShapeSchema")
xarray_schema/dataarray.py:107: error: Incompatible return value type (got "Optional[ChunksSchema]", expected "ChunksSchema")
xarray_schema/dataarray.py:118: error: Incompatible return value type (got "Optional[NameSchema]", expected "NameSchema")
xarray_schema/dataarray.py:129: error: Incompatible return value type (got "Optional[ArrayTypeSchema]", expected "ArrayTypeSchema")

After these are fixed, it would be nice to run mypy as part of the CI test suite.

@jhamman Here is an attempt to get mypy working: #38

As of #18, we're passing all of our Mypy checks.