-
Notifications
You must be signed in to change notification settings - Fork 85
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 typing support to get_solo
#128
Conversation
As `get_solo` hits the cache, type checkers can't infer the return type of the method correctly. User could use `typing.cast` or similar but having fixed it in the library directly sounds easier. `typing.TypeVar` is used as a workaround until `typing.Self` can be used without making use of `typing_extensions`.
If you'd like to, we could add basic typing to the other parts of the library as well |
I could see value in adding typing to this library, and enabling mypy checking of the project as a new CI check. An example you could look at is: Please configure Mypy in strict mode in [tool.mypy]
ignore_missing_imports = true
strict = true We'll also want to add a |
Great to hear you want to head into this direction. I added types to the whole library, and also updated some old compatibility code. Let me know if any changes are needed. As another PR, I think it would be great to have:
I you agree with this, I can make separate PRs |
Let's make separate PRs for these things. I'd prefer using Ruff for everything on the first bullet: formatting, linting and isort rules. You can see my example repo here for how I usually configure Ruff:
We may need to modify some of these rules for |
I presume you are using Would also be great if you could double check that Mypy now type checks your usage of |
We are making use of |
Here is a pull request making use of my branch: I had to add back Regarding mypy, we don't run it yet, but I can already see from my IDE (which uses |
Could you add a changelog entry for deprecating |
See c279dc4 |
Looking at the remaining type issue, might be another |
This is a mypy bug (works with pyright), but I can't produce a MRE: playground. Maybe this only happens when split into multiple files |
Thanks for the contribution, @Viicos! |
As
get_solo
hits the cache, type checkers can't infer the return type of the method correctly. User could usetyping.cast
or similar but having it fixed in the library directly sounds easier.typing.TypeVar
is used as a workaround untiltyping.Self
can be used without making use oftyping_extensions
.