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
{{ message }}
Repository navigation
Type hints allows None for too many parameters #1593
uxarray type hints allow None for too many parameters. For example, in uxarray/core/api.py:
defopen_grid(
grid_filename_or_obj: str|os.PathLike[Any] |dict|Dataset,
chunks=None,
use_dual: bool|None=False,
**kwargs: dict[str, Any],
):
"""Constructs and returns a ``Grid`` from a grid file. ... use_dual : bool, optional Specify whether to use the primal (use_dual=False) or dual (use_dual=True) mesh if the file type is MPAS ... """
...
The docstring and code both expect a bool, not None; there is no special meaning of use_dual=None. So, None should not be allowed in the type hinting here.
Briefly clarifying a few points here for future reference:
This applies in other cases too, not just use_dual. For example, grid.use_geodataframe() type hints allow engine=None, but the method starts by crashing with ValueError if engine not in ["spatialpandas", "geopandas"]. Other examples include destination in UxDataArray.difference(); start_index in Grid.from_topology(); and tol in Grid.from_structured().
I'm not sure how to add regression tests for this sort of thing. Maybe no regression tests are needed? Or, maybe this would be a good opportunity to introduce mypy or pyright checks into the CI pipeline somewhere? See PR Fix use_dual type hints #1612 for more discussion on this question.
Briefly clarifying a few points here for future reference:
This applies in other cases too, not just use_dual. For example, grid.use_geodataframe() type hints allow engine=None, but the method starts by crashing with ValueError if engine not in ["spatialpandas", "geopandas"]. Other examples include destination in UxDataArray.difference(); start_index in Grid.from_topology(); and tol in Grid.from_structured().
I'm not sure how to add regression tests for this sort of thing. Maybe no regression tests are needed? Or, maybe this would be a good opportunity to introduce mypy or pyright checks into the CI pipeline somewhere? See PR Fix use_dual type hints #1612 for more discussion on this question.
Activity
Sevans711 commentedon Jul 27, 2026
Briefly clarifying a few points here for future reference:
grid.use_geodataframe()type hints allow engine=None, but the method starts by crashing with ValueError if engine not in ["spatialpandas", "geopandas"]. Other examples includedestinationinUxDataArray.difference();start_indexinGrid.from_topology(); andtolinGrid.from_structured().erogluorhan commentedon Jul 29, 2026
Answering this, and also related to #1612 (comment)