Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indicate that MIKE IO uses type hints #759

Merged
merged 5 commits into from
Nov 29, 2024
Merged

Indicate that MIKE IO uses type hints #759

merged 5 commits into from
Nov 29, 2024

Conversation

ecomodeller
Copy link
Member

@ecomodeller ecomodeller commented Nov 23, 2024

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

@ecomodeller ecomodeller marked this pull request as ready for review November 23, 2024 15:07
@ecomodeller ecomodeller merged commit 504d2ad into main Nov 29, 2024
9 checks passed
@ecomodeller ecomodeller deleted the typed branch November 29, 2024 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant