-
Notifications
You must be signed in to change notification settings - Fork 76
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
Add mypy to CI job and type hints for one class. #404
Conversation
💖 Thank you for opening your first pull request in this repository! 💖 A few things to keep in mind:
⭐ No matter what, we are really grateful that you put in the effort to do this! ⭐ |
Hi @santisoler, is there anything I could do to help move this along? This change would be helpful to me when working with this library, and it seems like there has been interest from others as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @eliotwrobson. Yes, I totally agree. Type hints is something people would like to see in Pooch (me included!).
I left a few comments here so we can move forward with this PR.
Importing from typing
I noticed that in this PR you import typing as t
, and then use each one of the types in signatures with t.<TYPE>
, like t.Optional,
t.List`, etc.
Why not importing the required types directly? Like from typing import ...
. Most of the codebases that use type hints use the modules like this:
from typing import Optional
def f(x: Optional[float] = None):
...
I think having that extra t.
creates some clutter in the signatures, specially when we need to use several types. What do you think?
Do we need typing_extensions
?
I noticed that you added typing_extensions
as a dependency. I'm curious if this strictly necessary. I left a comment below where we can continue the conversation.
Minor things to do
Before I forget, we need to add the new style requirements to environment.yml
as well. Thanks for adding them to requirements-style.txt
and to add a new target to the Makefile!
Thanks again for the effort you put in this! I really appreciate that we can move forward with type hints in Pooch!
@santisoler I've responded to your comments. I've added mypy to the environment.yml, removed typing_extensions, and changed the typing import. Also, let me know if you want any help with #453, since I'm currently using ruff to autoformat everything locally. |
Rename them to `PathType` and `PathInputType` since those paths are not usually used for files, but for directories as well.
Hi @eliotwrobson! Thanks for addressing my comments, I appreciate it. I've just pushed a few changes to your branch, hope you don't mind (feel free to revert changes if you disagree with them). I managed to move the new type classes to their own |
No worries, thank you for making these changes! Everything looks good to me. Would you like to add typing to everything in the library before merging this? Or merge as-is and incrementally add typing over a number of PRs? This currently doesn't have the |
I think it would be better to merge this PR and work on adding other type hints incrementally in other PRs. That would things easier for reviewing, for avoiding conflicts and to also see some progress. I'm afraid I'm not familiar with the |
@santisoler sounds good. I don't think it's worth adding Let me know if you'd like more changes here before merging. If not, I think everything looks good, so after this is merged I can get started on annotations in other files. |
Replace `typing.List` for the builtin `list`, since the former has been deprecated.
I see. Sorry, I misunderstood your previous comment. Let's forget about the
I think we are good to go. I just made a small change to I'm merging this! 🚀 Thanks again for pushing forward with this and for the hard work. Feel free to open another PR for type hinting the rest of Pooch whenever you want, no rush!. And also, feel free to split the work in several PRs. |
Changes to test type hints and integrating a typechecker into the CI job.
This was to test feasibility of adding type annotations to the package (per
the issue). This was surprisingly easy to do, I basically just copied the types
listed in the docstring.
Relevant issues/PRs:
#330
Squash and Merge summary
Add type hints to
pooch/core.py
and create a newtyping
submodule for custom type classes, and add it to the API Reference. Runmypy
on CI to perform type checks, and create new targets in theMakefile
. Extend the list of dependencies required to run the type checks.