Skip to content

Wrong type hint for createEnumType #1378

Closed

Description

It seems that createEnumType is wrongly typed as:

def createEnumType(
    self,
    datatype: np.dtype[np.integer] | type[np.integer] | type[int],
    datatype_name: str,
    enum_dict: Mapping[str, int | np.integer],
) -> EnumType: ...

But e.g. datatype="u1" is also supported.

  • the version of the software with which you are encountering an issue: netCDF4==1.7.2
  • environmental information (i.e. Operating System, compiler info, java version, python version, etc.): Win10 / python 3.12
  • a description of the issue with the steps needed to reproduce it:
    downstream issue:
    Mypy 1.12 issues pydata/xarray#9624

problematic lines (roughly):

with nc4.Dataset(tmp_file, mode="w") as nc:
    nc.createEnumType("u1", "cloud_type", {"clear": 0, "cloudy": 1})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions