DHI / mikeio

Read, write and manipulate dfs0, dfs1, dfs2, dfs3, dfsu and mesh files.
https://dhi.github.io/mikeio
BSD 3-Clause "New" or "Revised" License
139 stars 57 forks source link

Indicate that MIKE IO uses type hints #759

Closed ecomodeller closed 2 hours ago

ecomodeller commented 6 days ago

Enables derived package to use type checkers (e.g. mypy, pyright) to find bugs: https://typing.readthedocs.io/en/latest/spec/distributing.html#packaging-typed-libraries

import mikeio

def main(ds: mikeio.Dataset):
    print(ds.item[0])

Before: 😢

$ mypy hello.py
hello.py:1: error: Skipping analyzing "mikeio": module is installed, but missing library stubs or py.typed marker  [import-untyped]
hello.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
Found 1 error in 1 file (checked 1 source file)

After: 😄

$ mypy hello.py
hello.py:4: error: "Dataset" has no attribute "item"; maybe "items"?  [attr-defined]
Found 1 error in 1 file (checked 1 source file)

image