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

[ENHANCEMENT] Implement Type Hints into Pastas #389

Closed
raoulcollenteur opened this issue Apr 7, 2022 · 4 comments · Fixed by #441
Closed

[ENHANCEMENT] Implement Type Hints into Pastas #389

raoulcollenteur opened this issue Apr 7, 2022 · 4 comments · Fixed by #441
Assignees
Labels
enhancement Indicates improvement of existing features

Comments

@raoulcollenteur
Copy link
Member

Describe the proposed enhancement
Following Pastastore, implement Type Hinting into Pastas to improve Error feedback. @dbrakenhoff, good idea?

@raoulcollenteur raoulcollenteur added the enhancement Indicates improvement of existing features label Apr 7, 2022
@dbrakenhoff
Copy link
Member

I think it's a "nice-to-have" addition for users. As far as I know, they're just hints that can generally also be picked up by users from the docstring. So not sure how error feedback would improve? But it does allow you to check the code with mypy (which I haven't really looked at much) and I think the hints can be pretty helpful.

@OnnoEbbens
Copy link
Member

I thought you could also enforce the types but now that I look into it I see that's not true.

This issue came up when someone tried to use the ps.plots.series function with a DataFrame instead of a Series. From the error it was hard to know what went wrong. We could manually add type checks like this :

if not isinstance(head, [pd.Series, ps.Timeseries]):
    raise TypeError('expected pandas Series or pastas Timeseries object')

But this is maybe a bit to rigid for pastas. Besides it is a lot of work to implement this for the relevant pastas functions.

@martinvonk
Copy link
Collaborator

martinvonk commented Aug 17, 2022

It would be nice to have one big file with the correct types of each arguments. This way these types can be implemented correctly in functions. Additionally, checks can be implemented to force the correct types.

@martinvonk martinvonk linked a pull request Dec 27, 2022 that will close this issue
4 tasks
@martinvonk martinvonk mentioned this issue Dec 27, 2022
4 tasks
@raoulcollenteur
Copy link
Member Author

Closing Issue after merging PR #441 from @martinvonk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Indicates improvement of existing features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants