Skip to content

Type hints allows None for too many parameters #1593

Description

@Sevans711

Version

2026.6.0

How did you install UXarray?

Source

What happened?

uxarray type hints allow None for too many parameters. For example, in uxarray/core/api.py:

def open_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.

Related: #1590

What did you expect to happen?

I expected type hinting for each kwarg to either precisely represent all accepted types, or to be excluded entirely.

Can you provide a MCVE to repoduce the bug?

N/A

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions